Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Regular Expressions (RegEx) In Window Commands

Did you know you can use Regular Expressions inside any of Macro Scheduler‘s window functions (e.g. SetFocus, WaitWindowOpen, WaitWindowClosed) so that you can match a window title using RegEx?

As an example someone recently asked us how they would match a window from an old piece of software where the window title was always the letter “b” followed by any 8 digits, e.g. b23425461. Macro Scheduler uses the PCRE syntax, so to match a window title like this we could use this expression:

^b\d{8}

If you’re new to RegEx this means: match from the beginning of the string (^), then match a “b” character followed by any digit (\d) 8 times. {8} means match the proceeding token 8 times. So:

Let>WIN_USEREGEX=1
SetFocus>^b\d{8}

I’ve posted a little about Regular Expressions before. This post links to some useful resources if you are new to RegEx.

Regular Expressions for Dummies
My Most Used RegEx
Remove Tags From HTML with RegEx

No related posts.



This post first appeared on Marcus' Macro Blog - Windows Macro And Windows Au, please read the originial post: here

Share the post

Regular Expressions (RegEx) In Window Commands

×

Subscribe to Marcus' Macro Blog - Windows Macro And Windows Au

Get updates delivered right to your inbox!

Thank you for your subscription

×