mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-03 07:33:55 +00:00
[EDIT] By Saki, 去除 _AXUIElementGetWindow 的调用
This commit is contained in:
parent
df394a94b8
commit
de95edb1a8
@ -41,6 +41,7 @@ package robotgo
|
|||||||
//
|
//
|
||||||
#include "screen/goScreen.h"
|
#include "screen/goScreen.h"
|
||||||
#include "mouse/mouse_c.h"
|
#include "mouse/mouse_c.h"
|
||||||
|
#include "window/goWindow.h"
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ MData get_active(void) {
|
|||||||
AXUIElementRef focused = AXUIElementCreateApplication(pid);
|
AXUIElementRef focused = AXUIElementCreateApplication(pid);
|
||||||
if (focused == NULL) { return result; } // Verify
|
if (focused == NULL) { return result; } // Verify
|
||||||
|
|
||||||
AXUIElementRef element;
|
/*AXUIElementRef element;
|
||||||
CGWindowID win = 0;
|
CGWindowID win = 0;
|
||||||
// Retrieve the currently focused window
|
// Retrieve the currently focused window
|
||||||
if (AXUIElementCopyAttributeValue(focused, kAXFocusedWindowAttribute, (CFTypeRef*) &element)
|
if (AXUIElementCopyAttributeValue(focused, kAXFocusedWindowAttribute, (CFTypeRef*) &element)
|
||||||
@ -383,7 +383,32 @@ MData get_active(void) {
|
|||||||
} else {
|
} else {
|
||||||
result.CgID = win;
|
result.CgID = win;
|
||||||
result.AxID = element;
|
result.AxID = element;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
AXUIElementRef focused = NULL;
|
||||||
|
AXUIElementRef windowElement = NULL;
|
||||||
|
CGWindowID win = 0;
|
||||||
|
|
||||||
|
// Retrieve the currently focused window
|
||||||
|
if (AXUIElementCopyAttributeValue(focused, kAXFocusedWindowAttribute, (CFTypeRef*) &windowElement) == kAXErrorSuccess && windowElement) {
|
||||||
|
// Use AXUIElementCopyAttributeValue to get parent window
|
||||||
|
CFTypeRef cfWindow = NULL;
|
||||||
|
if (AXUIElementCopyAttributeValue(windowElement, kAXParentAttribute, &cfWindow) == kAXErrorSuccess && cfWindow != NULL) {
|
||||||
|
AXUIElementRef parentWindow = (AXUIElementRef)cfWindow;
|
||||||
|
if (AXUIElementCopyAttributeValue(parentWindow, kAXWindowAttribute, (CFTypeRef*)&win) == kAXErrorSuccess && win) {
|
||||||
|
// Manually set internals
|
||||||
|
result.CgID = win;
|
||||||
|
result.AxID = windowElement;
|
||||||
|
} else {
|
||||||
|
CFRelease(parentWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CFRelease(windowElement);
|
||||||
|
} else {
|
||||||
|
result.CgID = 0;
|
||||||
|
result.AxID = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(focused);
|
CFRelease(focused);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user