Jump to content

Detect new window


Recommended Posts

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...