Sign in to follow this  
Followers 0
DanRiek

Wait for Window

6 posts in this topic

I would like to create a procedure that runs behind the scenes that waits for a window to open then clicks a button on that window. The code is listed below and does work fine. The problem is that Autoit will use 5% CPU load waiting for the window. Is there a better way?

While 1 = 1

WinWaitActive ("Test - Window")

MouseClick ( "left", 487, 393)

Wend

Share this post


Link to post
Share on other sites

Stay with me here, because this gets pretty complicated and in-depth.

While 1 = 1

WinWaitActive ("Test - Window")

MouseClick ( "left", 487, 393)

sleep(10)

Wend

Share this post


Link to post
Share on other sites

This is the line that is causing the CPU utilization:

WinWaitActive ("Test - Window")

It is waiting for the window to appear. It is during this time that the procedure has a higher amount if CPU utilization. The window may not appear for hours but when it does the procedure run through and then begins to wait again for the window which may take hours to apear. Do you know of a better way of doing this code or am I in need of a different program? Thanks

Share this post


Link to post
Share on other sites

Try this one.

While 1
If WinActive("Test - Window") Then
    MouseClick ( "left", 487, 393)
    Sleep(100) ; adjust to how quick you want it to click all the while its active
Else
    Sleep(100)
EndIf
Wend

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Thank you that does help.

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