macos-carbon

macOS accessibility API on WebKit applications with AXTextMarker

风格不统一 提交于 2019-12-01 13:37:55
I need to access data from webkit applications such as Safari, Mail and maybe others. I can see in the Accessibility Inspector there is : AXTextMarker and AXTextMarkerForRange . I tried the usual way to get this info : AXUIElementRef systemWideElement = AXUIElementCreateSystemWide(); //creating system wide element AXUIElementRef focussedElement = NULL; AXError error = AXUIElementCopyAttributeValue(systemWideElement, kAXFocusedUIElementAttribute, (CFTypeRef *)&focussedElement); //Copy the focused if (error != kAXErrorSuccess){ NSLog(@"Could not get focused element"); }else{ AXValueRef marker =

How to Identify if the process in User Interface Process?

半腔热情 提交于 2019-12-01 11:31:01
How can I get information from a process that it is UI(User Interface) process or non-ui? With UI process I mean, Finder, Dock, System UI server, or any other mac application which has UI interface and it is used by Window Server. I want to determine this information from ProcessID. I am using mac os x. darvids0n There is no way to determine based purely on the PID number what a specific process is. The reason for this: Process IDs are assigned (somewhat) sequentially from PID=1 on startup, and startup can be different for different systems. The process ID will also be reassigned if, for

macOS accessibility API on WebKit applications with AXTextMarker

别说谁变了你拦得住时间么 提交于 2019-12-01 11:18:45
问题 I need to access data from webkit applications such as Safari, Mail and maybe others. I can see in the Accessibility Inspector there is : AXTextMarker and AXTextMarkerForRange . I tried the usual way to get this info : AXUIElementRef systemWideElement = AXUIElementCreateSystemWide(); //creating system wide element AXUIElementRef focussedElement = NULL; AXError error = AXUIElementCopyAttributeValue(systemWideElement, kAXFocusedUIElementAttribute, (CFTypeRef *)&focussedElement); //Copy the

How do I find a window at a certain point on the screen for screenshot/screen-recording purposes?

a 夏天 提交于 2019-12-01 09:43:15
问题 I'm looking for a way to do what the equivalent of WindowFromPoint and GetWindowRect do, in Carbon/Cocoa and X11. WindowFromPoint - http://msdn.microsoft.com/en-us/library/ms633558%28VS.85%29.aspx GetWindowRect - http://msdn.microsoft.com/en-us/library/ms633519%28VS.85%29.aspx 回答1: I am developing screenshot and screen recording apps … Use Quartz Window Services. I want to … determine the bounding rectangle of the window, and then use the coordinates of the window to capture a bitmap of that

CGWindowID from AXUIElement

為{幸葍}努か 提交于 2019-12-01 04:47:29
I'm trying to automate a foreign OSX application using the accessibility API. Some of the state of the application isn't available through the API, so I acquire it through screen scraping. To do this, I need to get CGWindowID for an accessibility object with a 'Window Role'. Is there any direct way of acquiring CGWindowID of a 'Window Role' accessibility object? I can get it heuristically, by matching various attributes of the window, such as the size, title and location, but this is really hacky, and I'd feel better if my application would also support the corner cases, even if they are

CGWindowID from AXUIElement

泪湿孤枕 提交于 2019-11-30 04:55:15
问题 I'm trying to automate a foreign OSX application using the accessibility API. Some of the state of the application isn't available through the API, so I acquire it through screen scraping. To do this, I need to get CGWindowID for an accessibility object with a 'Window Role'. Is there any direct way of acquiring CGWindowID of a 'Window Role' accessibility object? I can get it heuristically, by matching various attributes of the window, such as the size, title and location, but this is really

How can you load a font (TTF) from a file using Core Text?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 00:00:00
Prior to OSX 10.6, ATSFontActivateFromFileSpecification/ATSFontActivateFromFileReference were available and could be used to load a font from a file. I can't find anything similar in Core Text. Rob Keniger You can get a CTFontRef from a font file by going via a CGFontRef : CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("/path/to/font"), kCFURLPOSIXPathStyle, false); CGDataProviderRef dataProvider = CGDataProviderCreateWithURL(url); CGFontRef theCGFont = CGFontCreateWithDataProvider(dataProvider); CTFontRef theCTFont = CTFontCreateWithGraphicsFont(theCGFont); CFRelease

What replaces the now-deprecated Carbon.File.FSResolveAliasFile in Python on OSX?

与世无争的帅哥 提交于 2019-11-29 16:57:00
In Python 2, I can use the following code to resolve either a MacOS alias or a symbolic link: from Carbon import File File.FSResolveAliasFile(alias_fp, True)[0].as_pathname() where alias_fp is the path to the file I'm curious about, stored as a string ( source ). However, the documentation cheerfully tells me that the whole Carbon family of modules is deprecated . What should I be using instead? EDIT: I believe the code below is a step in the right direction for the PyObjC approach. It doesn't resolve aliases, but it seems to detect them. from AppKit import NSWorkspace def is_alias (path): uti

How can I move/resize windows programmatically from another application?

被刻印的时光 ゝ 提交于 2019-11-29 14:52:29
I know, that I can use Apple Event Object Model for moving and resizing windows of Cocoa applications. But what can I use for Carbon applications? Same thing. You can use Apple Events on any scriptable application, and Apple Events and scriptability are a lot older than Carbon. Peter was right, you can access to bounds of any window using the following AppleScript: tell application "System Events" set allProcesses to application processes repeat with i from 1 to count allProcesses tell process i repeat with x from 1 to (count windows) position of window x size of window x end repeat end tell

How can I set the mouse position?

淺唱寂寞╮ 提交于 2019-11-29 12:12:56
I need to set the position of the mouse on the screen. In some other similar question, it was suggested to use CGDisplayMoveCursorToPoint(CGDirectDisplayID display, CGPoint point) , but I cannot figure out how to get the CGDirectDisplayID . Please tell me how to get the CGDirectDisplayID or a different method to set the mouse position. The real answer to this question is: CGMainDisplayID() https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/index.html#//apple_ref/c/func/CGMainDisplayID CGDisplayMoveCursorToPoint(CGMainDisplayID(), point); Try