The Case of the “Missing WindowTitle “

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

The Case of the “Missing WindowTitle “

Post by gchichester » Wed Mar 11, 2009 12:53 pm

After running a script that contains, 1-Dialog, 1-SetFocus, 1-WinWaitOpen , 2-Send commands and a few Waits.
I end up with a Window Title missing, Please see pics.
I tried using the WindowsHandle instead of the Title, it made no difference.
Has anyone seen this before, If so please let me know.

Regards
Gilc

Before
Image

After
Image

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Try isolating problem to a single command

Post by gdyvig » Wed Mar 11, 2009 2:36 pm

I have seen similar things happen to applications using other automation tools. I have seen other apps behave strangely if you set focus on them.

Try isolating the problem to the single command causing the problem by stepping through the code or running in trace mode.

Another way is to manually navigate to the window whose title disappears, do just the WinWaitOpen, if no problem do the SetFocus.

You may need to try another approach such as Image Recognition to get arround this problem.



Hope this helps,

Gale

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 11, 2009 3:25 pm

The app probably sets the window title internally depending on an action taken within the app itself. When an automation tool focuses the window all this processing is bypassed. Hence the title doesn't get set properly.

Similar to problems that can sometimes be seen with CloseWndow. CloseWindow sends a close event to the window and this may bypass the app's normal shut down logic. If the app has been coded so that the usual shutdown logic takes place in the File/Close event, then bypassing that and just telling it's window to close will bypass it's code.

So the solution might be that we need to send keystrokes to the app to mimic a user rather than focusing the window directly (or as well as). E.g. if that window is normally activated by selecting a particular menu option, then have the macro select that menu option (and if necessary then also use SetFocus).

At the end of the day only the developer of the application concerned could tell you the real reasons why stuff like this happens. But my guess is it's something like this. I hope what I've said makes sense to you.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Post by gchichester » Thu Mar 12, 2009 5:32 pm

Gale,
Thanks for your thoughts, I have done most of what you suggested and
was unable to isolate the culprit. I have included the code for review, if you see something please let me know. FYI - I'm using SetFocus elsewhere in my script without this issue.

Marcus,
Yes what you said does make sense, But why I''m I not having the same issue later in my script with other SetFocus commands? I tried leaving out the Setfocus and the script just stalls.
So what would best the best way to transition from a Dialog to a active program.


Thanks
Gilc

Code: Select all


Dialog closes and script continues

Wait>0.30
SetFocus>Open/New Shipment
Wait>0.30
CapsOff
/*
==========================================================================================
#2   		      Press Key ALT-2 - To Start New "Vessel Container" Shipment
==========================================================================================
*/
Press ALT
Send>2
Release Alt

/*
=========================================================================================
#3 							Move Cusor to "Vessel Container" in ListBox 
=========================================================================================
*/
Wait>SW
Press Shift
Press Tab
Wait>SW
Press Tab
Wait>SW
Release Shift
Wait>SW
Press Down * 2
Wait>vWait

/*
=========================================================================================
#4 							Pree Key  ALT-u to Select Auto Button
=========================================================================================
*/
Press ALT
Send>{"u"}
Release ALT
Wait>vWait

/*
=========================================================================================
#5 							Press Key  ALT-r to Select Create Button
=========================================================================================
*/
Press ALT
Send>{"r"}
Release ALT

/*
=========================================================================================
#6    Enter Booking Number - Wait for F12 - Press Tab, Enter to accept popup window
=========================================================================================
*/
Wait>vWait
Send>%BoLDialog.BkNum%
Wait>vWait
Press Tab
WaitWindowOpen>Export Manager
Wait>vWait
Press Enter
Include>C:\CP_Macros\NewEuropeJohn\2_CopyTemplate.scp

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Try a substitute for SetFocus

Post by gdyvig » Fri Mar 13, 2009 2:09 am

Let's rule out the SetFocus command.

You want to click the second tab.
If its position varies, use Image Recognition to locate it and do a mousemove to the coordinates found, then do a LClick. That should put focus on the window and open the tab at the same time.

If the window title still disappears, then the problem is downstream.

Another thing about SetFocus, if you still want to use it, make sure the visible window is open by doing this:
Let>WF_TYPE=2
Let>WW_TIMEOUT=10
WaitWindowOpen>Open/New Shipment
If>WW_RESULT=FALSE
exit>
endif
SetFocus,Open/New Shipment
..
..



Gale

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts