Hi everyone, I have searched the web high & low for a solution.
Background: I am using Keyboard Maestro (1) to try to make macro(s) for use in an EMR (EG Clinea) in a virtual Windows environment with Microsoft Remote Desktop (MRD). I need to use the "INSERT" key a lot in the EMR, so have used Karabiner to convert "right_command" to "INSERT" key.
KM seems to accept this and shows "right_command" as "Help/Insert"
**PROBLEM: In KM I've made a macro that is not working correctly.
It seems to stop after the first action (ENTER).
CTRL-R (to go to prescriptions) does not happen.
The ALT modifier seems to work. However, text strings are then not inserted where they were supposed to go.
Sidenote: Whilst using Elgato Stream Deck as a launcher of KM macros - it also inserted a great many "aaaaaaaa" in the text string on its own accord, which has dumbfounded me.
I also tried the "record" feature with KM in the background and Remote Desktop app as frontmost... everything recorded nicely, but still not working.
Any suggestions?
(1) Right now without Elgato Stream Deck XL with MacOS Ventura 13.4.1, but planning to implement this later, once I've wrangled KM
I do a similar thing to access my EMR (different than yours) using Microsoft Remote Desktop (MRD) and I also use the Elgato Streamdeck to trigger KM Macros. The work-around that I have found to work best is to substitute the keypresses that don't work natively with the Execute AppleScript action.
For example, when trying to type: "(Sample-Text)" using the "Insert Text action by typing" you will instead see "9sample-text0" where the parentheses are typed as 9 and 0 and no capital letters are typed because the Insert Text action does not properly convey the Shift Key to the windows computer via MRD.
Instead try setting the text you want to type to a KM Variable (which for this example we'll call: YourText) and then use an Execute AppleScript Action with the following code:
tell application "Keyboard Maestro Engine" to set text2Type to getvariable "YourText"
tell application "System Events" to keystroke text2Type
I can't tell you why this works or why the Insert Text Action does not properly convey some modifier keys to Windows across the MRD interface, but this is the only way I have found to work for me. Perhaps @peternlewis knows why?
For single key presses like CTRL-R that you report not working...again try the "Execute AppleScript" action with code like this:
tell application "System Events" to keystroke "r" using control down
you can use multiple modifier keys like so:
tell application "System Events" to keystroke "r" using {control down, shift down}
You can also use key codes. So CTRL-R would be:
tell application "System Events" to key code 15 using control down
Thank you so much! I'll try!
Ugh though! I was hoping to avoid too many work-arounds using KM.
And weird that MRD does not receive the input when simulated by KM/Elgato or whichever, but works fine when "real" keypresses are performed.
I'll try my hand at your solution and report back if everything is working properly.
The other thing that may help you is to put short pauses between each keystroke action. You'll have to experiment but 0.3 to 0.5 second pauses usually work for me...but it will depend on your connection speed to the remote computer. Otherwise KM will execute the steps too fast for your remote computer to respond and the macro will fail.
Thanks, it's finally getting there!
A follow-up: If I want to repeat a macro X number of times or "ad naseum" what is the easiest way to proceed?
Background: I need the macro to pull X number of patient records on a list one a time to then download the referral note of each patient sequentially from a secure* website
*I have to identify with MitID (a Danish version of a digital signature) the first time I log-in, but I can live with a login the first time as there is no known workaround that I am aware of.
Put the relevant block of your macro inside a "Repeat" action, or
Make another macro that is a "Repeat" action containing an "Execute Macro" action that runs your original macro
If you want to take it further, start another thread -- many people will look at the title of this one and then ignore it since sending modifier keys to MRD is a known problem.