mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
[EDIT] By Saki, replace _AXUIElementGetWindow with AXUIElementCopyAttributeValue
This commit is contained in:
parent
31ddf1a959
commit
9aa4059a31
16
window/pub.h
16
window/pub.h
@ -42,7 +42,7 @@ typedef struct _Bounds Bounds;
|
|||||||
static Boolean(*gAXIsProcessTrustedWithOptions) (CFDictionaryRef);
|
static Boolean(*gAXIsProcessTrustedWithOptions) (CFDictionaryRef);
|
||||||
static CFStringRef* gkAXTrustedCheckOptionPrompt;
|
static CFStringRef* gkAXTrustedCheckOptionPrompt;
|
||||||
|
|
||||||
AXError _AXUIElementGetWindow(AXUIElementRef, CGWindowID* out);
|
//AXError _AXUIElementGetWindow(AXUIElementRef, CGWindowID* out);
|
||||||
static AXUIElementRef GetUIElement(CGWindowID win){
|
static AXUIElementRef GetUIElement(CGWindowID win){
|
||||||
intptr pid = 0;
|
intptr pid = 0;
|
||||||
// double_t pid = 0;
|
// double_t pid = 0;
|
||||||
@ -90,13 +90,25 @@ typedef struct _Bounds Bounds;
|
|||||||
AXUIElementRef element = (AXUIElementRef) CFArrayGetValueAtIndex(windows, i);
|
AXUIElementRef element = (AXUIElementRef) CFArrayGetValueAtIndex(windows, i);
|
||||||
CGWindowID temp = 0;
|
CGWindowID temp = 0;
|
||||||
// Use undocumented API to get WindowID
|
// Use undocumented API to get WindowID
|
||||||
_AXUIElementGetWindow(element, &temp);
|
/*_AXUIElementGetWindow(element, &temp);
|
||||||
|
|
||||||
if (temp == win) {
|
if (temp == win) {
|
||||||
// Retain element
|
// Retain element
|
||||||
CFRetain(element);
|
CFRetain(element);
|
||||||
result = element;
|
result = element;
|
||||||
break;
|
break;
|
||||||
|
}*/
|
||||||
|
CFTypeRef cfWindow = NULL;
|
||||||
|
if (AXUIElementCopyAttributeValue(element, kAXWindowAttribute, &cfWindow) == kAXErrorSuccess && cfWindow != NULL) {
|
||||||
|
temp = *(CGWindowID*)CFDataGetBytePtr(cfWindow);
|
||||||
|
CFRelease(cfWindow);
|
||||||
|
|
||||||
|
if (temp == win) {
|
||||||
|
// Retain element
|
||||||
|
CFRetain(element);
|
||||||
|
result = element;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user