In macOS 10.15 Catalina there is a new section in the Security system preferences called Input Monitoring.
It says:
Allow the apps below to monitor input from your keyboard even while using other apps.
I wonder which API is behind this to get apps into this this section.
I know AXIsProcessTrustedWithOptions()
, which adds an app to the Accessibility section above Input Monitoring. Then I can use NSEvent.addGlobalMonitorForEvents(matching: .keyDown, handler: self.keyDown(event:))
to watch key presses from other apps. But what is Input Monitoring then good for?
It looks like adding an app to Input Monitoring manually doesn't allow you to use NSEvent.addGlobalMonitorForEvents(...)
.
Apps like Steam have been put into that section after updating to Catalina, so there has to be something that tells the system to put them there...
@Nick Moore is right. This API is only available since 10.15.
There are two types of request for IOHIDRequestAccess()
, and there is barely any doc about it :-( https://developer.apple.com/documentation/iokit/3181574-iohidrequestaccess?language=objc
if #available(macOS 10.15, *) {
// below requests "Input Monitoring"
IOHIDRequestAccess(kIOHIDRequestTypeListenEvent)
// below requests "Accessibility"
IOHIDRequestAccess(kIOHIDRequestTypePostEvent)
}