Wrong entry added by MacOS mojave/catalina for Accessibility

Mac OSX specific forum
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Wrong entry added by MacOS mojave/catalina for Accessibility

Post by Rinzwind »

Code: Select all

EnableExplicit

ImportC ""
  AXIsProcessTrusted()
  AXIsProcessTrustedWithOptions(options)
EndImport

Global kCFBooleanTrue = PeekI(dlsym_(#RTLD_DEFAULT, "kCFBooleanTrue"))
Global kAXTrustedCheckOptionPrompt = PeekI(dlsym_(#RTLD_DEFAULT, "kAXTrustedCheckOptionPrompt"))
Global dic = CocoaMessage(0, 0, "NSDictionary dictionaryWithObject:", kCFBooleanTrue, "forKey:", kAXTrustedCheckOptionPrompt)
;Global dic = CocoaMessage(0, 0, "NSDictionary dictionaryWithObject:", #YES, "forKey:$", @"kAXTrustedCheckOptionPrompt")

  If AXIsProcessTrustedWithOptions(dic)
    MessageRequester("Test", "Permissions are granted")
  EndIf
  
  Global w = OpenWindow(0, 0, 0, 200, 100, "Test")
  
  Repeat
    Global e = WaitWindowEvent()
    
  Until e = #PB_Event_CloseWindow
  
This code finally does something... second commented dic line doesn't work btw, access violation. Why? IDK..

However, macOS automatically adds the wrong path to the Accessibility dialog. It adds the path to the binary itself (hence the shown 'terminal icon') instead of the path to the package ('package icon'). The package path is needed to make it actually have permissions... (needs second run). How to make it add the .pkg path? plist hack?