I've been struggling to create a subroutine to find and click on a word on the screen using Better Touch Tool (BTT) "find/search text on screen and move mouse" action from Keyboard Maestro.
I hope there is a way to assign the a search word to a variable in KM, evoke BTT action from KM, pick up the variable in BTT, execute it and click on the word found with the mouse and return the control back to KM. Is it doable? How can one transfer variables between KM and BTT? Is there a way to run a specific BTT macro from KM?
I am aware of the MoveMouseToWord macro for KM created by @Airy but find it more difficult to use to achieve the same result.
OK I am struggling here. What is wrong with this one? I am trying to use "FindWord" variable from KM, and bring it to BTT, assigning its value to ClickWord variable (do I need to do it?). Is there a way to do it in a simpler manner?
you are only telling keyboard maestro, but not transferring the variable to BTT
I don't know the KM interfaces at all, but it should be something like
tell application "Keyboard Maestro Engine"
set kmValue to getvariable "FindWord"
end tell
tell application "BetterTouchTool"
set_string_variable "ClickWord" to kmValue
end tell
There are two ways for AppleScript to access KBM variables. One is similar to what has been suggested above. The other is available when Keyboard Maestro initiates the AppleScript script. Then it make all KBM variables available to the AppleScript environment.
Keyboard Maestro sets the environment variables for the script to include all (by default) your variables, using a prefix of KMVAR_ and your variable name with spaces changed in to underscores (_). For example, your Keyboard Maestro “File Name” variable will be available as the environment variable KMVAR_File_Name. By default, all variables are included, but you can limit which variables are included by using the popup menu next to the script (v11.0+). Note that these provide a readonly copy of the value of the variables when the script starts.
Also, you can (7.1+) access Keyboard Maestro variables directly like this: