GUI Button help
#1
Posted 02 March 2012 - 04:30 AM
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
#2
Posted 02 March 2012 - 08:36 AM
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
Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display
RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#3
Posted 02 March 2012 - 06:00 PM
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 this
and 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 1
If $time = 100 then
""the work""
Endif
$Time=$Time+1
Sleep(1000)
Wend
#4
Posted 02 March 2012 - 06:04 PM
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
Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display
RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#5
Posted 03 March 2012 - 02:15 AM
#6
Posted 03 March 2012 - 08:42 AM
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
Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display
RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#7
Posted 03 March 2012 - 06:34 PM
#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
#8
Posted 03 March 2012 - 06:44 PM
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:
#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 ;==>_Exit
All clear? Please ask if not.
M23
Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display
RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#9
Posted 04 March 2012 - 01:42 AM
thank you so much that is great ty
#10
Posted 14 March 2012 - 12:36 AM
Edited by ProfessorBean, 14 March 2012 - 03:47 AM.
Code removed.
#11
Posted 14 March 2012 - 02:01 AM
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.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.
#12
Posted 14 March 2012 - 02:21 AM
Edited by ProfessorBean, 14 March 2012 - 03:48 AM.
#13
Posted 14 March 2012 - 02:29 AM
#14
Posted 14 March 2012 - 02:57 AM
Edited by ProfessorBean, 14 March 2012 - 03:48 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





