AXUIElementPostKeyboardEvent - not sending key presses to Safari/TextEdit in Lion
AXUIElementPostKeyboardEvent - not sending key presses to Safari/TextEdit in Lion
- Subject: AXUIElementPostKeyboardEvent - not sending key presses to Safari/TextEdit in Lion
- From: Patrick Robertson <email@hidden>
- Date: Wed, 16 Nov 2011 18:51:14 +0000
Hi all,
I've upgraded to Lion, and my app which sends simulated keyboard presses to
various apps to activate a service cannot send these keyboard presses to
Safari or TextEdit. The keyboard presses are still sent correctly to Xcode,
Finder and Mail. I have also confirmed that they still work fine for Safari
and TextEdit on Snow Leopard.
Has anybody else come across this problem?
Below is a snippet of my code, and attached [1] is a test app I made that
sends ⌘N to various apps.
Please not that
a) the attached code was thrown together in a few minutes, and is not very
elegant
b) I cannot use CGEventCreateKeyboardEvent as I need to send the keyboard
presses to an app other than the front app
pid_t pid = **some pid, verified to be right**
AXUIElementRef app = AXUIElementCreateApplication (pid);
// Simulating a CMD ESC keypress
AXUIElementPostKeyboardEvent (app, (CGCharCode) 0, (CGKeyCode)55, true );
//Command
AXUIElementPostKeyboardEvent (app, (CGCharCode) 0, (CGKeyCode)53, true );
//Escape
AXUIElementPostKeyboardEvent (app, (CGCharCode) 0, (CGKeyCode)53, false );
//Escape
AXUIElementPostKeyboardEvent (app, (CGCharCode) 0, (CGKeyCode)55, true );
//Command
CFRelease( app );
[1] http://dl.dropbox.com/u/34827/KeyboardPress.zip
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden