Front window condition where the window name starts with a number

Hey folks, is there a way of using KM to detect whether name of the front window of an application begins with a number? I've been having a lot of success using it with Cubase and sending MIDI messages to Metagrid Pro based on the name of the front window, however when an instrument window is in focus, the window title begins with a two-digit number that corresponds to the number of the instrument.

The end result I'd like is to be able to move any open instrument windows to a specific spot, so if I'm able to base my If-Then-Else on the front window starting with a number, then I'd be in business. Any suggestions?

This should do it. If the window name starts with say, "10" or "6" or "120" it returns true but if it starts with say, "Ten" it returns false. (It is actually just checking that the very first character is a digit but it sounds like that should work for your purpose.)

The condition is if matches the regex ^\d

(^ is for start of string, \d is to match a digit)

To only match if the first two characters are digits you could use ^\d\d

To only match if the name starts with a two digit number and not match if it starts with three or more digits, you could use ^\d\d\D

(\D means not a digit)

Test if Front WIndow Name starts with a Number.kmmacros (5.6 KB)

Click to Show Image of Macro

Hey Aurio, thanks for that, it sent me down the right path, and after a little bit of tinkering with the Move Front Window action, everything works great. Much appreciated!