In my project, i can get the window which mouse is on, and i can use AXUIElementSetAttributeValue(element, kAXFrontmostAttribute, kCFBooleanTrue);
to make the window to top level temporarily. So i want to convert the element to Cocoa NSWindow and then use makeKeyAndOrderFront
to make it always in front. Anyone know how to implement this.
+ (NSArray *)attributeNamesOfUIElement:(AXUIElementRef)element {
NSArray *attrNames = nil;
AXUIElementCopyAttributeNames(element, (const void*)&attrNames);
AXUIElementSetAttributeValue(element, kAXFrontmostAttribute, kCFBooleanTrue);
// Below lines doesn't work.
HIObjectRef windowref=AXUIElementGetHIObject(element);
NSWindow *cocoaWindow = [[NSWindow alloc]initWithWindowRef:windowref];
return attrNames;
}