Jump to content

Winwait


daashag
 Share

Recommended Posts

I am trying to automate a backup. What I want to to is run the backup and then when it is finished close the application. It works up to the part when the backup starts then instead of waiting it for the backup to finish it just closed the application. I've tried using both Winwait and Sleep. The code in question is between Start Backup and Close window. Any help would be appreciated. Thanks

Run("C:\Program Files\Exact Software\bin\e4shell.exe")

WinWait("Open company","")

If Not WinActive("Open company","") Then WinActivate("Open company","")

WinWaitActive("Open company","")

Send("{TAB}{TAB}{ENTER}")

WinWait("Exact Globe 2003 Enterprise","")

If Not WinActive("Exact Globe 2003 Enterprise","") Then WinActivate("Exact Globe 2003 Enterprise","")

WinWaitActive("Exact Globe 2003 Enterprise","")

Send("{ALTDOWN}{ALTUP}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")

WinWait("Backup/Restore/Copy","")

If Not WinActive("Backup/Restore/Copy","") Then WinActivate("Backup/Restore/Copy","")

WinWaitActive("Backup/Restore/Copy","")

Send("{TAB}{TAB}{ENTER}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}")

WinWait("Create backup","")

If Not WinActive("Create backup","") Then WinActivate("Create backup","")

WinWaitActive("Create backup","")

Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}");Start backup

WinWait("Create backup","")

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

WinWait("Create backup","")

If Not WinActive("Create backup","") Then WinActivate("Create backup","")

WinWaitActive("Create backup","")

Send("{TAB}{ENTER}");Close Window

Edited by daashag
Link to comment
Share on other sites

just a quick over-view

these lines

WinWaitActive("Create backup","")

Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}");Start backup

WinWait("Create backup","")

...

Send("{TAB}{ENTER}");Close Window

its already active and you are closing it...

are you waiting for a "complete" window???

or can you check for text that changes??

8)

NEWHeader1.png

Link to comment
Share on other sites

WinWait

--------------------------------------------------------------------------------

Pauses execution of the script until the requested window exists.

Sounds like WinWaitNotActive is what you are looking for?

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

just a quick over-view

these lines

WinWaitActive("Create backup","")

Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}");Start backup

WinWait("Create backup","")

...

Send("{TAB}{ENTER}");Close Window

its already active and you are closing it...

are you waiting for a "complete" window???

or can you check for text that changes??

8)

Thanks for the quick reply. In between the Start backup and close backup takes about 20 minutes showing a progress bar. Once the back up is finished the Create backup window changes to have a a close button instead of start and cancel buttons. I don't want the Send for Close Window to be executed untill the backup is finished and the close button appears. I think an IF statement looking for the text to change might work. Just now sure how to do that. Thanks again Edited by daashag
Link to comment
Share on other sites

You should add text to the WinWait for clarity. The script may find the window a second time before it actually closes.

Appreciate your reply. Sounds great. I am a complete newby at this. Where can I find some examples showing me how to autoit. Also is it possible to just execute a button on a window rather that tabbing to get to the button. Not asking for anyone to do this for me. But I have searched the site and I can't seem to find any documentation or examples on how to do this. Thanks again
Link to comment
Share on other sites

Appreciate your reply. Sounds great. I am a complete newby at this. Where can I find some examples showing me how to autoit. Also is it possible to just execute a button on a window rather that tabbing to get to the button. Not asking for anyone to do this for me. But I have searched the site and I can't seem to find any documentation or examples on how to do this. Thanks again

Check the helpfile for Send(), ControlSend(), ControlCommand(), MouseClick(), ControlClick(), and take your pick ;)

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Even though this is pretty basic for most of you I thought I would post my solution. Maybe someone can benefit. I completely rewrote my code to use controls and PixelGetColor function.

;Start Backup
WinWaitActive("Create backup", "")
Send("!i")

;Get name of backupfile
$bkupdst = ControlGetText("Create backup", "", "17228084")
 ;MsgBox(0, "Example", "My variable is " & $bkupdst)

;Wait for backup to finish
Do
    WinWaitNotActive("Create Backup", "")
Until PixelGetColor(1108, 700) = 16711680 

;Close Backup
WinActivate("Create backup", "")
ControlSend("Create backup","&Cancel",3,"!c","")

;Close Exact Main screen
WinWaitActive("Exact Globe 2003 Enterprise", "")
Send("!f")
WinWaitActive("Exact Globe 2003 Enterprise", "")
Send("l")
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...