Jump to content
Sign in to follow this  
Cusem

Detect new window

Recommended Posts

Cusem

Hey guys,

I'm using a scripts that opens an x amount of windows.

I want the script to halt until the new window is opened and identified by the script.

Right now I'm using the following code:

_OpenNewWindow()

         ;now I want the script to wait until a new window is opened (with a 3 second timeout)
Local $old = WinList("WindowCommonString", "")
Local $new = ""
Local $timer = TimerInit()
Do
     Sleep(50)
     $new = WinList("WindowCommonString", "")
Until $old[0][0] <> $new[0][0] OR TimerDiff($timer) > 3000


         ;detecting timeout
If TimerDiff($timer) > 3000 Then _TimeOutMessage()

         ;now I want to identify the new window
Local $found = 0
Local $NewWindow = ""
For $a = 1 to $new[0][0]
     For $b = 1 to $old[0][0]
          If $new[$a][0] = $old[$b][0] Then $found = $found + 1
     Next
     If $found = 0 Then 
          $NewWindow = $new[$a][0]
          $a = $old[0][0];To exit the For..Next loop
     Endif
Next

This works, but I was wondering if there is an easier way to get the name of the new window.

Share this post


Link to post
Share on other sites
weaponx

Looks similar to something I wrote to detect any new processes:

#414954

#443881

Should be easy to modify.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.