BlackPhreaker
Новичок
- Сообщения
- 18
- Репутация
- 0
Может кто сталкивался???
Почему не отправляются данные в Com Port???
Почему не отправляются данные в Com Port???
Код:
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <CommMG.au3>
conecta(4,9600)
HotKeySet("q","exitt")
;_CommSetDllPath("C:\Archivos de programa\AutoIt3\Include\commg.dll")
Local $hDLL = DllOpen("user32.dll")
While 1
If _IsPressed("26", $hDLL) or _IsPressed(57) Then ; Вверх или W
$v = 1
;_CommSendString("1")
ElseIf _IsPressed("28", $hDLL) or _IsPressed(53) Then ; Вниз или S
$v = 2
;_CommSendString("2")
ElseIf _IsPressed("27", $hDLL) or _IsPressed(44) Then ; Вправо или D
$v = 3
;_CommSendString("3")
ElseIf _IsPressed("25", $hDLL) Or _IsPressed(41) Then ; Влево или A
$v = 4
;_CommSendString("4")
Else
$v = 0
;_CommSendString("0")
EndIf
_CommSendString($v&@CRLF) ;~ Отправка данных в Com Port
ConsoleWrite($v&@CRLF) ;~ Отправка данных в Console
Sleep(50)
WEnd
DllClose($hDLL)
Func conecta($port,$baud) ; Настройка Com Port
If $baud = "" Then $baud = 9600
Local $sportSetError
ConsoleWrite(_CommListPorts(0))
_CommSetPort($port, $sportSetError, 9600, 8, "none",2,1)
if $sportSetError = '' Then
Return 1
ConsoleWrite("using " & _CommGetVersion(1))
Else
ConsoleWrite("error")
return $sportSetError
EndIf
EndFunc
Func Beeps() ; Пищалка
Beep(1976,800)
Sleep(50)
EndFunc
Func exitt() ; Закрываем Com Port
_CommCloseport()
Exit
EndFunc