How to find class, handle of Window or Dialog

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
qurious
Newbie
Posts: 4
Joined: Tue Apr 12, 2011 12:25 am

How to find class, handle of Window or Dialog

Post by qurious » Thu Apr 14, 2011 5:11 am

Hi,

When I use GetControlText or PushButton etc... ,

It is hard to find the correct ClassName or Handle.

In most case, GetControlText works well.

Sometimes, GetControlText doesn't work because I don't know the correct ClassName or Handle.

I tried to use "View System Windows", but it is difficult to me.

I am ready to learn.

Please let me know where can I learn the skill to find ClassName or Handle.

Thank you.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Apr 14, 2011 1:27 pm

View System Windows is a great tool. Its only drawback is that it displays everything and so its sometimes difficult to find exactly what you're looking for.

Try the script I posted HERE. It's primary drawback is that it does not display everything, It only gets a specific level of objects. But it can make getting to your specific window in View System Windows easier since you can search by window handle and get to the location faster.

qurious
Newbie
Posts: 4
Joined: Tue Apr 12, 2011 12:25 am

Post by qurious » Fri Apr 15, 2011 4:25 pm

Thank you for your reply.

However I can't still solve my problem.

Here is my problem.

Image

In Total Commander,

I want to get the text and press the correct button.

However I can't find the className or Handle to point number 2.

Please slove this problem.

Thank you.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sat Apr 16, 2011 1:04 pm

You can accomplish the same with GetTextAtPoint.

Give this script a try, it should click the correct button.

Code: Select all

Label>Loop
Wait>.1

//Visible Windows Only
Let>WF_TYPE=2

//Check if nag screen is open
IfWindowOpen>Total Commander

//Move cursor over the the #2 button
MouseOver>Total Commander,&2

//Get Cursor position
GetCursorPos>X,Y

//Subtract 32 from Y coordinates
//This will give us the position
//of the number of the button to press.
//Adjus it if the coordinates are not in
//the center of the number.
Let>Y=Y-32

//Used for testing purpose to make sure the
//coordinates are correct.
MouseMove>X,Y

//Retrieve the number at the set X,Y coordinates
GetTextAtPoint>X,Y,TheNumber,nChar
//MessageModal>Please press button Nr. %TheNumber% to start the program

//Lets press the correct button
IF>TheNumber=1
//Press button 1
MouseOver>Total Commander,&1
wait>0.5
LClick
WaitWindowClosed>Total Commander
Endif
IF>TheNumber=2
//Press button 2
MouseOver>Total Commander,&2
wait>0.5
LClick
WaitWindowClosed>Total Commander
Endif
IF>TheNumber=3
//Press button 3
MouseOver>Total Commander,&3
wait>0.5
LClick
WaitWindowClosed>Total Commander
Endif

Endif
//All Windows (Default)
Let>WF_TYPE=1

Goto>Loop


qurious
Newbie
Posts: 4
Joined: Tue Apr 12, 2011 12:25 am

Post by qurious » Sun Apr 17, 2011 5:54 am

Rain's code works perfect!

GetTextAtPoint is great solution.

This code can slove my problem.

Thank you!

However I still want to know the skill to find ClassName or Handle.

Please let me know.

qurious
Newbie
Posts: 4
Joined: Tue Apr 12, 2011 12:25 am

Post by qurious » Sun Apr 17, 2011 12:59 pm

I found the code for GetControlText.

Thanks to JRL, Rain.

Code: Select all

wait>0.5
GetControlText>Total Commander,TPanel,2,strText

IF>strText=1
    //Press button 1
    MouseOver>Total Commander,&1
    wait>0.5
    LClick
Endif

IF>strText=2
    //Press button 2
    MouseOver>Total Commander,&2
    wait>0.5
    LClick
Endif

IF>strText=3
    //Press button 3
    MouseOver>Total Commander,&3
    wait>0.5
    LClick
Endif

View System Windows

Image

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