I'm not even sure where to begin with this question...
I want to be able to send mouse-click events to another machine, as if the user had clicked on that machine.
I can do it on the same machine via:
CGEventSourceRef source = CGEventSourceCreate(NULL);
CGEventType eventType = kCGEventLeftMouseDragged;
CGPoint mouseCursorPosition;
mouseCursorPosition.x = point.x;
mouseCursorPosition.y = point.y;
CGMouseButton mouseButton = kCGMouseButtonLeft;
CGEventRef mouseEvent = CGEventCreateMouseEvent ( source,
eventType,
mouseCursorPosition,
mouseButton );
CGEventSetType(mouseEvent, kCGEventLeftMouseDragged); // Fix Apple Bug
CGEventPost( kCGSessionEventTap, mouseEvent );
CFRelease(mouseEvent);
But how do I send that event somewhere else? Applescript? I've read some stuff with AppleEvents being app-app communication, but I'd like to just generate a system event on another machine?
Totally unsure.
Thanks,
[Edit 11/1/10 7:30a]
Just to clarify, I'm not looking to screen share. At least I don't think so. I've got a cluster of several mac pros linked together, each has like 4 monitors. I'm trying to use only 1 device to communicate "clicks" to each of the nodes. So if the device is over node 3, but the device is plugged into node0, node0 needs to tell node 3 that it needs to respond to a click.
Thanks,
[Edit 11/4/10 9:32am]
Really? Nobody can give me a concrete code example of generating Apple Events Programmatically to create mouse events on remote machines in C/C++/Objc-C???
As I understand it, you can use Distributed Objects to pass the Apple Events along.
They can work across the network via Bonjour. You could serialise or encode an Apple Event pass it across the network then have a helper app running on the machine at the other end to listen for, decode the Event and run it. You may just want to encode the coordinates of the mouse click for simplicity.
I also believe Marcus Zarra's book on Core Data has the sample code for a Core Data app running over a network which uses DO. You might be able to see what he's done and do something similar to get you started. See also this excellent Q&A on DO by Mike Ash.
the "System Events" "application" (just a process in reality) allows to send events using applescript:
tell application "System Events"
tell process "Finder"
click at {10, 10}
end tell
end tell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With