DrLarch

How to match window class via regular expression?

5 posts in this topic

I have several windows that I'm trying to deal with that have no title, no consistent text or much else to match on except for the class. But the class itself varies each time the application runs and has colons in it. For example one class is: "Afx:8:17e:6:10de" and the last four characters are different every time. Could someone please provide an example of how this could be done? The help entry "Window Titles and Text (Advanced)" has a link for REGEXPCLASS directing to StringRegExp which has no examples for matching windows, much less the syntax for matching a window class via this method. Thanks...

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

DrLarch,

I would imagine this would work:

("[REGEXPCLASS:(?i)Abx:8:17e:6:[a-z0-9]{4}")

M23

Edited by Melba23
Wrong bracket

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks Melba & jguinch, I'll give that a shot. But regarding the colons, I read somewhere that they need to be doubled up in some cases, but guessing not in a regular expression?

Share this post


Link to post
Share on other sites

DrLarch,

Not according to my testing - the only characters that need to be "escaped" in a RegEx are:

\ . ^ $ | [ ( { * + ? #

and that involves a leading " \ ".

You may be thinking of the double brackets when you deal with POSIX classes as when they are used inside existing class brackets it leads to the following rather odd syntax:

[[:alnum:]]

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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