Sign in to follow this  
Followers 0
CygnusX1

Waiting Issue

10 posts in this topic

Hello,

I've run into a problem I can not figure out.

I work on a 3D modeling product. I'm doing some testing with a bunch of models. So I'm opening a model, running a test, closing the model, repeat for a directory full of models.

The problem is some models take longer to open. When AutoIt "clicks" on the Open button on the Open dialog box the dialog box is still visible on the screen and AutoIt believes my program is active and ready to go...when actually it's still trying to load the model. I've tried WinWaitNotActive on the Open dialog box that didn't work because as soon as the Open button is click focus goes to the product even though the Open dialog box is still visible. I'm tried WinWaitActive, WinWait, WinGetState, Do..Until, Loops....

I can't seem to figure out how to make AutoIt wait until the model is actually loaded and the product is active and ready to take more commands.

Totally stumped!

Any and all help welcome.

Thank you.

Brad


Cygnus

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Just curious for more information about the modeling program you are using. Is it like many programs where the title of the main window will change based on the file loaded? For example:

Microsoft Word starts with this title - "Document1 - Microsoft Word" and then changes to "My_Document_Name - Microsoft Word"

If your program does do that, you can WinWaitActive the new title (ex. $DocName & "- Microsoft Word")

Typically, those titles don't change until the file is loaded.

-Fett

Edited by fett8802

[sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hey Fett,

Great question, Yes the program does just exactly what you said (DocName & "- Program Name")

I've tried what you suggested....

WinWaitActive("Model" & " - Program Name")
ConsoleWrite("Active" & @LF) ;just to see when AutoIt thinks the program is ready

As soon as Open is click the Title of the Program is correct, it's what I'm waiting for but the program isn't ready to be acted upon as it's still loading the file.

All similar attempts like this kind of logic have failed.

Thanks for replying.

Brad

Edited by CygnusX1

Cygnus

Share this post


Link to post
Share on other sites

Well, it's certainly not the best solution, but if you could figure up the time it takes to open the largest, slowest file, you could just put a Sleep timer there for that time. It'll slow the whole process down, but at least then it will be self-sufficient.


[sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub]

Share this post


Link to post
Share on other sites

Maybe search for a color that changes...

_checkload()

func _checkload()
$COLORdec = pixelgetcolor (613, 424)
$COLORhex = hex($COLORdec, 6)
msgbox (0, '' , $colorhex)
If $Colorhex = "F7F7F7" Then
    msgbox (0, '' , 'stillwhite')
    _checkload()
Else
    msgbox (0, '' , 'loaded')
    EndIf
EndFunc

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Oh I've thought about doing such a thing with Sleep but some models open very very quickly and my script would be waiting needlessly.

Is there a way to watch Task Manager -> Applications (Task/Status)?

I see the program will display 'Not Responding' until the model is loaded and then it's ready to go.

I see in help there are a lot of Process Functions but nothing for Task -> Status.

Brad


Cygnus

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I like iamthesky's suggestion. Have it monitor a single pixel in the Open Dialogue window (you'll have to make sure the open dialogue window is located in the same place every time) where below that window in the main window is a different color. Then, have AutoIt wait until the color has changed from the open dialogue box color to the main window color. (Probably from gray to white). Try this for an example:

Run("Notepad.exe")
WinWaitActive("Untitled - Notepad")
WinMove("Untitled - Notepad","",50,50,700,700)
MsgBox(0,"","This will now open the Open Dialogue box and the mouse will move to the pixel to be monitored.")
Send("^o")

WinActivate("Open")
$Color = Hex(PixelGetColor(556,531),6)
MouseMove(556,531)
MsgBox(0,"","The current color of this pixel (in 6 digit hex) is: " & $Color)

Do
    $Color = Hex(PixelGetColor(556,531),6)
    Sleep(10)
Until $Color = "FFFFFF" ;Waits until the pixel changes to white

Send("And now the program continues on!")

-Fett

Edited by fett8802

[sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub]

Share this post


Link to post
Share on other sites

Hey Fett and iamtheky,

That was a brilliant and simple solution!

Thank you so much!

Brad


Cygnus

Share this post


Link to post
Share on other sites

Glad it worked out! :graduated:


[sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub]

Share this post


Link to post
Share on other sites

Definitely a handy little work around.

I only wished I had asked the question earlier. It would have saved me a couple of hours of frustration.


Cygnus

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