tags:

views:

156

answers:

2

Hey guys, I am trying do write an application(server) which receives the keyboard instructions from the client and execute them on the server end. It's more like those screen recorders which records your keyboard and mouse events and replay them. For example, you pull up a textedit on the server, type whatever you like on the client and you can see those letters on the server.

I have no clues what materials I should look into, any suggestions?

+1  A: 

Ok, the way I see it there's a lot of technology involved in this stack.

I've done the first (pain in the rear to figure out, but once you have it it's not too bad), and a little work with the third item (although that is some really deep mojo). The second one is actually probably the easiest (solvable perhaps with the MYNetwork framework, or by classes built-into Cocoa.)

RyanWilcox
Why did you need to drop down to IOKit for capturing key presses? Why not just use a `CGEventTap`?
Rob Keniger
Ahhh - good point. So you'd need IOKit if you wanted your server application to be in the background and recording events while other applications were frontmost. If having the server app frontmost is an OK requirement then yes, CGEventTap would work fine. I forgot about the foreground option, because one of my apps for a client (that does this same sort of thing) needs to work in the background. I've added a link to CGEventTap in my answer
RyanWilcox
+1  A: 

You can use CGEventTap to record events at a fairly low level, and to inject events into the event stream. I have used this for recording and playing back a series of events for testing sometimes.

If you are writing the applications in cocoa, you can implement the sendEvent: method of a custom NSApplication to record all events sent to your application. If the server is also cocoa you can use the same sendEvent: method to process some events.

You can also look at CGRemoteOperation for posting events. It was deprecated by CGEventTap but is simpler to use.

drawnonward
I would if it would work out for the server since the server is run background