Lightroom: Windows accepts keystrokes normally, in OSX it does not

  • 1
  • Problem
  • Updated 2 years ago
  • (Edited)
My application MIDI2LR (code at https://github.com/rsjaffe/MIDI2LR/bl...), sends keystrokes to Lightroom and is cross-platform. Everything works fine in Windows, but in OSX, shortcuts that include the Command key do not work. Other OSX programs accept those shortcuts from MIDI2LR just fine, and the code is the standard set of steps for OSX. I presume that, because LR is monitoring for the command key as it modifies display in certain circumstances (e.g., adjusting noise reduction), it is using a non-standard way of identifying whether that key is pressed or no. This non-standard behavior should be viewed as a bug. The following is an abbreviated version of the code in the link above. This code should work with an application that complies with standard OSX program behavior but does not work with Lightroom. This should send Command-a (select all).

const CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef d = CGEventCreateKeyboardEvent(source, 0, true);
CGEventRef u = CGEventCreateKeyboardEvent(source, 0, false);
CGEventSetFlags(d, kCGEventFlagMaskCommand);
CGEventSetFlags(u, kCGEventFlagMaskCommand;);
constexpr CGEventTapLocation loc = kCGSessionEventTap;
CGEventPost(loc, d);
CGEventPost(loc, u);
CFRelease(d);
CFRelease(u);
CFRelease(source);
Photo of Rory Jaffe

Rory Jaffe

  • 37 Posts
  • 5 Reply Likes
  • frustrated

Posted 2 years ago

  • 1

Be the first to post a reply!