dryper Posted August 16, 2008 Share Posted August 16, 2008 Hello everyone! i have started wiTh some autoit again and trying to se if i can manage to make somthing useful but i Cant seem to get my Stop start button to work I found a example script in the Manual and added a While in it .. but when i click on the "stop " button it doesnt respond .. i think this is because its still in the while thingy and doesnt read rest of the code.. but how can i make it check if i pressed it or not? #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button"); will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton("Button Test", 0, -1) GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 While ($msg = $button_1) ;// MY FUNCTION GOES HERE Wend Case $msg = $Button_2 MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSelect WEnd EndFunc ;==>Example If something is confusing just say so Thanks Dryper Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 16, 2008 Share Posted August 16, 2008 Hello everyone! i have started wiTh some autoit again and trying to se if i can manage to make somthing useful but i Cant seem to get my Stop start button to work I found a example script in the Manual and added a While in it .. but when i click on the "stop " button it doesnt respond .. i think this is because its still in the while thingy and doesnt read rest of the code.. but how can i make it check if i pressed it or not? #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button"); will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton("Button Test", 0, -1) GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 While ($msg = $button_1) ;// MY FUNCTION GOES HERE Wend Case $msg = $Button_2 MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSelect WEnd EndFunc ;==>Example If something is confusing just say so Thanks Dryper $msg never changes because you don't execute GuiGetMsg() again while the loop is running. So $msg = $button_1 is always true once it goes there. This is just bad logic. You should consider GuiOnEventMode instead of a message loop if you want to interrupt other work with the GUI events. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
dryper Posted August 16, 2008 Author Share Posted August 16, 2008 (edited) $msg never changes because you don't execute GuiGetMsg() again while the loop is running. So $msg = $button_1 is always true once it goes there. This is just bad logic.You should consider GuiOnEventMode instead of a message loop if you want to interrupt other work with the GUI events. could you try set somthing easy up for me? i cant get this GuiOnEventMode to work Thanks DryperThe reason i used While is because its a Line that is gonna send a character to a game every 5 seconds .. though i know its bad logic because $msg will always be $bUtton_1 but i cant find anything in the help file in AUTOIT Edited August 16, 2008 by dryper Link to comment Share on other sites More sharing options...
dryper Posted August 16, 2008 Author Share Posted August 16, 2008 bump... ? Link to comment Share on other sites More sharing options...
rasim Posted August 17, 2008 Share Posted August 17, 2008 dryperExample:#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button"); will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton("Button Stop", 0, -1) GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 While ($msg <> $Button_2) $msg = GUIGetMsg() ConsoleWrite("MY FUNCTION GOES HERE" & @LF) Sleep(10) Wend ConsoleWrite("!> MY FUNCTION STOPPED" & @LF) EndSelect WEnd EndFunc ;==>Example 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