Alex Posted May 12 Share Posted May 12 (edited) I have a workflow with a 'Run Script' object set to 'osascript' tell application "System Events" set frontApp to name of first application process whose frontmost is true end tell if frontApp is "Agenda" then return "Agenda" else return "Other" end if This is connected to an Args and Vars object that stores {query} in {var:active_app} Conditional Utility: if '{var:activeapp}' 'is equal to' 'Agenda' (Ignoring Case) then 'Agenda' 'else' 'Other' After this, I have 'Copy to Clipboard' objects connected to the two outputs of the Conditional Utility, and they both print {var:active_app} as well as some text identifying the path ('Agenda Output' and 'Other Output'). However, even when {var:active_app} is 'Agenda', I get the 'else' path. I don't understand why 'Agenda' is not being evaluated as equal to 'Agenda'? For now, I've changed my script to return 1 when the frontApp is "Agenda" tell application "System Events" set frontApp to name of first application process whose frontmost is true end tell if frontApp is "Agenda" then return 1 else return 0 end if And then the Conditional Utility to evaluate if '{var:active_app)' 'is true' This works and I get the 'Agenda' path when Agenda is active and the 'else' path when any other app is active. Perhaps I'm missing something, but it feels like there's a bug in the way that 'is equal to' is being evaluated, because if the variable prints as 'Agenda', and 'is equal to' is set to 'Agenda', why is it not matching? Thanks Edited May 12 by Alex Link to comment
zeitlings Posted May 12 Share Posted May 12 As a general tip, use the debug utility to check your arguments and variables. When the string is returned from AppleScript, a newline character is added to the name of your frontmost app. If you remove the trailing newline character, matching the name will succeed. https://transfer.archivete.am/tldFJ/Test | AppleScript Conditional.alfredworkflow Stephen_C 1 Link to comment
Alex Posted May 12 Author Share Posted May 12 Thanks @zeitlings, appreciate the help! All good now. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now