axuielement

I am not able to get the range of selected text in TextEdit application from my background application

梦想的初衷 提交于 2019-12-12 09:11:31
问题 My application is agent type (running in background) and I have a button in window. when user select some text in TextEdit and trigger an action from my application I need to get the range of selection text. I am using below code but I am getting below error kAXErrorAttributeUnsupported I am using below code AXUIElementRef systemWideElement = AXUIElementCreateSystemWide(); AXUIElementRef focussedElement = NULL; AXError error = AXUIElementCopyAttributeValue(systemWideElement,

I am not able to get the range of selected text in TextEdit application from my background application

情到浓时终转凉″ 提交于 2019-12-04 17:26:38
My application is agent type (running in background) and I have a button in window. when user select some text in TextEdit and trigger an action from my application I need to get the range of selection text. I am using below code but I am getting below error kAXErrorAttributeUnsupported I am using below code AXUIElementRef systemWideElement = AXUIElementCreateSystemWide(); AXUIElementRef focussedElement = NULL; AXError error = AXUIElementCopyAttributeValue(systemWideElement, kAXFocusedUIElementAttribute, (CFTypeRef *)&focussedElement); if (error != kAXErrorSuccess) { NSLog(@"Could not get

Swift - Get file path of currently opened document in another application

ぃ、小莉子 提交于 2019-12-01 23:10:50
I am attempting to get the file path of an open document from another application using swift code. I know how to do it in AppleScript, which is like this: tell application "System Events" if exists (process "Pro Tools") then tell process "Pro Tools" set thefile to value of attribute "AXDocument" of window 1 end tell end if end tell This AppleScript does what I want, but I was hoping to do it natively in Swift. I know that one option is to run this script from my program, but I was hoping to find another way of doing it, potentially without using Accessibility. In my app I can get the