0

I'm currently studying socket programming, i'm working on creating an application to use my phone as a wireless keyboard/mouse. My current approach is to have the phone app send messages over wi-fi to an application on the computer which will translate those message to keystrokes, mouse movement, and mouse clicks.

The communication part is not the problem, the problem is once the message gets to the application on the computer, i'm not sure how to turned em into keyboard input/mouse input. I did some research and i found a few examples, but most of them required me to select an application to send the input to. Is there a way to just send the input to whatever the current application is? Also most of the examples i saw where for windows only, and i want my application to work in linux, macOS, and windows.

Do you guys have any suggestion on what i could use? or can you point me in the right direction to better research this.

I'm currently using C++ for the application

Mike Alike
  • 129
  • 2
  • 6
  • If you have to resort to sending it one way per OS (via #ifdefs), `SendInput` is the way to go for windows. – chris Jun 21 '12 at 15:06
  • I cannot provide you an answer, but what is the "current application"? The window currently in foreground on an user screen? Probably, is the application you want to send the input the graphic server? – D. Cannone Jun 21 '12 at 15:15
  • @D.Cannone - Presumably he means "wherever keys would go if I typed them." – Robᵩ Jun 21 '12 at 15:19
  • yes, that's what i meant by current application, wherever keys would go if i pressed them on the physical keyboard. – Mike Alike Jun 21 '12 at 15:24

2 Answers2

0

For Linux, I suggest you inject events into the kernel event subsystem. Look here: http://thiemonge.org/getting-started-with-uinput, specifically in the section "Injecting events in the input subsystem".

Robᵩ
  • 163,533
  • 20
  • 239
  • 308
0

Doing something like this requires communicating with the OS. Each OS has a different API.

In many cases you can use a runtime library / framework that will give you a common interface for this. This framework gives you a common interface, but the core of that interface is actually reimplemented for each OS.

However, I am not sure any framework would provide you with this functionality. It's quite likely you will have to reimplement this functionality for each target OS.

user606723
  • 4,918
  • 2
  • 27
  • 34