Rule to determine if screen is currently locked?

I have crafted a Hazel embedded Applescript to import new files into a fitness app when they get added to a Dropbox folder. This app hasn't any Applescript support, so the script uses key sequences and such to get the job done. Tests and works fine when the Mac screen is unlocked, but it appears OSX blocks some of these UI actions when the screen is locked, and then the script fails. Since Hazel has matched the file since it was added, no further processing occurs upon screen unlock.
These files get added to Dropbox as soon as the fitness device (a Wahoo Elemnt Bolt) is on the home network. That's pretty much always going to be before I get to my keyboard.
I can add code to the Applescript to test for screen lock (not terribly difficult) and unlock it before running the rest of the code (ugly, as it would require putting my password into the script and keeping it in sync). I'd prefer not to do this.
Is there some existing mechanism in Hazel (I've not found it in the manual) to do the following:
When new file appears in folder
If screen is unlocked
run internal Applescript against theFile
else
leave file marked as unmatched
I believe I can "roll my own rule" to check screen lock using the "passes shell" rule style. My question then becomes: if the "passes shell" rule fails, then the new-file-match rule doesn't happen, and the file is considered not to have been matched yet, right? If so, does this create a pretty busy loop that keeps testing the "passes shell" rule until it works?
Advice on how to tackle this much appreciated.
--Richard
These files get added to Dropbox as soon as the fitness device (a Wahoo Elemnt Bolt) is on the home network. That's pretty much always going to be before I get to my keyboard.
I can add code to the Applescript to test for screen lock (not terribly difficult) and unlock it before running the rest of the code (ugly, as it would require putting my password into the script and keeping it in sync). I'd prefer not to do this.
Is there some existing mechanism in Hazel (I've not found it in the manual) to do the following:
When new file appears in folder
If screen is unlocked
run internal Applescript against theFile
else
leave file marked as unmatched
I believe I can "roll my own rule" to check screen lock using the "passes shell" rule style. My question then becomes: if the "passes shell" rule fails, then the new-file-match rule doesn't happen, and the file is considered not to have been matched yet, right? If so, does this create a pretty busy loop that keeps testing the "passes shell" rule until it works?
Advice on how to tackle this much appreciated.
--Richard