As incredible as it seems, I read the documentation and forum discussions pertaining to this topic, and it's still not clear.
In the example below, I have the variable KM_input_URL which I want to pass on to the AppleScript below ie replace "https://forum.keyboardmaestro.com/" with the variable KM_input_URL (part of a prompt for user input).
thank you very much
PS: the AppleScript opens the URL, in the same tab (to avoid tab duplications)
KM Variable KM_input_URL
set theURL to "https://forum.keyboardmaestro.com/"
tell application "Google Chrome"
tell front window
set URL of active tab to theURL
end tell
end tell
You need to use the KM Engine to get the variable into AppleScript.
But what you are trying to do with the AppleScript is possible with just native KM actions.
tell application "Keyboard Maestro Engine"
if variable "Serveraddress" exists then
set volumeToMount to value of variable "Serveraddress"
end if
end tell
tell application "Finder"
mount volume volumeToMount
end tell
I frequently need these reminders and always good to read posts like this as many times as I have set values in AppleScript based on variables in Keyboard Maestro. Thank you.
Thanks for making us all feel better about ourselves today Peter.
You have, I hope, made yourself a Favourite for this?
set inst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set varName to getvariable "Local_varName" instance inst
end tell
(*
do stuff here
*)
tell application "Keyboard Maestro Engine"
setvariable "Local_varName" instance inst to theResult
end tell
It's a lot quicker to remove what you don't need than to try and remember what to add!