• 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
pre-jag click-thru-windows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pre-jag click-thru-windows


  • Subject: pre-jag click-thru-windows
  • From: Philip George <email@hidden>
  • Date: Sat, 14 Dec 2002 08:02:33 -0600

i'm trying to write a little snippet of code for us all to use that will allow users of our applications to do the click-thru-window thing in pre-jaguar os x. i'm using (for the moment) CGPostMouseEvent() to create a new click after opening a tiny little hole in the window (100% transparency 1x1 pixel). the hole vanishes directly after posting the new click through it. i can get it to work perfectly, except in the case that the user is trying to begin a drag event. It basically ONLY does clicks, no drags.

the algorithm is as follows:

[01] catch user clicking window in mouseDown: method
[02] use screen geometry and window (and subview(s))
frames(s) to calculate where the click location
should go (in global coordinates)
[03] cut a 1x1, 100% transparent hole in the window
right under the tip of the pointer
[04] generate a new click at the calculated global
coordinates, passing directly thru the hole
[05] redraw the window, closing up the hole

the comments in CGRemoteOperation.h for CGPostMouseEvent() mention dragging, but don't really explain how it's done. There are other APIs which post events that also mention dragging, but i've never used them, so....

anyone who knows how this could be done, please lend a hand. this code will be for everyone to use. I'll probably put a tutorial up somewhere and we can point people to it when they ask. it's a very popular question and an important missing feature.

i think we should be able to click through windows regardless of version of os x the user has installed... period.

below is the documentation in CGRemoteOperation.h for CGPostMouseEvent() mentioned above:

//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

/*
Posting events: These functions post events into the system. Use for remote operation and virtualization. Note that remote operation requires a valid connection to the server, which must be owned by either the root/Administrator user or the logged in console user. This means that your application must be running as root/Administrator user or the logged in console user.
*/

/*
Synthesize mouse events.
mouseCursorPosition should be the global coordinates the mouse is at for the event. updateMouseCursor should be TRUE if the on-screen cursor should be moved to mouseCursorPosition.

Based on the values entered, the appropriate mouse-down, mouse-up, mouse-move, or mouse-drag events are generated, by comparing the new state with the current state.

The current implemementation of the event system supports a maximum of thirty-two buttons. The buttonCount parameter should be followed by 'buttonCount' boolean_t values indicating button state. The first value should reflect the state of the primary button on the mouse. The second value, if any, should reflect the state of the secondary mouse button (right), if any. A third value woule be the center button, and the remaining buttons would be in USB device order.
*/

typedef u_int32_t CGButtonCount;
CG_EXTERN CGEventErr CGPostMouseEvent( CGPoint mouseCursorPosition,
boolean_t updateMouseCursorPosition,
CGButtonCount buttonCount,
boolean_t mouseButtonDown, ... );

//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

also, if this has already been done, please tell me before i waste any more time (and point me to where it is). and if you want to see the code i have so far (not much more than just calling that function really) just say so.

thanks.

- Philip George
PowerPlum Technologies
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Tooltips - what a pathetic joke... :)
  • Next by Date: Breaking
  • Previous by thread: Global keyDown?
  • Next by thread: Breaking
  • Index(es):
    • Date
    • Thread