Diana (Cda) Posted October 12, 2009 Posted October 12, 2009 (edited) I'd like to finetune a script I have in terms of when it loops launching an application. If I started it up now, at 06:39:50 a.m. (as I type), how could we get AI to wait for it to do its thing until gets to 06:45:00, the nearest quarter hour? I imagine that after that, if we've set the script to loop every 15 minutes, it would then run the app every quarter hour on the quarter hour? Thanks! :oD Edited October 12, 2009 by Diana (Cda)
Moderators Melba23 Posted October 12, 2009 Moderators Posted October 12, 2009 Diana (Cda),Try something like this (I have used @SEC rather than @MIN to speed up the demo, but the principle is the same):HotKeySet("{ESC}", "On_Exit") $Last_Sec = "" While 1 While 1 Switch @SEC Case 00, 15, 30, 45 $Sec = @SEC ExitLoop EndSwitch Sleep(10) WEnd If $Last_Sec <> $Sec Then ConsoleWrite($Sec & @CRLF) $Last_Sec = $Sec EndIf WEnd Func On_Exit() Exit EndFuncM23 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
Diana (Cda) Posted October 12, 2009 Author Posted October 12, 2009 Hi! Something new again; I can't seem to "read" this code so I can't figure out 100% what it's doing <wry grin>. I left my launch code where it was and put this at the top. App wasn't launched. Okay. Then I did the old, "let's put my code in to these logical spots it might go", but that approach didn't work this time <g>. Script still sits in the systray, so of course, I'm doing something wrong ... again! <g>. p.s., will this _just_ delay the script x number of minutes (or seconds with this code here <lol>)? The "Case 00, 15, 30, 45" makes me wonder. The rest of my script actually already determines the loop interval, in case that is what this 00, 15, 30, 45 reference is. I just didn't know how to approach a delay to nearest quarter hour (or actually whatever other time delay needed).
Moderators Melba23 Posted October 12, 2009 Moderators Posted October 12, 2009 Diana (Cda),OK, let us go through the relevant sections of the code slowly - most of it was just there to show you how it worked (and I used seconds rather than minutes because it was faster! ).You start your script at a random time (say 06:39:50) and you want it to wait until the next quarter hour point. At the quarter hour point, the minutes read 00, 15, 30 or 45 - we must wait until this is the case, i.e. 06:45:00.So we set up a loop waiting until the @MIN macro returns one of the magic figures 00, 15, 30, 45:While 1 Switch @MIN Case 00, 15, 30, 45 ; Is it a quarter hour? ExitLoop ; Yes it is a quarter hour point so exit the loop and start running your script EndSwitch ; if we get here it is not quarter hour and so we continue the loop Sleep(10) ; to prevent CPU overheating in a tight loop WEnd ; Your script goes hereYou say that you have already coded the timing interval so this code has done its job. I hope this is clearer. Please ask again 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
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