iRAWRRichard Posted December 15, 2011 Share Posted December 15, 2011 How do I write a script in which it'll detect whether the client has exited? If the client has exited, I want it to exit the loop of the current function it's performing and perform another function to get the client reopened. Link to comment Share on other sites More sharing options...
water Posted December 15, 2011 Share Posted December 15, 2011 Please see function AdlibRegister. This lets you register a function that is called every x milliseconds. In this function you can check the status of the client and do whatever you want. When you end the function the script keeps on processing where it left. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
iRAWRRichard Posted December 15, 2011 Author Share Posted December 15, 2011 Is there a thank button somewhere? :] Thanks! Link to comment Share on other sites More sharing options...
water Posted December 15, 2011 Share Posted December 15, 2011 Just saying thank you is enough My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
iRAWRRichard Posted December 15, 2011 Author Share Posted December 15, 2011 Since the AdlibRegister function checks back every few intervals, is there an optimal time I should put for it? I don't want to put something so low that would cause CPU stress, unless this doesn't stress the CPU that much anyways. Link to comment Share on other sites More sharing options...
water Posted December 15, 2011 Share Posted December 15, 2011 It depends on your application. What happens if the client exits? How fast have you to detect this change? But I think to set a value of 250 or 500 (means 4 or 2 checks per second) will be fine. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
iRAWRRichard Posted December 15, 2011 Author Share Posted December 15, 2011 (edited) Alright thank you! Also thanks for the quick replies. I honestly wasn't expecting an answer until tomorrow. Edited December 15, 2011 by iRAWRRichard Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 15, 2011 Moderators Share Posted December 15, 2011 iRAWRRichard, You will probably find that for water (and for me) it is already tomorrow! 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...
iRAWRRichard Posted December 16, 2011 Author Share Posted December 16, 2011 The check works when the function is somewhere close to the beginning. However as the function gets closer to the middle, the check stops working :/ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 16, 2011 Moderators Share Posted December 16, 2011 iRAWRRichard,It is obvious that the error is on Line 23487 - you have spurgled the exobrox at that point. .....Seriously, how are we supposed to help you with so few clues? Please post the code you have - but please use Code tags. Put [autoit] before and [/autoit] after your posted code. Once we see what is going on we can offfer more sensible advice. 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...
iRAWRRichard Posted December 16, 2011 Author Share Posted December 16, 2011 (edited) Ahh sorry haha. Well here's my full script :] expandcollapse popupHotKeySet("{F1}", "Start") HotKeySet("{F2}", "Stop") Opt("MouseCoordMode", 2) Opt("PixelCoordMode", 2) AdlibRegister("CheckClient", 5000) $RUNCOUNTER = 0 $TIMEOUT = 165000 $TIMEEXIT = 150000 Const $ID = "" Const $PASSWORD = "" Const $CHANNEL = 6 ; will change into array Const $CHARACTER = 2 ; will change into array While 1 DisplayToolTip(0) WinWaitActive("Client", "") WEnd Func CheckClient() If Not ProcessExists("Client.exe") Then StartClient() Login() Start() EndIf EndFunc Func StartClient() ShellExecute("C:Client.exe") EndFunc Func Login() Do PixelSearch(482, 414, 482, 414, 0xFFFFFF, 1) Until Not @error WinSetOnTop("Client", "", 1) WinActivate("Client") MouseClick("left", 400, 300) Do PixelSearch(61, 94, 61, 94, 0xDDEE88, 1) Until Not @error MouseClick("left", 398, 291, 2) ControlSend("Client", "", "", $ID) ControlSend("Client", "", "", "{TAB}") ControlSend("Client", "", "", $PASSWORD) ControlSend("Client", "", "", "{ENTER}") Do PixelSearch(135, 57, 135, 57, 0xFFCC00, 1) Until Not @error MouseClick("left", 162, 59) Do PixelSearch(251, 249, 251, 249, 0xFFDD00, 1) Until Not @error MouseClick("left", 260, 327, 2) Do PixelSearch(117, 153, 117, 153, 0xFF7700, 1) Until Not @error ControlSend("Client", "", "", "{ENTER}") Do PixelSearch(371, 245, 371, 245, 0xFFBB00, 1) Until Not @error ControlSend("Client", "", "", "{ENTER}") EndFunc Func Start() WinActivate("Client") WinSetOnTop("Client", "", 1) WinMove("Client", "", 0, 0) Do PixelSearch(482, 414, 482, 414, 0xCCEEEE, 2) Until Not @error MouseClick("left", 564, 555) Do PixelSearch(431, 353, 431, 353, 0xFF0000, 2) Until Not @error ControlSend("Client", "", "", "{DOWN}") ControlSend("Client", "", "", "{ENTER}") Do PixelSearch(431, 392, 431, 392, 0xFF0000, 2) Until Not @error ControlSend("Client", "", "", "{ENTER}") Call("StageOne") EndFunc Func StageOne() WinActivate("Client") $RUNCOUNTER = $RUNCOUNTER + 1 Do PixelSearch(445, 237, 445, 237, 0xDDDDDD, 1) Until Not @error DisplayToolTip(1) $TIMER = TimerInit() Send("{RIGHT down}") Sleep(700) Send("{RIGHT up}") While TimerDiff($TIMER) <= $TIMEOUT Do Do PixelSearch(660, 450, 885, 546, 0x309C29, 20) Until Not @error Send("{S down}") PixelSearch(660, 450, 885, 546, 0x309C29, 20) Until @error Send("{S up}") WEnd Call("StageTwo") EndFunc Func StageTwo() Do PixelSearch(444, 238, 444, 238, 0xDDDDDD, 1) Until Not @error DisplayToolTip(2) $TIMER = TimerInit() Send("{RIGHT down}") Sleep(700) Send("{RIGHT up}") While TimerDiff($TIMER) <= $TIMEOUT Do Do PixelSearch(660, 450, 885, 546, 0xCC0000, 10) Until Not @error Send("{S down}") PixelSearch(660, 450, 885, 546, 0xCC0000, 10) Until @error Send("{S up}") WEnd Do PixelSearch(386, 275, 286, 275, 0xFFEEEE, 1) Until Not @error Call("StageThree") EndFunc Func StageThree() Do PixelSearch(445, 236, 445, 236, 0xDDDDDD, 1) Until Not @error DisplayToolTip(3) $TIMER = TimerInit() Send("{RIGHT down}") Sleep(700) Send("{RIGHT up}") While TimerDiff($TIMER) <= $TIMEEXIT Do Do PixelSearch(660, 450, 885, 546, 0x557799, 10) Until Not @error Send("{S down}") PixelSearch(660, 450, 885, 546, 0x557799, 10) Until @error Send("{S up}") WEnd MouseClick("left", 190, 214) Do PixelSearch(431, 393, 431, 393, 0xFF0000, 2) Until Not @error ControlSend("Client", "", "", "{ENTER}") Call("Start") EndFunc Func DisplayToolTip($STAGE) ToolTip("Number of runs: " & $RUNCOUNTER & @CRLF & "Stage: " & $STAGE & @CRLF & "Press F1 to start" & @CRLF & "Press F2 to quit", @DesktopWidth, 0, "Bot", 0, 4) EndFunc Func Stop() WinSetOnTop("Client", "", 0) Exit EndFunc I just ran another test just now and the check ran fine, however around an hour ago the check didn't work. Just take a look at it and tell me what could be wrong. Also I realize my script is poorly coded, any tips on improving it? :] Edited December 16, 2011 by iRAWRRichard Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 16, 2011 Moderators Share Posted December 16, 2011 iRAWRRichard,Subway PQ Bot<Sigh>Unfortunately you appear not to have read the Forum Rules. Please read them now and then you will understand why you will get no more help and this thread will shortly be locked. 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...
Recommended Posts