I’ve got a script that works in Applescript’s edit perfectly, but gives the following error when I try to run it from inside KM
/var/folders/_d/tr03v0911ln7chvy_hr3zcym0000gn/T/Keyboard-Maestro-Script-650B06D6-65E3-4AAE-9D27-AB8A2A1E7C9F:1000:1003: execution error: Can’t get end. (-1728)
The script is rather convoluted so I don’t want to post it here, but it mainly just gets a bit.ly link for a site depending on whether the user is using Chrome or Safari. Is there any rough idea of what would make the script fail in KM but work fine in AS?
Wrap your script in a proper error handler and see if you get any more information.
If not then you’ll have to troubleshoot the script the hard way.
-------------------------------------------------------------------------
try
# YOUR SCRIPT HERE
on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
try
tell application (path to frontmost application as text) to set ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try
-------------------------------------------------------------------------
Keyboard Maestro runs scripts in osascript, so generally you can get the same result by simply opening the Terminal, typing “osascript[return]” and then pasting in your script, press return and Control-D.
Even then the context is slightly different, since the Terminal context is different to the Keyboard Maestro context.