Jump to content
Sign in to follow this  
raoool

Help with loops

Recommended Posts

raoool

;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 :idiot:

;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")

Share this post


Link to post
Share on other sites
phillip123adams

;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)

I'm only guessing, but I think function DirGetSize should be used to determine if there are any files to be copied. If it returns 0, there are no files and the appropriate action should be taken. If it returns 1, do the FileCopy and acknowledgements.

Phillip

Share this post


Link to post
Share on other sites
JSThePatriot

I am not quite sure of your question. Try to put your code behind a [ code ]...[ / code ]. That way you can state your question without having it in the format of being inside the code.

Let me know if you can word it better.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.