;Need script to retrieve and process two files on an hourly basis using a
;specific GUI, The GUI requires user click a button, wait until the file
;is downloaded, then click a series of buttons/menus to acknowledge download.
;Before running the acknowledge, need to make a copy of it.
;
;The script (excerpts below) works if there are files to download. But if
;there are no files to download, things hang at the acknowledge process
;(required series of clicks in the GUI done with mouse movements)
;
;Each retrieve is to get exactly two files each hour (launched in scheduler).
;Somtimes there are no files to retrieve, sometimes just one; but the only
;indication from the GUI either way is a change on the button text. If there
;are files available, text changes from 'Get File' to 'Cancel Download'.
;It can take up to three seconds for the button to change so we need to wait
;that long before assuming there are no files, then move on (or not) to the
;'acknowledge' process
Dim $filecount
Opt( "MouseCoordMode", 0)
Opt( "WinTitleMatchMode", 3)
Opt( "WinTextMatchMode", 2)
Opt( "WinSearchChildren", 0)
Opt( "TrayIconDebug", 1)
;stuff here to login and launch the downloader
;real basic approach to getting two files (duh)
For $filecount = 1 to 2
;This count changes regularly (need quick script edit to accomodate)
;
;Downloads Jobs
WinWait( "Vendor Downloader", "")
If Not WinActive( "Vendor Downloader", "") Then WinActivate("Vendor Downloader", "")
WinWaitActive("Vendor Downloader", "")
;
;The GUI requires click of button2 to initiate a download
;If there are no files, nothing happens. If there are files, the
;button text changes to 'Cancel Download' (we hope within three seconds
;then back to 'Get' when the download is complete. The copy and acknowledge
;steps must take place before we can get the next file and the acknowledge
; process cannot begin until the file is completely downloaded.
;
ControlClick ( "Vendor Downloader", "", "Button2")
WinWait( "Vendor Downloader", "&Cancel download", 30)
WinWait("Vendor Downloader","&Get")
Sleep(3000)
FileCopy ( "C:\Program Files\GetIt\*.*", "c:\archive\", 0 )
;so we watch the button, wait until it changes to Cancel then back to
;get before proceeding to the acknowledge
;NEED SMARTER LOOP READING THIS BUTTON
;given the limitations described
;acknowledge
WinWait("Vendor Downloader","")
If Not WinActive("Vendor Downloader","") Then WinActivate("Vendor Downloader","")
WinWaitActive("Vendor Downloader","")
MouseMove(45,201)
MouseDown("right")
MouseUp("right")
Sleep(500)
MouseMove(121,209)
MouseDown("left")
MouseUp("left")
Sleep(3000)
MouseMove(151,108)
MouseDown("left")
MouseUp("left")
Sleep(1000)
MouseMove(102,203)
MouseDown("right")
MouseUp("right")
Sleep(1000)
MouseMove(132,237)
MouseDown("left")
MouseUp("left")
Sleep(1000)
If Not WinActive("Please confirm!","") Then WinActivate("Please confirm!","")
WinWaitActive("Please confirm!","")
MouseMove(94,89)
MouseDown("left")
MouseUp("left")
Sleep(3000)
Next
;to go back and get the next job, but...
;Close and do stuff with the files
WinClose("Vendor Downloader", "")
Sleep (5000)
Runwait ("C:\some other process")