Recently, I was given the unpleasant task of automating actions in such unfriendly apps. I just about went crazy trying to find a way to write a simple script with coordinates for mouse click events.There's nothing available within AppleScript for pushing the mouse around, and I couldn't find any command-line utilities either. Out of necessity, I wrote my own.
This is my first time writing anything that even resembles Cocoa, and my first time writing code that compiles in nearly 10 years. I'm a scripting guy, and I just wanted to be able to write a script. What I wrote is a little command-line 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. I think this could even be modified to click, hold, and drag, but I haven't taken it that far because I don't need to. Here's the source: 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 gcc -o click click.m -framework ApplicationServices -framework Foundation. 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.
I'm sure I'm not the only one out there who needs to script mouse events, so hopefully this will brighten somebody's day. The only gotcha here is that scripts that invoke this will likely break if they are then used on a machine with a different screen size. Such is life when scripting the unscriptable.
[robg adds: You'll need Xcode installed to compile this code, but I've already done that, so here's a pre-built binary for those who want the program but don't have Xcode. Usage is as noted in the comments in the code: click -x 100 -y 200 would move the mouse horizontally 100 pixels and vertically 200 pixels, and then send a mouse click event. I tested it, and it works as described.]

