Using tiffle's suggestions, I was able to accomplish what I wanted which was to use an AppleScript imbedded in Xojo to fire off a Keyboard Maestro script.
The screenshot below shows the navigation bar with the file that tiffle supplied (Info2) and the AppleScript (AardvarkPrepare). Both have been dragged to this location.
AardvarkPrepare is very simple.
At this point, all works pretty well. It is cool that in Xojo you can just write a line of code
in, for example, the action event of a button and the AaarvarkPrepare.scpt in the navigation bar of the same name will run. It will even auto-complete when you are typing that line of code. And this particular AppleScript will launch the Keyboard Maestro macro.
For the record, when I attempted a more complex Keyboard Maestro, I ran into a problem that stumped me for a considerable time. The Keyboard Maestro macro that I was running bounced around various apps (one of the magic powers of Keyboard Maestro) and then returned to the Xojo app to get some additional information. The whole process was initiated by a menu event handler in Xojo. When the logic of the macro brought it back to Xojo a second menu event handler in Xojo was used to keep the chain of Keyboard Maestro commands going.
This did not work. I am not sure exactly why, but when I tried debugging the situation it was apparent that, while nothing crashed, I did not end up with the desired outcome. If I launched the same Keyboard Maestro macro using a hotkey trigger in Keyboard Maestro then things worked just fine.
For whatever reason, the menu event handlers in Xojo never really completed until after all the Keyboard Maestro steps had been run. In some sense, it was suspended. So if I wrote some code to time-stamp and log the ending (last line of code) of the menu event handlers those lines of code did not happen until after everything in Keyboard Maestro had completed.
To deal with this situation, I changed tactics slightly. I did not imbed the AppleScript script in the navigation bar of Xojo. Rather I saved the AppleScript as an app rather than the default complied script. Xojo was informed of the path of this app on the file system of the computer.
Var NAME_KM_MACRO As String // The simple AppleScript app that initiates KM script
NAME_KM_MACRO = "AardvarkPrepare.app"
Var f As folderitem = SpecialFolder.Desktop.Child(NAME_KM_MACRO)
If f <> Nil And f.exists Then
So the Keyboard Maestro macro was fired off by opening the app (AardvarkPrepare.app). That overcame the issue. It involves having to know where in the file system the app lives and making sure that the location corresponded to the Xojo code but it works. (In the example I put the code on the Desktop)
So in this special circumstance, I use the
technique but usually I can just put the AppleScript title in the navigation bar and access it from there.