PennyDreadful Posted September 27, 2016 Posted September 27, 2016 I have this script I would like to know how can I run it in specific times in each day of the week for example on sunday runs at 6 am and 5 pm and each other day has specific times. And stay running all the week days no need to launch it each time. Anyone can help with it I tried many ways. expandcollapse popup; ---------------------------------------------------------------------------- ; Script Start - Add your code below here #NoTrayIcon #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <UpdownConstants.au3> #include <IE.au3> #include <date.au3> #include <string.au3> #include <ScreenCapture.au3> ;Your code HotKeySet("{ESC}", "Terminate") Func terminate() Exit 0 EndFunc Local $ShellObj = ObjCreate("Shell.Application") $ShellObj.ToggleDesktop() ShellExecute ("http://www.pme.gov.sa/Ar/alert/Pages/default.aspx") sleep (5000) Example1() Func Example1() Local $hBmp ; Capture full screen $hBmp = _ScreenCapture_Capture("") ; Save bitmap to file _ScreenCapture_SaveImage(@MyDocumentsDir & "\Weather Alerts.jpg", $hBmp) ShellExecute(@MyDocumentsDir & "\Weather Alerts.jpg") EndFunc ;==>Example Sleep (500) WinClose ( WinGetTitle("[ACTIVE]")) ProcessClose("iexplore.exe")
genius257 Posted September 27, 2016 Posted September 27, 2016 On 9/27/2016 at 6:01 AM, PennyDreadful said: Anyone can help with it I tried many ways. Expand Schedule a Task To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
PennyDreadful Posted September 27, 2016 Author Posted September 27, 2016 i tried that . i want prevent it from running during specific times using script not using Schedule a Task
orbs Posted September 27, 2016 Posted September 27, 2016 @PennyDreadful, welcome to AutoIt and to the forum. regardless if your code and configuration are the optimal for the task at hand, AutoIt provides you with time macros, so you can easily tell what the current time is. look at the help file: AutoIt \ Language Reference \ Macros. notice @YEAR, @MON, @MDAY, @HOUR, @MIN, @SEC and others. a simple If..Then check at convenient intervals should do the trick. Signature - my forum contributions: Reveal hidden contents UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
PennyDreadful Posted September 27, 2016 Author Posted September 27, 2016 @orbs I want to use the if...then command to compare the system time to a specified time so that the program can't run before or after that time. how can I do this using the macros you specified? Also how to define a macro to specific time? Any help will be appreciated. Thanks !!
orbs Posted September 27, 2016 Posted September 27, 2016 (edited) here is a simple example: While True If @WDAY = 1 And (@HOUR = '06' Or @HOUR = '17') And @MIN = '00' Then ; start on Sunday at 6:00 and 17:00 ; scheduled action here EndIf Sleep(1000 * 60) WEnd i trust the condition line is self-explanatory. what is important here is the Sleep() call. it is used for two purposes: 1) prevent your script from hogging the CPU while doing nothing 2) make sure the action does not run twice for the same scheduled time, in case it takes less than one minute to complete. Edited September 27, 2016 by orbs Signature - my forum contributions: Reveal hidden contents UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
PennyDreadful Posted September 28, 2016 Author Posted September 28, 2016 @orbs yes this works for me using the while function . thanks a lot
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