mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-17 21:43:55 +00:00
Compare commits
No commits in common. "dd208c6dd1b972ce67d83eaee4218357f6bba194" and "48706562fc34dcd710da5ca49f3d16a4ca3d423f" have entirely different histories.
dd208c6dd1
...
48706562fc
@ -24,45 +24,33 @@ Bounds get_bounds(uintptr pid, int8_t isPid){
|
|||||||
AXValueRef axp = NULL;
|
AXValueRef axp = NULL;
|
||||||
AXValueRef axs = NULL;
|
AXValueRef axs = NULL;
|
||||||
AXUIElementRef AxID = AXUIElementCreateApplication(pid);
|
AXUIElementRef AxID = AXUIElementCreateApplication(pid);
|
||||||
AXUIElementRef AxWin = NULL;
|
|
||||||
|
|
||||||
// Get the window from the application
|
|
||||||
if (AXUIElementCopyAttributeValue(AxID, kAXFocusedWindowAttribute, (CFTypeRef *)&AxWin)
|
|
||||||
!= kAXErrorSuccess || AxWin == NULL) {
|
|
||||||
// If no focused window, try to get the main window
|
|
||||||
if (AXUIElementCopyAttributeValue(AxID, kAXMainWindowAttribute, (CFTypeRef *)&AxWin)
|
|
||||||
!= kAXErrorSuccess || AxWin == NULL) {
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine the current point of the window
|
// Determine the current point of the window
|
||||||
if (AXUIElementCopyAttributeValue(AxWin, kAXPositionAttribute, (CFTypeRef*) &axp)
|
if (AXUIElementCopyAttributeValue(AxID, kAXPositionAttribute, (CFTypeRef*) &axp)
|
||||||
!= kAXErrorSuccess || axp == NULL) {
|
!= kAXErrorSuccess || axp == NULL){
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the current size of the window
|
// Determine the current size of the window
|
||||||
if (AXUIElementCopyAttributeValue(AxWin, kAXSizeAttribute, (CFTypeRef*) &axs)
|
if (AXUIElementCopyAttributeValue(AxID, kAXSizeAttribute, (CFTypeRef*) &axs)
|
||||||
!= kAXErrorSuccess || axs == NULL) {
|
!= kAXErrorSuccess || axs == NULL){
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGPoint p; CGSize s;
|
CGPoint p; CGSize s;
|
||||||
// Attempt to convert both values into atomic types
|
// Attempt to convert both values into atomic types
|
||||||
if (AXValueGetValue(axp, kAXValueCGPointType, &p) &&
|
if (AXValueGetValue(axp, kAXValueCGPointType, &p) &&
|
||||||
AXValueGetValue(axs, kAXValueCGSizeType, &s)) {
|
AXValueGetValue(axs, kAXValueCGSizeType, &s)){
|
||||||
bounds.X = p.x;
|
bounds.X = p.x;
|
||||||
bounds.Y = p.y;
|
bounds.Y = p.y;
|
||||||
bounds.W = s.width;
|
bounds.W = s.width;
|
||||||
bounds.H = s.height;
|
bounds.H = s.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return bounds;
|
||||||
exit:
|
exit:
|
||||||
if (axp != NULL) { CFRelease(axp); }
|
if (axp != NULL) { CFRelease(axp); }
|
||||||
if (axs != NULL) { CFRelease(axs); }
|
if (axs != NULL) { CFRelease(axs); }
|
||||||
if (AxWin != NULL) { CFRelease(AxWin); }
|
|
||||||
if (AxID != NULL) { CFRelease(AxID); }
|
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
|
Loading…
Reference in New Issue
Block a user