hammerspoon
hammerspoon copied to clipboard
passing arguments to hs.osascript.applescriptFromFile
Hi,
Is it possible to pass arguments to an existing Apple Script file with hs.osascript.applescriptFromFile? Otherwise I have to rewrite the file into hs.osascript.applescript([[ ]]) logic and maintain 2 sources.
Thank you Vincent
I ran into this same issue. A possible workaround is to pass the parameters via the Applescript command run script ... with parameters
.
set myApplescriptFile to "Macintosh HD:Users:vincent:.hammerspoon:my-applescript.scpt" as alias
run script myApplescriptFile with parameters {"one", "two"}
So your hammerspoon script might be something like
source = [[
set myApplescriptFile to "Macintosh HD:Users:vincent:.hammerspoon:my-applescript.scpt" as alias
run script myApplescriptFile with parameters {"one", "two"}
]]
hs.osascript.applescript(source)