Sign in to follow this  
Followers 0
Omatsei

Best of Both Worlds? Run vs. RunWait

11 posts in this topic

Is it possible to run a program, and wait only until the program is completely loaded, but not until the program closes? I'm checking to see if a window exists, and if not, start the program (Outlook in this case)... then a few lines later, go into the address book, but the script runs too fast and Outlook doesn't get a chance to fully open.

Share this post


Link to post
Share on other sites



Run()

WinWaitAcrive()

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Run()

WinWaitAcrive()

8)

I would use

Run ()

WinWait ()

which actually does wait only until the program is loaded, but not necesarily the front window

:whistle:


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

Having same problem i use sleep :whistle: But i think you can use some kinda wait for an object to exist if the object exists and then continue.. but havent found something usefull yet

Share this post


Link to post
Share on other sites

I would use

Run ()

WinWait ()

which actually does wait only until the program is loaded, but not necesarily the front window

:whistle:

I have found "at times" that is not a "long" enough wait to start sending info to a window

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I've tried WinWait and WinWaitActive... and neither of them seem to wait until Outlook gets done doing whatever it does when it starts. It starts, then immediately switches to the other program I started (Eudora, in this case).

I tried just telling it to sleep for 5 seconds, which works, but it just seems kinda inelegant.

Share this post


Link to post
Share on other sites

I've tried WinWait and WinWaitActive... and neither of them seem to wait until Outlook gets done doing whatever it does when it starts. It starts, then immediately switches to the other program I started (Eudora, in this case).

I tried just telling it to sleep for 5 seconds, which works, but it just seems kinda inelegant.

Sometimes inelegant is the only way.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I've tried WinWait and WinWaitActive... and neither of them seem to wait until Outlook gets done doing whatever it does when it starts. It starts, then immediately switches to the other program I started (Eudora, in this case).

I tried just telling it to sleep for 5 seconds, which works, but it just seems kinda inelegant.

if sleep for 5 seconds works... then it maybe the best approach

you could also try a loop with winwaitactive for Endura, but that may even be more inelegant.

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

I settled on using the sleep method. It's ugly, but it gets the job done (so far).

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I settled on using the sleep method. It's ugly, but it gets the job done (so far).

A more elegant approach would be to automate Outlook using COM instead of keystrokes and mouse clicks. You are more certain to get precisely the data you want without a lot of key & click trial and error. I can't begin to tell you how much time I wasted in the early days trying to time and judge keystrokes, wait on windows, and click on buttons - only to have to start over when some unforseen change in the application's behavior or data came up. COM allows you to work directly with just about every MS Office application minus OneNote, I believe.

It takes more effort to learn, but once you get it, you'll never go back to keystrokin'. It's well worth it.

I'm not sure if anyone has written a comprehensive library that covers what you're looking to do (i.e. fiddle with contacts), but I don't think your project would be difficult to script with COM.

Are you familiar with COM programming in other languages?

Here's a link to Microsoft's Outlook automation help front-end:

MS Outlook Automation

-S

Edited by Locodarwin

(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

The WaitForInputeIdle() function should accomplish that. It will require using DllCall() on OpenProcess(), CloseHandle() and the aforementioned WaitForInputIdle() function since AutoIt doesn't expose any of those.

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  
Followers 0