macos-carbon

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

a 夏天 提交于 2019-11-28 05:21:05
问题 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? 回答1: Same thing. You can use Apple Events on any scriptable application, and Apple Events and scriptability are a lot older than Carbon. 回答2: 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

Getting a unique ID for a window of another application

心已入冬 提交于 2019-11-27 23:19:35
I'm a newbie Cocoa developer and I'm developing my first application. I want to read a unique identifier from any window of any application - whether it's Cocoa or Carbon. Cocoa applications make their window IDs available to AppleScript (although I'm sure there's a much better way to do this through a proper Objective C route), but I'm trying to access window IDs from documents in the Adobe apps. This seems to be a lot trickier. All I can seem to find in the reference libraries is HIWindowGetCGWindowID : "This function returns the window ID assigned by the window server when a window is

How can I determine the running Mac OS X version programmatically?

余生颓废 提交于 2019-11-27 21:25:12
I have a program which needs to behave slightly differently on Tiger than on Leopard. Does anybody know of a system call which will allow me to accurately determine which version of Mac OS X I am running. I have found a number of macro definitions to determine the OS of the build machine, but nothing really good to determine the OS of the running machine. Thanks, Joe Nik Reiman See this article here But in short, if you're using carbon, use the Gestalt() call, and if you're using cocoa, there is a constant called NSAppKitVersionNumber which you can simply check against. Edit : For Mac OSX 10.8

Controlling OSX windows

*爱你&永不变心* 提交于 2019-11-27 20:05:46
问题 I'm trying to control windows of a foreign OSX applications from my application. I'd like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window of the application 4. get the currently active window. (And I'd like to do this either through ObjC/C/C++ apis). What are the API calls that I should be looking for, considering that I have the CGWindowIDs of the windows that I want to control? That is, I'd expect to find functions with

Global modifier key press detection in Swift

荒凉一梦 提交于 2019-11-27 15:09:03
问题 I'm trying to use Carbon's function RegisterEventHotKey to create a hotkey for when the command key is pressed. I'm using it like so: InstallEventHandler(GetApplicationEventTarget(), handler, 1, &eventType, nil, nil) RegisterEventHotKey(UInt32(cmdKey), 0, hotKeyID, GetApplicationEventTarget(), 0, &hotKeyRef) However, it doesn't call handler when I only use the command key. The handler is called if I replace cmdKey with any other non-modifier key code. Does anyone have any suggestions that

Displaying file copy progress using FSCopyObjectAsync

故事扮演 提交于 2019-11-27 13:18:03
问题 It appears after much searching that there seems to be a common problem when trying to do a file copy and show a progress indicator relative to the amount of the file that has been copied. After spending some considerable time trying to resolve this issue, I find myself at the mercy of the StackOverflow Gods once again :-) - Hopefully one day I'll be among those that can help out the rookies too! I am trying to get a progress bar to show the status of a copy process and once the copy process

How to detect whether an OS X application is already launched

折月煮酒 提交于 2019-11-27 12:20:10
问题 Normally an application bundle on OS X can only be started once, however by simply copying the bundle the same application can be launched twice. What's the best strategy to detect and stop this possibility? On Windows this effect can simply be achieved by the application creating a named resource at launch and then exit if the named resource can't be created, indicating that another process is running that has already created the same resource. These resources are released in a reliable way

How can Mac OS X games receive low-level keyboard input events?

怎甘沉沦 提交于 2019-11-27 10:34:06
问题 Games need low-level access to keyboard input. On Windows, there's DirectInput. But what technology do Mac OS X game developers use? Obviously, there's enough Mac games which get keyboard input just right, without the drawbacks of the commonly known solutions: Solution #1: Use keyUp / keyDown events -(void)keyUp:(NSEvent*)event; -(void)keyDown:(NSEvent*)event; Inacceptable drawback: keyDown events are repeated based on the system preference settings for "key repeat rate" and "key repeat delay

Get real path of application from pid?

核能气质少年 提交于 2019-11-27 10:22:42
问题 How can I get the process details like name of application & real path of application from process id? I am using Mac OS X. 回答1: It's quite easy to get the process name / location if you know the PID, just use proc_name or proc_pidpath. Have a look at the following example, which provides the process path: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <libproc.h> int main (int argc, char* argv[]) { pid_t pid; int ret; char pathbuf[PROC_PIDPATHINFO

Programmatically check if a process is running on Mac

限于喜欢 提交于 2019-11-27 06:50:50
Is there any Carbon/Cocoa/C API available on Macs that I can use to enumerate processes? I'm looking for something like EnumProcesses on Windows. My goal is to check from code whether a process is running (by name). Thanks! Here are some specific implementations and details, note that proc->kp_proc.p_comm has a character length limit that's why I'm implemented infoForPID: instead Cocoa : [NSWorkspace launchedApplications] (10.2+ , deprecated in 10.7, very limited process listing) [NSWorkspace runningApplications] (10.6+ , less limited process listing but still not including daemon processes)