SteveO Posted January 12, 2008 Share Posted January 12, 2008 (edited) Okay, how do I get my program to Stop and wait for a new command when I click Stop in the GUI? Lets say my program is in the middle of a function, and the user presses the "Stop" button, how do I get the Program to respond to that and exit the function and jump into another loop until another button on the GUI is pressed? EDIT I need the program to jump out of a "For" loop when the Stop button is pressed. Edited January 12, 2008 by SteveO Link to comment Share on other sites More sharing options...
BrettF Posted January 12, 2008 Share Posted January 12, 2008 Depends what is being done whilst in the stop button becomes unresposonsive. I can see a loop, but your code I cannot. My crystal ball is cloudy Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
SteveO Posted January 12, 2008 Author Share Posted January 12, 2008 Depends what is being done whilst in the stop button becomes unresposonsive. I can see a loop, but your code I cannot. My crystal ball is cloudy hehe, sry. here you go. expandcollapse popupFunc NumPost() For $I = $startpost To $endpost _IENavigate($IE,$Thread[2] & $sid) $Post = _IEFormGetObjByName($IE,"post") $Mess = _IEFormElementGetObjByName($Post,"message") _IEFormElementSetValue($Mess, $startglobalbbcode & $Message & $endmsgbbcode & $startnumbbbcode & $sym & $I & $endglobalbbcode) _IEFormImageClick ($Post,"Submit","alt") $I = $I+1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Early Post End Check If $I == $endpost + 1 Then If $tymsgonoff == 1 Then Sleep(Random($min, $max, 1)) _IENavigate($IE,$Thread[3] & $sid) $Post = _IEFormGetObjByName($IE,"post") $Mess = _IEFormElementGetObjByName($Post,"message") _IEFormElementSetValue($Mess, $tymsg) _IEFormImageClick ($Post,"Submit","alt") ;;End Msg MsgBox(0, "The Bumping Catalyst v" & $ver, "Bumping Completed") Exit Else MsgBox(0, "The Bumping Catalyst v" & $ver, "Bumping Completed") Exit EndIf EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Sleep(Random($min, $max, 1)) _IENavigate($IE,$Thread[3] & $sid) $Post = _IEFormGetObjByName($IE,"post") $Mess = _IEFormElementGetObjByName($Post,"message") _IEFormElementSetValue($Mess, $startglobalbbcode & $Message & $endmsgbbcode & $startnumbbbcode & $sym & $I & $endglobalbbcode) _IEFormImageClick ($Post,"Submit","alt") Sleep(Random($min, $max, 1)) Next ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If $tymsgonoff == 1 Then Sleep(Random($min, $max, 1)) _IENavigate($IE,$Thread[2] & $sid) $Post = _IEFormGetObjByName($IE,"post") $Mess = _IEFormElementGetObjByName($Post,"message") _IEFormElementSetValue($Mess, $tymsg) _IEFormImageClick ($Post,"Submit","alt") ;;End Msg MsgBox(0, "The Bumping Catalyst v" & $ver, "Bumping Completed") Exit Else MsgBox(0, "The Bumping Catalyst v" & $ver, "Bumping Completed") Exit EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EndFunc Link to comment Share on other sites More sharing options...
MrCreatoR Posted January 12, 2008 Share Posted January 12, 2008 Hi, You not need jump from loop to loop, you just check the events in the main loop ... #include <GuiConstants.au3> $GUI = GUICreate("Test Script", 300, 200) $Button_1 = GUICtrlCreateButton("My Button 1", 20, 40, 80, 20) $Button_2 = GUICtrlCreateButton("My Button 2", 20, 80, 80, 20) $CheckBox = GUICtrlCreateCheckbox("My CheckBox", 20, 120) GUISetState(@SW_SHOW, $GUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button_1 MsgBox(0, "", "Button <" & GUICtrlRead($Button_1, 1) & "> pressed") Case $Button_2 MsgBox(0, "", "Button <" & GUICtrlRead($Button_2, 1) & "> pressed") Case $CheckBox $IsChecked = BitAND(GUICtrlRead($CheckBox), $GUI_CHECKED) = $GUI_CHECKED MsgBox(0, "", "Checkbox checked = " & $IsChecked) EndSwitch WEnd  Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1  AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ==================================================    AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
SteveO Posted January 12, 2008 Author Share Posted January 12, 2008 (edited) Hi, You not need jump from loop to loop, you just check the events in the main loop ... #include <GuiConstants.au3> $GUI = GUICreate("Test Script", 300, 200) $Button_1 = GUICtrlCreateButton("My Button 1", 20, 40, 80, 20) $Button_2 = GUICtrlCreateButton("My Button 2", 20, 80, 80, 20) $CheckBox = GUICtrlCreateCheckbox("My CheckBox", 20, 120) GUISetState(@SW_SHOW, $GUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button_1 MsgBox(0, "", "Button <" & GUICtrlRead($Button_1, 1) & "> pressed") Case $Button_2 MsgBox(0, "", "Button <" & GUICtrlRead($Button_2, 1) & "> pressed") Case $CheckBox $IsChecked = BitAND(GUICtrlRead($CheckBox), $GUI_CHECKED) = $GUI_CHECKED MsgBox(0, "", "Checkbox checked = " & $IsChecked) EndSwitch WEnd That's how my main code is set up. My problem is, I need the program to jump out of a "For" loop when the Stop button is pressed. Edited January 12, 2008 by SteveO Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted January 12, 2008 Share Posted January 12, 2008 (edited) This is what I always had problems with. I never really did figure out a way to have a global check for if anything was pressed. I guess you could possibly declare $nMsg or whatever your variable may be as like a global variable, then use adlibenable to start doing checks while you are in a function then when the function ends or whatever disable the adlib, but then again you would need to figure out a way to send exitloop . If (name not mentioned) would program some multithreading that would be KICK ASS. What you could try is adding this $Msg = GUIGetMsg() If $Msg = $SOMEBUTTON Then Exitloop Now add that right before your for loop starts. The only problem is it will only execute after the for loop goes through completely then back to the start. And by he looks of it using IE stuff it will take a little while but so far its your only option. EDIT: ooops out of the for loop , should be exitloop not return Edited January 12, 2008 by Thatsgreat2345 Link to comment Share on other sites More sharing options...
SteveO Posted January 12, 2008 Author Share Posted January 12, 2008 This is what I always had problems with. I never really did figure out a way to have a global check for if anything was pressed. I guess you could possibly declare $nMsg or whatever your variable may be as like a global variable, then use adlibenable to start doing checks while you are in a function then when the function ends or whatever disable the adlib, but then again you would need to figure out a way to send exitloop . If (name not mentioned) would program some multithreading that would be KICK ASS.That might just work. I'll try testing with that. Thanks. Link to comment Share on other sites More sharing options...
MrCreatoR Posted January 12, 2008 Share Posted January 12, 2008 (edited) Take a look at Timers, you can run a timer (using callback) that will check if there was an event.If there was an event, just set a global variable, and check that variable in your loop(s).P.SChecking with GUIGetMsg() will slow down you loop, because this function include a pause on 10 ms (only when non "OnEvent mode" used). Edited January 12, 2008 by MsCreatoR  Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1  AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ==================================================    AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
BrettF Posted January 12, 2008 Share Posted January 12, 2008 If you add the If GUIGetMsg () = $SomeButton Then ExitLoop at the toop of your For Loop, then it should do what you want Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
MrCreatoR Posted January 12, 2008 Share Posted January 12, 2008 If you add the If GUIGetMsg () = $SomeButton Then ExitLoop at the toop of your For Loop, then it should do what you want I edited my previouse post (i didn't seen your post). P.S Checking with GUIGetMsg() will slow down you loop, because this function include a pause on 10 ms (only when non "OnEvent mode" used).  Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1  AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ==================================================    AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
BrettF Posted January 12, 2008 Share Posted January 12, 2008 (edited) 10ms is unlikely to be noticed by the user EDIT: Unless of course, that loop is really, really, really, big Edited January 12, 2008 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
SteveO Posted January 12, 2008 Author Share Posted January 12, 2008 (edited) If you add the If GUIGetMsg () = $SomeButton Then ExitLoop at the toop of your For Loop, then it should do what you want I tried that, and I tried making a function to check the GUI Message. Then I have it check if the stop button was pressed in specified times in the loop. I have to press the stop button like 20 times before it actually gets read. Edited January 12, 2008 by SteveO Link to comment Share on other sites More sharing options...
Paulie Posted January 12, 2008 Share Posted January 12, 2008 Maybe you could solve your problem with GuiOnEvent? Link to comment Share on other sites More sharing options...
Paulie Posted January 12, 2008 Share Posted January 12, 2008 Maybe you could solve your problem with GuiOnEvent? 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