Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Basically, I have a script that does some processing, opens Microsoft Outlook, creates a new mail, populates it, sends it and continues on. Due to the slowness of my PC, the mail takes some time to close, so I do a winexist and winwaitclose before continuing on. This is where my problem manifests itself. winexist always seems to return true and winwaitclose simply waits for ever, even though the window has closed.
I have created a short script to duplicate and demonstrate the problem. The script simply opens up a new mail, waits a few seconds, closes the mail then checks to make sure the mail is closed before continuing. I have tried a number of variations to check for the existence of the mail closure, and none of them ever detect the window closing.
allwins = WinItemize( ) OutlookInbox = AskItemList("Windows", allwins, @TAB, @unsorted, @single) winactivate(OutlookInbox) sendkeysto(OutlookInbox, "^n") timedelay(1) allwins = WinItemize( ) NewMail = AskItemList("Windows", allwins, @TAB, @unsorted, @single) ; do some other stuff and usually sent the mail here ; for this example I will simply shut the new mail windows timedelay(2) winactivate(NewMail) sendkeysto(Newmail, "!{F4}") ; I have tried tried this if winexist(Newmail) == @true then winwaitclose(NewMail) ; I have also tried this while winexist(NewMail) == @true yield() end while I have a problem Iied this before giving up while @true yield() if winexist(NewMail) == @true then timedelay(1) else break endif end while ; this message simply never appears message("Done","You may proceed")Any suggestions would be much appreciated.
The WinState function can tell you the current state of the window. It may be flopping between Normal and Hidden.
I have changed my code now to open the NewMail, do a winidget, then close it. If winexist(NewMailID) returns true and winstate(NewmailID) returns @hidden, then I simply assume it's in the hidden state and continue on.
Works great now.
Article ID: W16267
File Created: 2004:03:30:15:43:42
Last Updated: 2004:03:30:15:43:42