我會回答我的問題: 它可能具有輔助功能的API &碳 一)註冊範圍內的事件:
AXUIElementRef _systemWideElement = AXUIElementCreateSystemWide();
b)將碳屏幕點
c)獲取鼠標下的進程
個
NSPoint cocoaPoint = [NSEvent mouseLocation];
if (!NSEqualPoints(cocoaPoint, _lastMousePoint)) {
CGPoint pointAsCGPoint = [self carbonScreenPointFromCocoaScreenPoint:cocoaPoint];
AXUIElementRef newElement = NULL;
if (AXUIElementCopyElementAtPosition(_systemWideElement, pointAsCGPoint.x, pointAsCGPoint.y, &newElement) == kAXErrorSuccess) {
NSLog(@"%@",newElement);
}
_lastMousePoint = cocoaPoint;
}
貸https://developer.apple.com/library/mac/samplecode/UIElementInspector/Introduction/Intro.html
的NSLog給出類似< AXUIElement 0x6000000583c0 > {PID = 39429}
ps aux | grep 39429
:39429 0.2 5.5 5109480 916500 ?? U 1:57PM 3:34.67 /Applications/Xcode.app/Contents/MacOS/Xcode
真棒和完善。我經常忘記參考這個示例應用程序,忘記AX錘子是多麼的鈍。 – uchuugaka