macos-carbon

Apple Events to Control Mouse Remotely

你。 提交于 2019-12-21 12:44:14
问题 I'm not even sure where to begin with this question... I want to be able to send mouse-click events to another machine, as if the user had clicked on that machine. I can do it on the same machine via: CGEventSourceRef source = CGEventSourceCreate(NULL); CGEventType eventType = kCGEventLeftMouseDragged; CGPoint mouseCursorPosition; mouseCursorPosition.x = point.x; mouseCursorPosition.y = point.y; CGMouseButton mouseButton = kCGMouseButtonLeft; CGEventRef mouseEvent = CGEventCreateMouseEvent (

CGEventTapCreate breaks down mysteriously with “key down” events

人盡茶涼 提交于 2019-12-21 04:52:25
问题 I'm using CGEventTapCreate to "steal" media keys from iTunes when my app is running. The code inside of the callback that I pass to CGEventTapCreate examines the event, and if it finds that it's one of the media keys, posts an appropriate notification to the default notification center. Now, this works fine if I post a notification for the "key up" event. If I do that for "key down" events, eventually my app stops getting media key events and iTunes takes over. Any ideas on what can be

Set non-owned window always on top - Like the app “Afloat”

社会主义新天地 提交于 2019-12-21 03:46:46
问题 I have set up a global hotkey with RegisterEventHotkey . When the user presses it, it gets the currently focused window with CGWindowListCopyWindowInfo , and then I need to set it always on top. If the current window is in my process (from which I am executing the code) I can simply convert the windowNumber from CGWindowListCopyWindowInfo to a NSWindow and do setLevel : nswin = [NSApp windowWithWindowNumber:windowNumber] [nswin setLevel: Int(CGWindowLevelForKey(kCGFloatingWindowLevelKey))] My

How to programmatically simulate a mouse click without moving mouse in Cocoa

心已入冬 提交于 2019-12-21 02:04:08
问题 I am interested in simulating a mouse click event/keyboard stroke on Mac OS X without actually moving the mouse. In Windows, it is possible to do this using messages: win32: simulate a click without simulating mouse movement? Is there an analog of this for Mac OS X? I am aware of Quartz Event Services, but it seems that that API would only restrict me to sending events to the current key window. Is this true? Is it possible to send keyboard/mouse events to non-key windows? I really just need

How to programmatically simulate a mouse click without moving mouse in Cocoa

南笙酒味 提交于 2019-12-21 02:04:04
问题 I am interested in simulating a mouse click event/keyboard stroke on Mac OS X without actually moving the mouse. In Windows, it is possible to do this using messages: win32: simulate a click without simulating mouse movement? Is there an analog of this for Mac OS X? I am aware of Quartz Event Services, but it seems that that API would only restrict me to sending events to the current key window. Is this true? Is it possible to send keyboard/mouse events to non-key windows? I really just need

Cocoa switch focus to application and then switch it back

回眸只為那壹抹淺笑 提交于 2019-12-20 09:55:25
问题 I want to create OS X application which shows up and getting focused with system-wide hotkey, and then, with same hotkey it should dissapear and switch focus back . Just like Alfred does it. The problem is that I can't focus back on application previously used. By focusing back I mean that I can't continue typing in previous app. Here is my hotkey handler: OSStatus OnHotKeyEvent(EventHandlerCallRef nextHandler,EventRef theEvent, void *userData) { AppDelegate *me = (__bridge AppDelegate*)

How to remove NSMenuItem gap above custom view

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 07:14:23
问题 I was looking for something discussed in following posts. Gap above NSMenuItem custom view. Reverse engineering an NSMenu for a Status Bar Item I tried the carbon code provided by Pierre Bernard initially, i was getting same error "EXC_BAD_ACCESS on the line InstallControlEventHandler" like other had. I play with the code lots and accidently found the solution. I have just replaced the InstallControlEventHandler function call to HIViewInstallEventHandler and everything is working fine. Hope

How to get other application to paste from my global hotkey

十年热恋 提交于 2019-12-20 06:26:47
问题 I have written a small productivity tool that does a few string manipulations via the clipboard. It is currently registering a hot key, where it pulls in the clipboard text, processes it, and dumps the result back on the clipboard. I have this installed on CMD+SHIFT+V currently what you need to do from another apppiclation is copy (CMD+C) and then activate my hothandler (CMD+SHIFT+V), and then you have to paste it back into the orginal app with (CMD+V). I'd like to eliminate the third step if

Replacing CMNewProfileSearch with non-deprecated, 64-bit code

六月ゝ 毕业季﹏ 提交于 2019-12-20 04:28:14
问题 I have existing code that uses CMNewProfileSearch to find then iterate over the color profiles on the system getting their names and full paths. Unfortunately, CMNewProfileSearch is deprecated in Mac OS X 10.5 and is also unavailable when compiling a 64-bit application. In reading the ColorSync Manager 2.5 Reference, it seems like the new way to iterate over installed color profiles is to use the CMIterateColorSyncFolder function. Is that true? Is there a Cocoa way to do what I want instead?

FSEvents weirdness on OS X Leopard

痞子三分冷 提交于 2019-12-20 03:30:34
问题 I want to monitor file-system events for a couple of directories on the mac. The directories I want to monitor might change at runtime, so using FSEvents here's what my app does: creates a global callback function to handle callbacks create a new FSEventStreamRef per folder, associating it with the callback created above and adding a context to the eventStream that helps me associate the change callback with this folder Stuff seems to mostly work, but I've noticed some weirdness in when the