Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The easiest way? Compile <a href="http://web.archive.org/web/20100328083020/http://www.macosxhints.com/article.php?story=2008051406323031" rel="nofollow noreferrer">this</a> Cocoa app and pass it your mouse movements.</p> <p>Here is the code:</p> <pre><code>// File: // click.m // // Compile with: // gcc -o click click.m -framework ApplicationServices -framework Foundation // // Usage: // ./click -x pixels -y pixels // At the given coordinates it will click and release. #import &lt;Foundation/Foundation.h&gt; #import &lt;ApplicationServices/ApplicationServices.h&gt; int main(int argc, char **argv) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSUserDefaults *args = [NSUserDefaults standardUserDefaults]; // grabs command line arguments -x and -y // int x = [args integerForKey:@"x"]; int y = [args integerForKey:@"y"]; // The data structure CGPoint represents a point in a two-dimensional // coordinate system. Here, X and Y distance from upper left, in pixels. // CGPoint pt; pt.x = x; pt.y = y; // https://stackoverflow.com/questions/1483567/cgpostmouseevent-replacement-on-snow-leopard CGEventRef theEvent = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, pt, kCGMouseButtonLeft); CGEventSetType(theEvent, kCGEventLeftMouseDown); CGEventPost(kCGHIDEventTap, theEvent); CFRelease(theEvent); [pool release]; return 0; } </code></pre> <blockquote> <p>App called click that invokes CGPostMouseEvent from the CGRemoteOperation.h header file. It takes coordinates as command line arguments, moves the mouse to that position, then clicks and releases the mouse button.</p> <p>Save the above code as click.m, open Terminal, and switch to the folder where you saved the source. Then compile the program by typing <code>gcc -o click click.m -framework ApplicationServices -framework Foundation</code>. Don't be intimidated by needing to compile this as there are more comments than code. It is a very short program that does one simple task. </p> </blockquote> <hr> <p>Another way? Import <a href="http://developer.apple.com/cocoa/pyobjc.html" rel="nofollow noreferrer">pyobjc</a> to access some of the OSX framework and access the mouse that way. (see the code from the first example for ideas).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload