Jump to content
Seminko

WinExists partial Class name

Recommended Posts

Seminko

Hey fellas,

is there a was to check if window exists by only a partial Class?

The Class is apparently dynamic for my window and looks something like: HwndWrapper[app.exe;;255bd6d6-etc-etc-etc]

I would like to search only for app.exe in the class.

Is that doable?

Thanks

Seminko

Share this post


Link to post
Share on other sites
willichan

Have you tried doing something like this?

WinExists("HwndWrapper[app.exe","")

-- edit --

You might also want to set the Window Title Match option somewhere before calling WinExists()

AutoItSetOption("WinTitleMatchMode", 2) ;Match any substring in the title

 

Edited by willichan
additional information

Share this post


Link to post
Share on other sites
Seminko
23 minutes ago, willichan said:

Have you tried doing something like this?

WinExists("HwndWrapper[app.exe","")

-- edit --

You might also want to set the Window Title Match option somewhere before calling WinExists()

AutoItSetOption("WinTitleMatchMode", 2) ;Match any substring in the title

 

Does not work. I suspect AutoItSetOption only works on Titles not Classes.

Share this post


Link to post
Share on other sites
willichan

Interesting.  I am able to do partial class name matching on my PC using this method.

Share this post


Link to post
Share on other sites
Seminko
2 minutes ago, willichan said:

Interesting.  I am able to do partial class name matching on my PC using this method.

Shouldn't Class be specified like this?

WinExists("[Class:ClassName]")

 

Share this post


Link to post
Share on other sites
willichan

I used your own example to format the search example I gave you.  You should substitute in the part of the class name you are looking for.

In my test, I looked for my IBM Notes window.  The AutoIt v3 Window Info utility gives me the following info.

>>>> Window <<<<
Title:  Mail - Inbox - IBM Notes
Class:  SWT_Window0

I used the following line to test for it

If WinExists("SWT_Win","") Then MsgBox(0,"test","yes")

For me, I get a "yes" pop-up whenever I have Notes open, and nothing when it is closed.

I can't guarantee that it will work for all apps.  You will need to test it for your situation.

Share this post


Link to post
Share on other sites
jdelaney

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

REGEXPCLASS - Window classname using a regular expression (if the regular expression is wrong @error will be set to 2)

  • Like 1

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

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

×