SteveR Posted March 26, 2016 Report Share Posted March 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
acantor Posted March 26, 2016 Report Share Posted March 26, 2016 Try something like this... Text Box Display: StartVariable Set String %T1% to ""Wait for Window Title: %T1%Text Box Display: End Quote Link to comment Share on other sites More sharing options...
rberq Posted March 26, 2016 Report Share Posted March 26, 2016 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 appearingMouse Move Screen 519, 553Repeat Start (Repeat 3000 times) Get Pixel: Under Mouse into %N1% If Variable %N1% = 52479 Repeat Exit End If Delay 100 MillisecondsRepeat End// Quote Link to comment Share on other sites More sharing options...
SteveR Posted March 29, 2016 Author Report Share Posted March 29, 2016 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 Quote Link to comment Share on other sites More sharing options...
rberq Posted March 29, 2016 Report Share Posted March 29, 2016 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 appearingMouse Move Screen 519, 553Repeat Start (Repeat 3000 times) Get Pixel: Under Mouse into %N1% If Variable %N1% = 52479 Repeat Exit End If Delay 100 MillisecondsRepeat EndIf Variable %N1% = 52479Else Text Box Display: Error - expected window did not appear Macro StopEnd If// Quote Link to comment Share on other sites More sharing options...
acantor Posted March 30, 2016 Report Share Posted March 30, 2016 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!" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.