Post

Replies

Boosts

Views

Activity

[Applescript] set miniatured property failed
Hi, Recently we tested how to minimize app using Applescript as below picture and find some interesting phenomenon. After executing the script, if “miniaturized” marked in green (recognized as parameter), it failed to set minimize property. If “miniaturized” marked in purple, it is ok to set minimize property. Because the syntax is exactly the same, could you help to guide us what is wrong with the script? Sincerely, Thanks, YM
2
0
742
May ’23
"URLsForApplicationsToOpenContentType" alternative in macOS
Recently we surveyed macOS file association by extension to retrieve what app to “open with”. Ex: image.png -> “Preview” to open “URLsForApplicationsToOpenContentType”(macOS 12.0+) is a good API which returns NSArray for “open with” app list. https://developer.apple.com/documentation/appkit/nsworkspace/3752999-urlsforapplicationstoopencontent May I ask the alternative for “URLsForApplicationsToOpenContentType” below macOS 12.x ?  “LSCopyDefaultApplicationURLForContentType” (macOS 10.10–12.00) is “Deprecated”. https://developer.apple.com/documentation/coreservices/launch_services?language=objc
0
0
275
Nov ’22
NSAppleScript memory leak
Platform: macOS 12.3.1 Xcode: 13.3 I had Xcode ARC turned ON. AppleScript should be declared like below. NSAppleScript *script = [[NSAppleScript alloc] initWithSource:strScript]; When call AppleScript, open "Monitor.app" app will observe some memory leak. I try to wrap AppleScript by autoReleasePool. Memery leak still exists @autoreleasepool { NSAppleScript *script = [[NSAppleScript alloc] initWithSource:strScript]; //script to do something } Is there other suggestion to do gabage collection to release memory?
15
0
2.4k
Apr ’22
Detect Accessibility privilege using ObjectiveC++ in Xcode
Hi, Detecting "Accessibility" granted or not will work using "AXIsProcessTrustedWithOptions" API in Xcode with compile source as "According to file type". But changing Xcode setting with compile source as "Objective C++" will make "AXIsProcessTrustedWithOptions" API always return "NO" since the Accessibility privilege is granted in "Security & privacy". Does anyone have any idea about this? Thanks, YM
0
0
408
May ’21
window name not available in macOS 10.15
Hi,By enumerating desktop windows in Xcode,In macOS 10.14.6, it is easy to get window name by window number.In macOS 10.15.1, it is unable to get window name in the same flow. (ref. source code below)---------------------------------------------------------------------------------CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);for (NSMutableDictionary* entry in (__bridge NSArray*)windowList){ NSString* owner = [entry objectForKey:(id)kCGWindowOwnerName]; NSString* Name = [entry objectForKey:(id)kCGWindowName]; NSString* ownerPID = [entry objectForKey:(id)kCGWindowOwnerPID]; NSInteger win_num = [[entry objectForKey:(id)kCGWindowNumber] integerValue]; if( num == win_num ) { ownerName = owner; //ex: "Finder" windowName = Name; // "nil" in macOS 10.15.1 NSLog(@"drag window found: %@, %@: %d", ownerName, windowName, (int)win_num); break; }}CFRelease(windowList);---------------------------------------------------------------------------------"windowName" is necessary along with "ownerName" to move desktop window to specified position by Apple script.I try to have my app get “Accessibility” priviledge in “Security & Privacy” panel, but in vain.How to get "windowName" in macOS 10.15.x ?Is there other way to move window in macOS 10.15 or above?Sincerely,Yiming
2
0
1.8k
Dec ’19