Jump to content
Macro Express Forums

Wait for blank window title


SteveR

Recommended Posts

I have a problem with an application where one of the windows I need to work with does not have a title. I was assuming I could not use the wait for window commands or if window title commands, but now it occurs to me perhaps I can use them, just leave the text blank. Is this possible? I will have an opportunity to try it Monday, but thought I would post in case anyone can provide me with tips.

Link to comment
Share on other sites

If Alan's idea doesn't work, pick out one or a few unique color spots on the screen you are waiting for (or just uniquely different from the screen you are starting from), then write a loop to check pixel colors in those spots until they all match. For example, the code below is checking a single location waiting for a signon screen to appear so i can check whether I have won the lottery. The macro makes it quick and easy to get my weekly bad news. Note the 100ms delay built into the loop -- one tenth of a second. You don't want the loop to run as fast as the processor will go -- the delays leave some CPU power for the browser and operating system. :)

 

//
// Delay briefly for page to finish loading -- based on yellow "Submit" button appearing
Mouse Move Screen 519, 553
Repeat Start (Repeat 3000 times)
Get Pixel: Under Mouse into %N1%
If Variable %N1% = 52479
Repeat Exit
End If
Delay 100 Milliseconds
Repeat End
//

Link to comment
Share on other sites

I was not able to get Alan's suggestion to work. However rberq's idea of looking at pixel color I was able to make work. This was a big help as the timing for this particular screen to come up and go away after working with it varies considerably. Now I think my macro will work reliably with this dialog. Thanks

Link to comment
Share on other sites

Glad you got it to work, and thanks for the feedback. Note that the Repeat loop will eventually end even if the expected color doesn't appear. To be safer in a production environment, I would add a few more error-checking lines after the Repeat loop. See highlighted lines below. I didn't bother in my lottery checker macro because the prize is just a measly million dollars, so not worth getting excited about. :)

 

Seriously, though, color checking can be extremely useful. I have also used it for locating a button I want to click on, when I know approximately where it is on a page but not exactly. For example, in a Repeat loop, scan down the page looking for the button color by setting a starting location then incrementing the "y" coordinate of Get Pixel each time through the loop. Don't use the Under Mouse option of Get Pixel for such a scan, because then you have to move the mouse each time through and the macro will run MUCH slower.

 

//
// Delay briefly for page to finish loading -- based on yellow "Submit" button appearing
Mouse Move Screen 519, 553
Repeat Start (Repeat 3000 times)
Get Pixel: Under Mouse into %N1%
If Variable %N1% = 52479
Repeat Exit
End If
Delay 100 Milliseconds
Repeat End
If Variable %N1% = 52479
Else
Text Box Display: Error - expected window did not appear
Macro Stop
End If

//

Link to comment
Share on other sites

Many of my Macro Express scripts rely on "pixel sniffing" to make inferences about the user interface. There are many ways to improve the reliability of these inherently unreliable scripts, e.g.,:

 

Let's say you are checking vertically for a colour 123456 inside a window. Let's say you start searching 100 pixels from the top left edge of the window. You can set the maximum number of pixels to check this way:

 

%N1% = height of current window // Maximum number of pixels to check

%x% = 100 // Starting x coordinate

%y% = 0 // Topmost y coordinate to check

 

Repeat %N1% times

%z% = pixel colour at %x%, %y% relative to window

If %z% = 123456

// Done! Target found, so click on it

Move Mouse to (%x%, %y%)

Mouse Left Click

Macro Stop

End If

%y% = %y% + 1 // Increment y value

End Repeat

MsgBox "Error! Pixel not found!"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...