• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AXUIElementPostKeyboardEvent - not sending key presses to Safari/TextEdit in Lion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: AXUIElementPostKeyboardEvent - not sending key presses to Safari/TextEdit in Lion
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Re: Quick validation of an audio file?
  • Next by Date: awakeFromInsert called twice with nested contexts
  • Previous by thread: Re: Quick validation of an audio file?
  • Next by thread: Re: AXUIElementPostKeyboardEvent - not sending key presses to Safari/TextEdit in Lion
  • Index(es):
    • Date
    • Thread