Jump to content

Recommended Posts

Posted

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
Posted

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!

Posted (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 by Belini
Posted

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
Posted

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.
  :)

  • 5 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...