#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ;-----------------------------------------------------------Includes : #include #include #include ;Include the Serial UDF #include 'CommMG.au3' ;-----------------------------------------------------------GUI : $Form1 = GUICreate("test LED", 400, 200) $rouge = GUICtrlCreateButton("Rouge",5,5,140,190) $jaune = GUICtrlCreateButton("Jaune",150,5,140,190) $boutonrouge = GUICtrlCreateLabel("Off rouge",300,15) $boutonnoir= GUICtrlCreateLabel("Off noir",300,30) $test2 = 0 $r=0 $j=0 ;-----------------------------------------------------------Variables : ;Internal for the Serial UDF Global $sportSetError = '' ;COM Vars Global $CMPort = 4 ; Port Global $CmBoBaud = 9600 ; Baud Global $CmboDataBits = 8 ; Data Bits Global $CmBoParity = "none" ; Parity Global $CmBoStop = 1 ; Stop Global $setflow = 2 ; Flow _CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _CommSendstring("20" & @CR) _CommSendstring("10" & @CR) _CommClosePort() Exit case $rouge _rouge() case $jaune _jaune() EndSwitch $test = _CommGetLine(@CR,10000,0) if $test = 3 then GUICtrlSetData($boutonrouge,"ON rouge") Elseif $test = 4 then GUICtrlSetData($boutonnoir,"ON noir") else GUICtrlSetData($boutonrouge,"OFF rouge") GUICtrlSetData($boutonnoir,"OFF noir") EndIf WEnd ;-----------------------------------------------------------Fonctions : ;---------------------rouge Func _rouge() if $r=0 Then _CommSendstring("21" & @CR) $r=1 elseif $r=1 Then _CommSendstring("20" & @CR) $r=0 EndIf EndFunc ;---------------------jaune Func _jaune() if $j=0 Then _CommSendstring("11" & @CR) $j=1 elseif $j=1 Then _CommSendstring("10" & @CR) $j=0 EndIf EndFunc