ronmage Posted March 2, 2012 Share Posted March 2, 2012 Hi, i am using a GUI with a start and stop button. when the start button it hit i want it to run and when you hit stop i would like it to stop. what is going on is that i hit start and i can hit stop and it is real Skippy and not working very well but it will stop at some point. what i am doing it while 1 $nMsg = GUIGetMsg() Switch $nMsg case $Button2 $a=1 EndSwitch While $a=1 If $nMsg = $button1 then $a=0 Endif under this while is about 30 seconds worth the work. Wend Wend Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2012 Moderators Share Posted March 2, 2012 ronmage,Do you want to interrupt the "30 seconds worth the work" when you press the button or are you happy to wait until it has finished? If you want to interrupt it, does the "work" involve a loop, a series of commands, or is it a single command that takes that time to run? The answers to the above will determine how you can best do what you want. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ronmage Posted March 2, 2012 Author Share Posted March 2, 2012 when you hit the start button the If statement comes true which is doing work but i am using a few sleep(1000) with in the if statement. i have been running it to problems with the program running faster then the computer so the sleep was the only way i could see to get it to work.but yes it is a loop that when the if is false then there is a 1 second sleep which is counting up till the if becomes true. looks like thisand yes i was trying to get the stop button to stop in mid way. i know that if it is on a sleep() then it will not stop but that would give a max of 1 second lag.Just wondering is the answer something to do with a function?While 1If $time = 100 then""the work""Endif$Time=$Time+1Sleep(1000)Wend Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2012 Moderators Share Posted March 2, 2012 ronmage,If you are looking at putting the "work" in a function and there are some places where you can wait and look for an interrruption sign, I suggest you read the Interrupting a running function tutorial in the Wiki - that explains how you can do that in AutoIt. It is a bit advanced in places, but give it a try and ask again if you need to. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ronmage Posted March 3, 2012 Author Share Posted March 3, 2012 no the work was not in a function i was wondering if the exit for the loop was going to work with a function. but with that that page you showed me will help me with another problem, sadly not this one Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2012 Moderators Share Posted March 3, 2012 ronmage,Unless you show what the "work" consists of it is going to be very difficult to help any more. As I explained above, how we might go about interrupting it depends very much on what exactly is going on during that time. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ronmage Posted March 3, 2012 Author Share Posted March 3, 2012 that is a good point. ill post the code. this was me playing around so that code is a mess sorry did not think i was going to be showing anyoneexpandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 318, 146, 1165, 426) $Button1 = GUICtrlCreateButton("Start", 24, 80, 97, 33) $Button2 = GUICtrlCreateButton("Stop", 184, 80, 97, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### HotKeySet("+{ESC}", "_Exit") MsgBox(0, "Info", "To Exit the program Hit Shift + Esc") $a=120 $b=900 $c=0 $d=0 $e=0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $e=1 EndSwitch While $e=1 $nMsg = GUIGetMsg() If $nMsg = $Button2 Then $e=0 Exit EndIf If $a > 117 Then Beep() EndIf While $a >= 120 If $d=0 Then MouseClick("left", -616, 333,3,10) Sleep(200) MouseClick("left", -69, 89,2,5) $d=1 EndIf Sleep(300) MouseClick("left", -977, $b,1,0) $b=$b-10 If $b <= 600 Then $b = 900 $d=0 $c=$c+1 Sleep(100) EndIf If $c = 2 Then Sleep(1000) MouseClick("left", -1069, 594,3,10) Sleep(1000) MouseClick("left", -266, 412,3,10) Sleep(1000) MouseClick("left", -1027, 677) Sleep(1000) MouseClick("left", -266, 412,3,10) $b=870 $a=0 $c=0 EndIf WEnd Sleep(1000) $a=$a+1 WEnd WEnd Func _Exit() MsgBox(0, "Goodbye", "I'm exiting now") Exit EndFunc ;==>_Exit what it is doing is when you hit the start button it works in this case it is moving the mouse so i cant test the stopping mid run. but what it is doing is when it is done running there is a gap where it is counting up 2 min, in that time i want to hit stop and have it stop right there you have to spam click it a bit to get it to stop. the other way to do it would to when you click it get the button to change somehow showing that it was pressed and will close soon Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2012 Moderators Share Posted March 3, 2012 ronmage,You have plenty of places to look for the "Stop button. Here is something that should work - note I have replaced all the MouseClicks with ConsoleWrites so you can see what is going on:expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("+{ESC}", "_Exit") $Form1 = GUICreate("Form1", 318, 146, 1165, 426) $Button1 = GUICtrlCreateButton("Start", 24, 80, 97, 33) $Button2 = GUICtrlCreateButton("Stop", 184, 80, 97, 33) GUISetState(@SW_SHOW) MsgBox(0, "Info", "To Exit the program Hit Shift + Esc") $a = 120 $b = 900 $c = 0 $d = 0 $e = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 $e = 1 EndSwitch While $e = 1 If $a > 117 Then Beep() EndIf While $a >= 120 If $d = 0 Then ; MouseClick("left", -616, 333, 3, 10) ConsoleWrite("Click" & @CRLF) _Wait(200) ; MouseClick("left", -69, 89, 2, 5) ConsoleWrite("Click" & @CRLF) $d = 1 EndIf _Wait(300) ; MouseClick("left", -977, $b, 1, 0) ConsoleWrite("Click" & @CRLF) $b = $b - 10 If $b <= 600 Then $b = 900 $d = 0 $c = $c + 1 _Wait(100) EndIf If $c = 2 Then _Wait(1000) ; MouseClick("left", -1069, 594, 3, 10) ConsoleWrite("Click" & @CRLF) _Wait(1000) ; MouseClick("left", -266, 412, 3, 10) ConsoleWrite("Click" & @CRLF) _Wait(1000) ; MouseClick("left", -1027, 677) ConsoleWrite("Click" & @CRLF) _Wait(1000) ; MouseClick("left", -266, 412, 3, 10) ConsoleWrite("Click" & @CRLF) $b = 870 $a = 0 $c = 0 EndIf WEnd _Wait(1000) $a = $a + 1 WEnd WEnd Func _Wait($iDelay) $iBegin = TimerInit() Do Switch GUIGetMsg() Case $Button2 ConsoleWrite("Exiting" & @CRLF) Exit EndSwitch Until TimerDiff($iBegin) > $iDelay EndFunc Func _Exit() MsgBox(0, "Goodbye", "I'm exiting now") Exit EndFunc ;==>_ExitAll clear? Please ask if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ronmage Posted March 4, 2012 Author Share Posted March 4, 2012 wow that works WAY better. never used TimerInit. thank you so much that is great ty Link to comment Share on other sites More sharing options...
ProfessorBean Posted March 14, 2012 Share Posted March 14, 2012 (edited) nevermind, i fixed it, please remove this. Edited March 14, 2012 by ProfessorBean Code removed. Link to comment Share on other sites More sharing options...
Valik Posted March 14, 2012 Share Posted March 14, 2012 HI i have a gui and a list of hotkey sets, how do i make the two work to gather? this is my GUI <Removed> this is my hotkeys <Removed> now the hotkeys work fine and the gui works fine but when i try and merge the two it doesn't work.... help. You are hijacking a dead thread to ask for help with something against the rules (game automation). That's not exactly the best course of action. Before you post again I suggest you locate your brain, insert it back into your head and then use it to read (and comprehend!) the forum rules. Link to comment Share on other sites More sharing options...
ProfessorBean Posted March 14, 2012 Share Posted March 14, 2012 (edited) nevermind, i fixed it, please remove this. Edited March 14, 2012 by ProfessorBean Link to comment Share on other sites More sharing options...
Valik Posted March 14, 2012 Share Posted March 14, 2012 I see that you were unable to locate your brain. That is unfortunate. Link to comment Share on other sites More sharing options...
ProfessorBean Posted March 14, 2012 Share Posted March 14, 2012 (edited) nevermind, i fixed it, please remove this. Edited March 14, 2012 by ProfessorBean 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