gspot Posted May 29, 2014 Share Posted May 29, 2014 (edited) Hi, Im still strugling with some basic stuff in autoit. I have a GUI and i have Hotkeysets in a au3 script, i want both to work, but when the Form is called the Hotkeysets dont respond because the script its in the while 1 of the form. What is the way around this? Can you help me? Ps: The GUI in my script doesnt do anything yet... Thanks expandcollapse popup#include <MsgBoxConstants.au3> AutoItSetOption("TrayIconDebug", 1);0-off #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $fPaused = False Global $status1 = "active" & @CRLF #Region ### START Koda GUI section ### Form=d:\documents and settings\ptpro.pvmarques\desktop\autoit\gso portin\form1.kxf $Form1_1 = GUICreate("GSO Portin", 182, 272, 700, 391) GUISetBkColor(0xA6CAF0) $Label1 = GUICtrlCreateLabel("GSO Portin", 24, 224, 146, 36) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xE9E7E2) $Button_iniciar = GUICtrlCreateButton("Iniciar", 40, 24, 105, 33, BitOR($WS_BORDER,$WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0x50CB62) GUICtrlSetTip(-1, "[F4] Inicia robot se este estiver parado") GUICtrlSetCursor (-1, 0) $Button_Pausar = GUICtrlCreateButton("Pausar", 40, 70, 105, 33, BitOR($WS_BORDER,$WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFF80) GUICtrlSetTip(-1, "Pausa robot") GUICtrlSetCursor (-1, 0) $Button_reload = GUICtrlCreateButton("Reload", 40, 172, 105, 33, BitOR($WS_BORDER,$WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0x0080FF) GUICtrlSetCursor (-1, 0) $Button_stop = GUICtrlCreateButton("STOP", 40, 118, 105, 33, BitOR($WS_BORDER,$WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xEB6A14) GUICtrlSetCursor (-1, 0) Dim $Form1_1_AccelTable[1][2] = [["{F4}", $Button_iniciar]] GUISetAccelerators($Form1_1_AccelTable) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd HotKeySet("{PAUSE}", "TogglePause") HotKeySet("+{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") ; Shift-Alt-d HotKeySet("{F9}", "_localtest") While 1 Sleep(100) WEnd Func TogglePause() $fPaused = Not $fPaused While $fPaused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit EndFunc ;==>Terminate Func ShowMessage() MsgBox($MB_SYSTEMMODAL, "", "This is a message.") EndFunc ;==>ShowMessage Func _localtest() Local $status1 = "Inactive" & @CRLF ConsoleWrite($status1) MsgBox(0, 0, "test") EndFunc ;==>_localtest Edited May 29, 2014 by gspot Link to comment Share on other sites More sharing options...
Solution Palestinian Posted May 29, 2014 Solution Share Posted May 29, 2014 Put the hotkeyset at the top of your script and it will work. gspot 1 Link to comment Share on other sites More sharing options...
November Posted May 29, 2014 Share Posted May 29, 2014 Hi there gspot, As Palestinian as wrote, is ok. You have a loop that doesn't make sense as is. expandcollapse popup#include <MsgBoxConstants.au3> AutoItSetOption("TrayIconDebug", 1);0-off #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> HotKeySet("{PAUSE}", "TogglePause") HotKeySet("+{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") ; Shift-Alt-d HotKeySet("{F9}", "_localtest") Global $fPaused = False Global $status1 = "active" & @CRLF #Region ### START Koda GUI section ### Form=d:\documents and settings\ptpro.pvmarques\desktop\autoit\gso portin\form1.kxf $Form1_1 = GUICreate("GSO Portin", 182, 272, 700, 391) GUISetBkColor(0xA6CAF0) $Label1 = GUICtrlCreateLabel("GSO Portin", 24, 224, 146, 36) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xE9E7E2) $Button_iniciar = GUICtrlCreateButton("Iniciar", 40, 24, 105, 33, BitOR($WS_BORDER, $WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0x50CB62) GUICtrlSetTip(-1, "[F4] Inicia robot se este estiver parado") GUICtrlSetCursor(-1, 0) $Button_Pausar = GUICtrlCreateButton("Pausar", 40, 70, 105, 33, BitOR($WS_BORDER, $WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFF80) GUICtrlSetTip(-1, "Pausa robot") GUICtrlSetCursor(-1, 0) $Button_reload = GUICtrlCreateButton("Reload", 40, 172, 105, 33, BitOR($WS_BORDER, $WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0x0080FF) GUICtrlSetCursor(-1, 0) $Button_stop = GUICtrlCreateButton("STOP", 40, 118, 105, 33, BitOR($WS_BORDER, $WS_CLIPSIBLINGS)) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xEB6A14) GUICtrlSetCursor(-1, 0) Dim $Form1_1_AccelTable[1][2] = [["{F4}", $Button_iniciar]] GUISetAccelerators($Form1_1_AccelTable) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd #cs ; this don't make sense, you are already in a loop above and this loop doesn't do nothing While 1 Sleep(100) WEnd #ce Func TogglePause() $fPaused = Not $fPaused While $fPaused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit EndFunc ;==>Terminate Func ShowMessage() MsgBox($MB_SYSTEMMODAL, "", "This is a message.") EndFunc ;==>ShowMessage Func _localtest() Local $status1 = "Inactive" & @CRLF ConsoleWrite($status1) MsgBox(0, 0, "test") EndFunc ;==>_localtest Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now