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