Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a custom device attached to a computer via FTDI/USB. I can write a program that receives data from the device. What I need to be able to do is make a program that can then act as a keyboard, and allow it to send keys to whatever program is specified. In a way, it is similar to the "SendKeys" API however I have tested this and found it to be incredibly unreliable, especially for full screen programs.

I have searched the internet and I really cannot find any information about this. Does anyone have any experience/knowledge/links relating to this?

Thanks!

Note: Just to be clear, no, I am not making some kind of on screen virtual keyboard. I need the program to actually act as a keyboard.
Posted
Comments
Sergey Alexandrovich Kryukov 18-Aug-12 13:53pm    
I understand. Just a note: such thing on Windows and Linux will be totally different work; this is very low level stuff.
--SA

1 solution

Let me answer only about Windows side.

If you managed to develop driver work and are ready to send key input, please understand that SendKeys is not good at all. On Windows, you really need to use one API which performs generation of events from user input exact same way as hardware drivers do. This is SendInput:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx[^].

The real hardware actually used to use keybd_event and mouse_event, but you should not use these functions, they are both superseded by SendInput:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646304%28v=vs.85%29.aspx[^].

Sorry, I have little idea on how this is done on Linux. But Linux is very open; hope you will find it.

Good luck,
—SA
 
Share this answer
 
v2
Comments
pasztorpisti 18-Aug-12 14:23pm    
5ed, on linux I know there is an X api call for X window to simulate a key press event: http://linux.die.net/man/3/xtestfakekeyevent
It might work, might not work. I have not much experience in programming linux drivers but maybe the OP should go in that direction.
Sergey Alexandrovich Kryukov 18-Aug-12 14:30pm    
Thank you.
I would post this link in your separate answer, for OP to try out.
Teamwork! ;-)
LloydA111 18-Aug-12 15:04pm    
Thanks for the help there! MSDN never seems to come up in Google search, which is probably why I never found it. Thanks again though, I will look into it.
Sergey Alexandrovich Kryukov 18-Aug-12 17:04pm    
Somehow I always find appropriate MSDN articles via Google, but I might miss something else myself.
Please consider accepting the answer formally (green button).
I had a good use of this API, testes its functionality quite well -- this is exactly what you need in Windows.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900