Jump to content

Unable to Access WPF Window Title by Class


Go to solution Solved by mLipok,

Recommended Posts

Posted

Hi,

I am trying to access WPF window title by its class id which i found from Au3Info.exe but it retunrs 0 but same method works for most of the winform controls. I suspect special characters (Square Bracket "[]") appears in class id of WPF windows is causing for failiure of accessing its titile. can anyboyd help me on this?

Working

Local $winTitle = WinGetTitle("[CLASS:Notepad]")
MsgBox(1,"Test",$winTitle)

Not Working

Local $winTitle = WinGetTitle("[CLASS:HwndWrapper[MainWindow.exe;;76a6129f-c1f4-4d90-b109-c51279623bc6]]")
MsgBox(1,"AutoIt",$winTitle)

Thank in Advance

Posted

Hi mrflibblehat find required details below

au3

MsgBox(1,"AutoIT3",WinGetTitle("[CLASS:HwndWrapper[WpfApplication9.vshost.exe;;53428c5d-555b-4756-8d2a-d0cc92208132]]"))

Summary

>>>> Window <<<<
Title:    MainWindow
Class:    HwndWrapper[WpfApplication9.vshost.exe;;53428c5d-555b-4756-8d2a-d0cc92208132]
Position:    132, 174
Size:    525, 350
Style:    0x16CF0000
ExStyle:    0x00040100
Handle:    0x00030724

>>>> Control <<<<
Class:    
Instance:    
ClassnameNN:    
Name:    
Advanced (Class):    
ID:    
Text:    
Position:    
Size:    
ControlClick Coords:    
Style:    
ExStyle:    
Handle:    

>>>> Mouse <<<<
Position:    508, 198
Cursor ID:    0
Color:    0x82A9E9

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<


>>>> Hidden Text <<<<
 

Posted (edited)

try this:

Local $winTitle = WinGetTitle("[REGEXPCLASS:HwndWrapper\[MainWindow\.exe\;\;76a6129f-c1f4-4d90-b109-c51279623bc6\]]")
MsgBox(1,"AutoIt",$winTitle)

EDIT:

or simply

Local $winTitle = WinGetTitle("[REGEXPCLASS:(?i)HwndWrapper.*MainWindow.exe.*]")
MsgBox(1,"AutoIt",$winTitle)

EDIT:

But the question which gave @JohnOne is realy intresting.

Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 10/7/2013 at 11:04 AM, JohnOne said:

 

What does this give?

#include <WinAPI.au3>

$hwnd = WinGetHandle("MainWindow")
MsgBox(0,0,_WinAPI_GetClassName($hwnd))

Thanks for reply.

This script simply showing CLASS ID as shown by au3Info tool

i tried to use this method inside WinGetTitle(_WinAPI_GetClassName($hwnd)) function but it returns 0

Edited by Sethu1984
Posted (edited)
  On 10/7/2013 at 11:07 AM, mlipok said:

try this:

Local $winTitle = WinGetTitle("[REGEXPCLASS:HwndWrapper\[MainWindow\.exe\;\;76a6129f-c1f4-4d90-b109-c51279623bc6\]]")
MsgBox(1,"AutoIt",$winTitle)

EDIT:

or simply

Local $winTitle = WinGetTitle("[REGEXPCLASS:(?i)HwndWrapper.*MainWindow.exe.*]")
MsgBox(1,"AutoIt",$winTitle)

EDIT:

But the question which gave @JohnOne is realy intresting.

Thanks for reply,

both of your suggestion returns 0. i can not get window title

Edited by Sethu1984
Posted

check the @error 

Local $winTitle = WinGetTitle("[REGEXPCLASS:(?i)HwndWrapper.*MainWindow.exe.*]")
MsgBox(1,"AutoIt @error = " & @error,$winTitle)

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • Solution
Posted

Wait a moment I see now

I use Class from first post 

try again this:

Local $winTitle = WinGetTitle("[REGEXPCLASS:(?i)HwndWrapper.WpfApp.*vshost.exe.*]")
MsgBox(1,"AutoIt @error = " & @error,$winTitle)

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

I suspect that the problem is that inside the class name used characters like square brackets.

"[CLASS:HwndWrapper[...........]]")

and that is why I suggest using REGEXPCLASS

EDIT:

It is quite an unusual situation and is therefore not described in the documentation.

EDIT:

I suspect just like you in OP.

Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 10/7/2013 at 11:46 AM, mlipok said:

 

Wait a moment I see now

I use Class from first post 

try again this:

Local $winTitle = WinGetTitle("[REGEXPCLASS:(?i)HwndWrapper.WpfApp.*vshost.exe.*]")
MsgBox(1,"AutoIt @error = " & @error,$winTitle)

Hello Milpok,

Thanks for your great reply it works like charm...

Posted (edited)

Please try once again this:

Local $winTitle = WinGetTitle("[REGEXPCLASS:(?i)HwndWrapper\[WpfApp.*vshost.exe.*\]]")

EDIT:

I just want to check something with this brackets

Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 10/8/2013 at 7:33 AM, mlipok said:

Please try once again this:

Local $winTitle = WinGetTitle("[REGEXPCLASS:(?i)HwndWrapper\[WpfApp.*vshost.exe.*\]]")

EDIT:

I just want to check something with this brackets

Yes milpok this syntax is also working

but have any idea why below one syntax is not working

Class:    HwndWrapper[WpfApplication9.vshost.exe;;0ef727d1-fc4b-41c4-8433-a9accda280d8]

Not Working

WinGetTitle("[REGEXPCLASS:(?i)HwndWrapper[WpfApplication9.vshost.exe;;0ef727d1-fc4b-41c4-8433-a9accda280d8]]")

Working

WinGetTitle("[REGEXPCLASS:(?i)HwndWrapper[WpfApplication9.vshost.exe;;.*0ef727d1-fc4b-41c4-8433-a9accda280d8]]")

Posted (edited)

look at the example:

http://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm

what a special character you see in the examples:

  Quote

 

One or more properties are used in the title parameter of a window command in the format:

[PROPERTY1:Value1; PROPERTY2:Value2]
WinWaitActive("[TITLE:My Window; CLASS:My Class; INSTANCE:2]", "")

there is:

 [  :  ; ]

You can not use this characters in TITLE or CLASS

If you want to use them you must use REGEXPTITLE or REGEXPCLASS

In regex you can use one of that:

:

;

]

or just

.

 

 

I do not know if my description is not too short and terse, but I hope that enough.

Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 10/8/2013 at 7:35 PM, mlipok said:

look at the example:

http://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm

what a special character you see in the examples:

WinWaitActive("[TITLE:My Window; CLASS:My Class; INSTANCE:2]", "")

there is:

 [  :  ; ]

You can not use this characters in TITLE or CLASS

If you want to use them you must use REGEXPTITLE or REGEXPCLASS

In regex you can use one of that:

:

;

]

or just

.

 

 

I do not know if my description is not too short and terse, but I hope that enough.

Thanks milpok, Now i am pretty clear from the link which u shared once again thanks for solving my issue and make me clear on this.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...