Check if token exists

Hi. I've got a script that is triggered by focused window title changes.

In some scenario's there apparently is no window title. For example after clicking on the desktop, but I suspect there are also background apps in play that don't have a title. I want to take or prevent actions based on the absence of a title. How can I check for this?

This is what I have tried. I suspect it doesn't work because %WindowName%Front% at that moment doesn't exist and therefor the 'is not empty' test fails. The notification is executed and displays "". What would be the best way to deal with this? Thank you.

In the Finder, at least, %WindowName%Front% does return "" when the Desktop is active:

No WIndow Test.kmmacros (4.8 KB)

Image

...so I suspect something else is going on.

But in general -- if you've got an action etc that might succeed or might error, wrap it in a "Try/Catch" block and either use that directly for flow control or set a variable you can use for such later on.

Hi Nige_S,

Thank you very much for your input. Im not quite there yet but this has given me enough insight to plough on. Should I get any major breakthroughs I will report them here.

regards, Ferdinand