Re: Cocoa-dev Digest, Vol 1, Issue 262
Re: Cocoa-dev Digest, Vol 1, Issue 262
- Subject: Re: Cocoa-dev Digest, Vol 1, Issue 262
- From: Benjámin Salánki <email@hidden>
- Date: Thu, 11 Nov 2004 19:32:36 +0100
Thank you, this does the trick. Looks like i'll need to put a note into
the manual of my app that some parts won't function while "Secure
Keyboard Entry" is enabled.
Thanks for the help!
ben
Message: 4
Date: Thu, 11 Nov 2004 09:14:30 -0600
From: "Jonathan 'Wolf' Rentzsch" <email@hidden>
Subject: Re: CGPostKeyboardEvent strangeness
To: <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset="iso-8859-1"
Salánki Benjámin, email@hidden, wrote:
The problem arises when I try to mix these two functions, so when I
press my hotkey combo I want to use the CGPostKeyboardEvent functions.
But here's what happens: I press my key combo and everything works
fine. I press it again, and nothing happens!! I press it a third time,
works like a charm, press it a fourth time, nothing again, and so
on!!!
Are you attempting to post keystrokes immediately within your hot key
handler? If so, put this code in your handler, prior to any calls to
CGPostKeyboardEvent():
long ignored;
while( AnyKeyDown() ) {
Delay(6, &ignored); // tenth of a second
}
Where AnyKeyDown() is defined as:
static BOOL AnyKeyDown() {
const UInt32 kCapsLockBit = 0x02L;
KeyMap keys;
GetKeys( keys );
return keys[0] || (keys[1] & ~kCapsLockBit) || keys[2] || keys[3];
}
Basically, you're waiting for the user to stop pressing any keys before
you attempt to type anything. I've found attempting to type while the
user is pressing the key results in behavior like what you're seeing.
Keep in mind this will fail if "Secure Keyboard Entry" is enabled in
Terminal.app:
<http://rentzsch.com/macosx/terminalSecureKeyboardEntry>
In this case, I know of no work-around.
| Jonathan 'Wolf' Rentzsch http://rentzsch.com
| Red Shed Software http://redshed.net
| "better" necessarily means "different"
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden