Is it possible to simulate the actions of a mouse from a program in OS X? Specifically, the short version is that I'm trying to simulate a touchscreen using two webcams. So assuming I can get X,Y positions, can I send information to the OS as a mouse movement or click?
Edit- Or if it's particularly easy in another operating system I'd be willing to consider that.
Yes, it is possible. You can use the Quartz Event Services to simulate input events.
Assuming C, I wrote this quick example:
And assuming GCC, compile with:
gcc -o program program.c -Wall -framework ApplicationServices
Enjoy the magic.
Swift
mouse move and click example:If you don't want to compile things and are looking for a shell-based tool, Cliclick may be the solution.
Here is a working C program based on jweyrick's answer:
Hosted at https://gist.github.com/Dorian/5ae010cd70f02adf2107