Setting Focus and Getting Window Title

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Setting Focus and Getting Window Title

Post by kpassaur » Tue Jun 12, 2007 8:31 pm

I am working on trying to capture the text contained in the title bar of a window.

I wrote this simple script to display it as it sets focus on the parent window then the child window.

In Access I notice that Access the Names of the Windows are listed like this



66550 - OTable "email addresses : Table"
262808 - OForm "Form Test : Form"

How would I capture the one that is on top and get all of the text in the line? Anyone know?



MDL>Click on the Window that contains the value to be used as a Commandline

Press Alt
Press Tab
Release ALT
Wait>.5
GetActiveWindow>parent,X,Y
//Let>GAW_TYPE=1
GetActiveWindow>Child,X,Y
//Let>GAW_TYPE=0
//MDL>%parent%%CRLF%%Child%
Ask>%parent%%CRLF%%Child%%CRLF%Does one of the lines contain the data that needs to be a Commandline,gotit
If>%gotit%=YES,Startparse
Ask>Try entering manually?,ta
If>%ta%=YES,Begin,EOF
Label>Begin
Input>parent,Enter Parent Window,
Input>Child,Enter Child Window.
//Let>GAW_TYPE=0
SetFocus>%parent%*
GetActiveWindow>parent,X,Y
//Let>GAW_TYPE=1
SetFocus>%Child%*
GetActiveWindow>Child,X,Y
//Let>GAW_TYPE=0
Ask>%parent%%CRLF%%Child%%CRLF%Does one of the lines contain the data that needs to be a Commandline,gotit
If>%gotit%=YES,Startparse
MDL>Difficulty in Capturing Window Name - Will not Exit
Goto>EOF

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Fri Jun 15, 2007 3:05 am

Try using the GetControlText> command.

GetControlText>WindowTitle,ClassName,Instance,Result

where ClassName would be replaced by OTable

GCT>WindowTitleGoesHere,OTable,1,HereIsYourAnswer

where 1 means it is the first occurrence of such an object on the desktop.

With this window open, View System Windows ( I believe on the tools menu) will show you the Classes, just count all instances of OTable (probably just the one) until you get to the one in which you are interested...that's your "instance"...

good luck...

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Class and instance

Post by kpassaur » Fri Jun 15, 2007 8:02 am

Gave it a try, and it returned ##NOSUCHWINDOW##,
I copied the text from the view system windows tool so it would be an exact match.

Any other ideas?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Fri Jun 15, 2007 1:18 pm

Any chance I can get a look at this app? If not, how about an on-line session so you can show me what you are dealing with?

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Getting Widow title

Post by kpassaur » Fri Jun 15, 2007 2:03 pm

Paul,

I am away for the next couple of weeks without much internet access. The program though is Microsoft Access.

Thanks for looking into this

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