Mac32API.so ?
-
Hi all,
Is there a library for MAC that could help us find an instance of an application window, its size, position, bring it to front, etc. on a MAC? All this can be done on a PC through Win32API.so. Is there something similar on MAC?Tomasz
-
I have this OSX 'code snippet' from somewhere - perhaps there's something you can extract from it...
struct kinfo_proc *result, *ptr; int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 }; size_t length, i; result = NULL; length = 0; if (sysctl((int *) name,(sizeof(name) / sizeof(*name)) - 1,NULL,&length,NULL,0) == -1) { /* error */ }; if ((result = (kinfo_proc *) malloc(length)) == NULL) { /* error */ }; if (sysctl((int *) name,(sizeof(name) / sizeof(*name)) - 1,result,&length,NULL,0) == -1) { /* error */ }; for (i = 0, ptr = result; (i < (length / sizeof(kinfo_proc)); ++i, ++ptr) { // ptr->kp_proc.p_pid contains the pid // ptr->kp_proc.p_comm contains the name } free(result);
-
@TIG .. looks like C code to enumerate the processes returning pid and name. Similar to MS tlist.exe utility on Windows.
@Tomasz .. There are two libraries on Mac: Cocoa and Carbon, there are Ruby 'interfaces' to them.
I've seen Ruby code that had "require 'Cocoa'" or similar at the top.
The calls are not the same as Win32 (naturally.) The Apple Developer website has information. The problem is finding what you need in all that information. -
@ Dan - I will investigate Cocoa.
@ Tig - Thanks for the C snippet. -
Here's some related info:
http://forums.sketchucation.com/viewtopic.php?p=66969#p66969
Advertisement