epicfail Posted September 12, 2009 Share Posted September 12, 2009 hello im trying to add a GUI to my bot. My bot has sleep in it when it waits 4 the next click and then a sleep 4 6 hours. I tryed to make a gui that has start and stop on it but once the bot starts the stop button dosnt work how would i make it so i can get it to work? Link to comment Share on other sites More sharing options...
AwAke Posted September 12, 2009 Share Posted September 12, 2009 When using sleep that pauses the whole script to pause, including the GUI. What I think your looking for is: GuiSetOnEvent. Look at it in the help file. Link to comment Share on other sites More sharing options...
epicfail Posted September 12, 2009 Author Share Posted September 12, 2009 welli need it to sleep cos i have mouse clicks and need it to wait/sleep before the next click Link to comment Share on other sites More sharing options...
jvanegmond Posted September 12, 2009 Share Posted September 12, 2009 (edited) You can split up a sleep command to ensure that gui events keep coming through._Sleep(8000) ; sleep for 8 seconds but GUI messages can still come through : ) : ) : ) Func _Sleep($wait, $delay = 10) $init = TimerInit() While TimerDiff($init) < $wait Sleep($delay) Wend EndFuncI'm not 100% sure on this but I think GUIOnEventMode breaks through the sleep anyway, making this useless.Edit: Yep, this works:Opt("GUIOnEventMode", 1) $hWnd = GUICreate("Win", 200, 200) $hButton = GUICtrlCreateButton("WinButton", 10, 10, 180, 180) GUICtrlSetOnEvent($hButton, "Buttonclick") GUISetState(@SW_SHOW, $hWnd) Sleep(10000) Func Buttonclick() GUICtrlSetData($hButton, "You clicked me.") EndFuncHere's how to solve it without concurrency (is a little less accurate probably, but who cares lol )$hWnd = GUICreate("Win", 200, 200) $hButton = GUICtrlCreateButton("WinButton", 10, 10, 180, 180) GUISetState(@SW_SHOW, $hWnd) _Sleep(10000) ; sleep for 10 seconds but GUI messages can still come through : ) : ) : ) Func _Sleep($wait, $delay = 10) $init = TimerInit() While TimerDiff($init) < $wait Sleep($delay) ApplicationDoEvents() Wend EndFunc Func ApplicationDoEvents() $hMsg = GUIGetMsg() Switch $hMsg Case -3 ; $GUI_EVENT_CLOSE Exit Case $hButton Buttonclick() EndSwitch EndFunc Func Buttonclick() GUICtrlSetData($hButton, "You clicked me.") EndFunc Edited September 12, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 12, 2009 Author Share Posted September 12, 2009 thankyou but the problem is that i i have the button exit when im using sleep it dont exit. Link to comment Share on other sites More sharing options...
jvanegmond Posted September 12, 2009 Share Posted September 12, 2009 In my examples I show you how to solve that problem. I don't know how I can be more specific. github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 13, 2009 Author Share Posted September 13, 2009 cant get it to work if im still using _sleep to wait 4 my next mouse click the my exit button dont work Link to comment Share on other sites More sharing options...
Yashied Posted September 13, 2009 Share Posted September 13, 2009 And where is your Exit Button, where the source code? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
epicfail Posted September 13, 2009 Author Share Posted September 13, 2009 expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/cs #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Local $loop = 0 Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) #include <IsChecked.au3> #include <Timers.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 329, 123, 192, 124) $Input1 = GUICtrlCreateInput("Email", 72, 16, 185, 21) $Input2 = GUICtrlCreateInput("Password", 72, 40, 185, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL)) $Button1 = GUICtrlCreateButton("Start Bot", 56, 88, 105, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Exit", 168, 88, 105, 25, $WS_GROUP) GUICtrlSetOnEvent($Button2, "_EXIT") $Checkbox1 = GUICtrlCreateCheckbox("Save Email & Password", 72, 64, 129, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _Sleep(10000) ; sleep for 10 seconds but GUI messages can still come through : ) : ) : ) Func _Sleep($wait, $delay = 10) $init = TimerInit() While TimerDiff($init) < $wait Sleep($delay) ApplicationDoEvents() Wend EndFunc Func ApplicationDoEvents() $hMsg = GUIGetMsg() Switch $hMsg Case -3 ; $GUI_EVENT_CLOSE Exit Case $Button1 start() EndSwitch EndFunc Func start() $oIE = _IECreate ("www.Mysite.com") $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", @SW_MAXIMIZE) _IELoadWait ($oIE) $oform = _IEFormGetObjByName($oIE, "menubar_login") $oQuery = _IEFormElementGetObjByName($oform, "email") $o_Query = _IEFormElementGetObjByName($oform, "pass") $username = GUICtrlRead($Input1) $password = GUICtrlRead($Input2) _IEFormElementSetValue($oQuery, $username) _IEFormElementSetValue($o_Query, $password) Send("{TAB}{ENTER}") _IELoadWait ($oIE) MouseMove(765,391) MouseDown("left") MouseUp("left") _Sleep(8000) MouseMove(775,367) MouseDown("left") MouseUp("left") _Sleep(8000) MouseMove(774,380) MouseDown("left") MouseUp("left") _Sleep(8000) MouseMove(344,256) MouseDown("left") MouseUp("left") _Sleep(8000) MouseMove(394,363) MouseDown("left") MouseUp("left") _IEQuit ($oIE) EndFunc Func _EXIT() Exit EndFunc Link to comment Share on other sites More sharing options...
jvanegmond Posted September 13, 2009 Share Posted September 13, 2009 It could still get stuck in _IELoadWait. github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 13, 2009 Author Share Posted September 13, 2009 so there nothing u can do? cos i was planing to do a 7 hour sleep at the end of it and loop it Link to comment Share on other sites More sharing options...
jvanegmond Posted September 13, 2009 Share Posted September 13, 2009 It could still get stuck in _IELoadWait for about 2 seconds. The rest all works. The GUI stays for 10 seconds and then it closes, unless you press the button. github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 13, 2009 Author Share Posted September 13, 2009 no i want it to be able to stop the running scrit ad exit the gui when its sleeping waiting 4 the next click Link to comment Share on other sites More sharing options...
jvanegmond Posted September 13, 2009 Share Posted September 13, 2009 I just said what it does. github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 14, 2009 Author Share Posted September 14, 2009 well i tested it itdont exit if the sleep is running Link to comment Share on other sites More sharing options...
jvanegmond Posted September 14, 2009 Share Posted September 14, 2009 You have to use either GUIOnEventMode or you use GUIGetMsg. I have shown examples of both, but I think you interpreted it as being the same thing. If you use GUIGetMsg (you do in the code you posted above) you can't use functions like GUICtrlSetOnEvent or GUISetOnEvent. expandcollapse popupLocal $loop = 0 Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) #include <Timers.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 329, 123, 192, 124) $Input1 = GUICtrlCreateInput("Email", 72, 16, 185, 21) $Input2 = GUICtrlCreateInput("Password", 72, 40, 185, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL)) $Button1 = GUICtrlCreateButton("Start Bot", 56, 88, 105, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Exit", 168, 88, 105, 25, $WS_GROUP) $Checkbox1 = GUICtrlCreateCheckbox("Save Email & Password", 72, 64, 129, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _Sleep(10000) ; sleep for 10 seconds but GUI messages can still come through : ) : ) : ) Func _Sleep($wait, $delay = 10) $init = TimerInit() While TimerDiff($init) < $wait Sleep($delay) ApplicationDoEvents() Wend EndFunc Func ApplicationDoEvents() $hMsg = GUIGetMsg() Switch $hMsg Case -3 ; $GUI_EVENT_CLOSE Exit Case $Button1 start() Case $Button2 _Exit() EndSwitch EndFunc Func start() $oIE = _IECreate ("www.Mysite.com") $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", @SW_MAXIMIZE) _IELoadWait ($oIE) $oform = _IEFormGetObjByName($oIE, "menubar_login") $oQuery = _IEFormElementGetObjByName($oform, "email") $o_Query = _IEFormElementGetObjByName($oform, "pass") $username = GUICtrlRead($Input1) $password = GUICtrlRead($Input2) _IEFormElementSetValue($oQuery, $username) _IEFormElementSetValue($o_Query, $password) Send("{TAB}{ENTER}") _IELoadWait ($oIE) MouseMove(765,391) MouseDown("left") MouseUp("left") _Sleep(8000) MouseMove(775,367) MouseDown("left") MouseUp("left") _Sleep(8000) MouseMove(774,380) MouseDown("left") MouseUp("left") _Sleep(8000) MouseMove(344,256) MouseDown("left") MouseUp("left") _Sleep(8000) MouseMove(394,363) MouseDown("left") MouseUp("left") _IEQuit ($oIE) EndFunc Func _EXIT() Exit EndFunc And don't say "it doesn't work" when it clearly does work in both of the examples I posted. You just copy pasted it wrong. github.com/jvanegmond 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