macos-carbon

Is there a way to check if process is 64 bit or 32 bit?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 02:47:58
问题 I am trying to find process type (32 bit/ 64bit) from process pid? I get the process information and process list from using GetBSDProcessList method described here. how can we get the process type information? Any Ideas? I can use defined( i386 ) or defined( x86_64 ) but only if we are in process. I am out of the process. 回答1: GetBSDProcessList returns a kinfo_proc . The kinfo_proc has a kp_proc member which is of type extern_proc. The extern_proc has a p_flag member, which one of the flags

Simulating key press events in Mac OS X

夙愿已清 提交于 2019-11-27 01:29:39
I'm writing an app where I need to simulate key press events on a Mac, given a code that represents each key. It seems I need to use the CGEventCreateKeyboardEvent function to create the event. The problem is that this function needs a Mac keycode, and what I have is a code that represents the specific key. So, for example, I receive: KEY_CODE_SHIFT or KEY_CODE_A - these are both numeric constants defined somewhere. I need to take these constants and turn them into CGKeyCode values. My current attempt uses code similar to this SO question . The problem is that it only works for printable

Getting Window Number through OSX Accessibility API

旧巷老猫 提交于 2019-11-27 00:37:45
问题 I am working on an application that moves windows of third party applications around on the screen. To get an overview of all currently open windows, I use CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID); This returns an array of dictionaries defining every open window. Here's an exemplary dictionary returned: { kCGWindowAlpha = 1; kCGWindowBounds = { Height = 442; Width = 475; X = 3123; Y = "-118"; }; kCGWindowIsOnscreen = 1;

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

安稳与你 提交于 2019-11-26 23:02:56
问题 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 回答1: 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

Programmatically check if a process is running on Mac

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 12:12:18
问题 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! 回答1: 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)

How do I determine the OS version at runtime in OS X or iOS (without using Gestalt)?

旧时模样 提交于 2019-11-26 12:10:27
The Gestalt() function located in CarbonCore/OSUtils.h has been deprecated as of OS X 10.8 Mountain Lion. I often use this function to test the version of the OS X operating system at runtime (see the toy example below). What other API could be used to check the OS X operating system version at runtime in a Cocoa application? int main() { SInt32 versMaj, versMin, versBugFix; Gestalt(gestaltSystemVersionMajor, &versMaj); Gestalt(gestaltSystemVersionMinor, &versMin); Gestalt(gestaltSystemVersionBugFix, &versBugFix); printf("OS X Version: %d.%d.%d\n", versMaj, versMin, versBugFix); } On OS X 10

Simulating key press events in Mac OS X

ⅰ亾dé卋堺 提交于 2019-11-26 09:38:00
问题 I\'m writing an app where I need to simulate key press events on a Mac, given a code that represents each key. It seems I need to use the CGEventCreateKeyboardEvent function to create the event. The problem is that this function needs a Mac keycode, and what I have is a code that represents the specific key. So, for example, I receive: KEY_CODE_SHIFT or KEY_CODE_A - these are both numeric constants defined somewhere. I need to take these constants and turn them into CGKeyCode values. My