Using modifiers with RDP Windows session

Hi,

Making keystrokes work in JXA requires a few extra steps.

For example, let’s take Finder.app as the target application. Opening the “Downloads” folder in the Finder.app menu has the shortcut “L” + Command + Option. I will program it in my example:


// the Keystroke and the Keycode commands belond to Standard Additions,
// so, following code line is requred 
Application.currentApplication().includeStandardAdditions = true;

// bring to front the target application (it is Finder in my example)
Application('Finder').activate();

// optional delay. Maybe, need some delay for stability
delay(1);

// keysroke which opens Downloads folder in the Finder
Application('System Events').keystroke('l', { using: ['command down', 'option down'] });

NOTE:

  1. save this JXA example as application. Run it.

  2. The prompt to control System Events by this new app will pop up. Select Yes.

  3. Other prompt - “Not allowed to send keystrokes” will pop up. Go to Accessibility of Security & Privacy pane of System Preferences. Add your new application to applications allowed to control your Mac.

  4. Now all settings is OK, so the app can be used any moment. Run it again to ensure it works as expected.

Thanks KniazidisR, Fredrik71 and Mockman. Thanks to Mockman’s suggestion I did find some settings in Citrix Viewer that might do the trick (Unfortunately my 2nd RDP isn’t working at the moment so I can’t actually test it).

Regarding mixing up the concept of “key code” vs “keystroke,” I don’t think that’s the problem here. I simply was trying to find a way to call the alt key directly without needing to use two key combinations (such as command down, option down). Whether that was by using a single key code for the alt key or keystroke of some kind, I didn’t really care (and yes, I do know the difference). Thanks to Mockman’s (a very apt user name I might add) suggestion, I think the problem has more to do with Citrix Viewer. I changed a setting:

Hopefully, this propagates to the second, child RDP session.

So, yeah, this entire thing seems to have been a nothing burger because it had to do with a setting in Citrix Viewer, not something I needed to script.

Regarding KniazidisR’s post about bringing the correct app to front, thanks for that input as well. I’m using FastScripts and calling scripts using hotkeys so I don’t need to worry about making sure the target app is in focus.

Anyway, thanks for all the input. I appreciate all your suggestions!

I would say more acerbic than mocking but I could never come up with a fitting username. Glad you’re seeing some resolution to your problem.