The variable currentApplication is the name of frontmost.
tell application "System Events" to set currentApplication to name of first application process whose frontmost is true
To test the code in Automator.
tell application "System Events" to set currentApplication to name of first application process whose frontmost is true
-- Only for testing
display dialog currentApplication
You code will look like this
tell application currentApplication
-- Your code
end tell
To make above code little more useful you could do a AppleScript record to ask the handler its name.
set appName to name of currentApplication()
display dialog appName
on currentApplication()
tell application "System Events" to set nameOfCurrentApplication to name of first application process whose frontmost is true
return {name:nameOfCurrentApplication}
end currentApplication
Thanks for your help Fredrik71. When running the script I now get an error message “Can’t set bounds of window to {0, 0, 1250, 930}”. This occurs regardless of the app from which the workflow is activated. This is a copy of the new script:
on run {input, parameters}
tell application "System Events" to set currentApplication to name of first application process whose frontmost is true
tell application currentApplication
tell window
set bounds to {0, 0, 1250, 930}
end tell
end tell
return input
property theBounds : {{0, 0}, {1250, 930}}
tell application "System Events" to tell window 1 of (process 1 whose it is frontmost) to ¬
set {position, size} to theBounds