Re: Send click to window
Re: Send click to window
- Subject: Re: Send click to window
- From: Nate Weaver <email@hidden>
- Date: Thu, 9 Apr 2009 17:39:53 -0500
There are actually 2 NSEvent methods that aren't in my local docs here
at work, but are in the headers and on developer.apple.com:
+ (NSEvent *)eventWithCGEvent:(CGEventRef)cgEvent;
- (CGEventRef)CGEvent;
10.5-only, though.
On Apr 9, 2009, at 6:24 AM, Dave Keck wrote:
Is it possible to send a simulated mouse click to a specific window,
overlapped by others?
CGEventPostToPSN() is what you want - but unfortunately it looks like
a little hackery will be involved to get it working. NSEvent has a
'windowNumber' property associated with it, but it doesn't look like
CGEvent has anything like that. (Although, I suspect it might, but
that value isn't part of the public API.)
I quickly tested CGEventPostToPSN() and was able to click Safari's
menu bar from my test app, but was not able to click inside Safari's.
I would try converting an NSEvent to a CGEvent (using NSEvent's
-eventRef method). Set the NSEvent's window number in its initializer,
and, with a little luck the windowNumber might find its way into the
CGEvent after the conversion. Again, this assumes CGEvent tracks
windowNumber in the first place, which there's no evidence that it
does.
Also, check out CGEventField. I searched it up and down for something
like kCGEventWindowNumber but, alas, it ain't there. So yeah, maybe
it's part of the private API...
At any rate, if you have trouble getting it working, which looks
likely, try asking about CGEventPostToPSN() on a quartz-dev or
something.
Good luck (and keep us posted!),
David
_______________________________________________
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