kawliga751 Posted June 7, 2017 Posted June 7, 2017 I'm new to Auotit but I have built a simple script that "runs" a different "batch" file based on certain days of the workweek. The script works now, but I was wanting to eliminate the need for a manual date entry. For example "First Batch' needs to run every Tuesday thru Thursday however "Second Batch" needs to run only on Friday and "Third Batch" needs to run only on Monday. In addition the 1st batch file runs on Tuesday, say 06/06 (the "FW" section) but then needs to actually report (the F4 date) the next weekday so this Batch actually needs 2 dates verified. What I'm trying to do is when the script is initiated it gets the date, verifies if and which weekday it is and in turn goes to and runs the appropriate "Batch' file. I've found ways to verify weekdays but can't find anything to do all of the above. Any help is MUCH appreciated. ;P10 ShellExecute("C:\Program Files (x86)\Ericom Software\PowerTerm Enterprise\Sessions\mir00p10.PTS") WinWait('(A) Soutwest P10 : PowerTerm Pro Enterprise Suite') WinActivate('(A) Soutwest P10 : PowerTerm Pro Enterprise Suite') Send('$Login) Sleep(3000) Send('{Enter}') Sleep(3000) Send($Password) Send('{Enter}') Sleep(3000) ; ****First Batch file run Send('Batch') Sleep(3000) Send('{Enter}') Send('FW') Send('{Enter}') Send('{DOWN}') Send($Date) Send('{Enter}') Send('{Enter}') Send($Date) Send('{F9}') Send('Y') Sleep(3000) Send('{Enter}') Send('{F4}') Send('Y') Sleep(3000) Send('{Enter}') Send($Date) Send('{Enter}') Send('0620') Send('{Enter}') SEND('{!}SW0410PM.FWR') Send('{Enter}') Sleep(3000) Send('Y') Send('{Enter}') Sleep(3000) Send('{F9}') Sleep(3000) ; ****Second Batch file run Send('Batch') Sleep(3000) Send('{Enter}') Send('FW') Send('{Enter}') Send('{DOWN}') Send($Date) Send('{Enter}') Send('{Enter}') Send($Date) Send('{F9}') Send('Y') Sleep(3000) Send('{Enter}') Send('{F4}') Send('Y') Sleep(3000) Send('{Enter}') Send($Date) Send('{Enter}') Send('0620') Send('{Enter}') SEND('{!}SO0411AM.FWR') Send('{Enter}') Sleep(3000) Send('Y') Send('{Enter}') Sleep(3000) Send('{F9}') Sleep(3000) ; ****Third Batch file run Send('Batch') Sleep(3000) Send('{Enter}') Send('FW') Send('{Enter}') Send('{DOWN}') Send($Date) Send('{Enter}') Send('{Enter}') Send($Date) Send('{F9}') Send('Y') Sleep(3000) Send('{Enter}') Send('{F4}') Send('Y') Sleep(3000) Send('{Enter}') Send($Date) Send('{Enter}') Send('0620') Send('{Enter}') SEND('{!}SW0411AM.LOA') Send('{Enter}') Sleep(3000) Send('Y') Send('{Enter}') Sleep(3000) Send('{F9}') Sleep(3000) Send('EXIT')
Moderators JLogan3o13 Posted June 7, 2017 Moderators Posted June 7, 2017 You could simply use the @WDAY macro in a switch, like so: Switch @WDAY Case 2 To 4 ;Call this Batch File Case 5 ;Call This Batch File Case Else ;Do Something Else EndSwitch "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Belini Posted June 7, 2017 Posted June 7, 2017 (edited) You can use @Wday macro to know the day of the week! Switch @WDAY Case 1 MsgBox(4096, "Day of the week", "Today is sunday", 3) Case 2 MsgBox(4096, "Day of the week", "Today is Monday", 3) Case 3 MsgBox(4096, "Day of the week", "Today is Tuesday", 3) Case 4 MsgBox(4096, "Day of the week", "Today is Wednesday", 3) Case 5 MsgBox(4096, "Day of the week", "Today is Thursday", 3) Case 6 MsgBox(4096, "Day of the week", "Today is Friday", 3) Case 6 MsgBox(4096, "Day of the week", "Today is Saturday", 3) EndSwitch EDITED: @JLogan3o13 we posted together! Edited June 7, 2017 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
kawliga751 Posted June 7, 2017 Author Posted June 7, 2017 this looks very useful but, how would I make this call a specific "line" in the script? As in how would : Switch @WDAY Case 2 To 4 then go to ; ****First Batch file run $Date = InputBox("Date","Enter the Date To Run the Report","Date Here MMDDYYYY",'M8') Send('Batch') Sleep(3000) Send('{Enter}') Thanks again!
Developers Jos Posted June 7, 2017 Developers Posted June 7, 2017 Forget about GoTo and Just put the lines you want to perform under the Case statement and you're ready to go. Another option is to put the code in separate Func statements and you run that Func from the Case statement. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Bert Posted June 8, 2017 Posted June 8, 2017 one other suggestion - you may want to look at "ControlSend" instead of "send". The reason is Send only sends keystrokes to where ever the carrot is. If anything changes, your script breaks and all sorts of trouble can happen. ControlSend sends directly to the control in question so it makes things MUCH more stable. The Vollatran project My blog: http://www.vollysinterestingshit.com/
ashraful089 Posted June 29, 2022 Posted June 29, 2022 @JLogan3o13 How to get time of a day, in hour and minute?? is the below way correct? If @Hour = 12 And @Min = 20 Then Exit Else Sleep(250)
Developers Jos Posted June 29, 2022 Developers Posted June 29, 2022 18 minutes ago, ashraful089 said: is the below way correct? You could simply test that and find out yourself without asking ... right? ashraful089 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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