Click here to Skip to main content
15,889,632 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have to develop a client server application in c++ that must be able to to send command(ctrl/alt/shift,followed by a/b/...1/2/3) from server to an application that is actually in focus.

What I have tried:

I made only a client server but not the control command for the application in the server from the client
Posted
Updated 13-Mar-17 22:23pm

Quote:
I made only a client server but not the control command for the application in the server from the client
Well, no one prevents you in doing that.
If you have the client and the server and they are able to communicate, the next step is simple: send the 'commands' based on a simple protocol, and in the other side interpretate and execute them, giving feedback as appropriate. What is the hurdle, then?
 
Share this answer
 
Comments
Member 12891988 14-Mar-17 4:49am    
Thanks for your reply.
I do not know how I can send a command(ctrl+c for example) from client to the server.
I know how send a buffer of char or string but I do not know how I can send a combination of key from keyboard.
CPallini 14-Mar-17 5:23am    
What's wrong in sendig the CONTROL key code (0x11) followed by the 'C' one (0x43)?
Member 12891988 14-Mar-17 5:59am    
I do not know how to send a command from keyboard to interact with process on focus.
For example: I have in the server side machine firefox opened and when I press ctrl*f from my keyboard a searching bar was opened.
So I would do the same thing, but pushing ctrl+f from my client machine and open searching bar in firefox installed on server machine.
I just want to use command from my keyboard to interact with a window application.
and after I do not push enter or send,I only want that: if I push ONLY ctrl server must receive it, if i push ctrl+f server must receive it and so on.
CPallini 14-Mar-17 6:16am    
Well, then you have to just intercept keystrokes on the client application and send them to the server. How to do that depends on your OS. On Windows you may look at the very documentation:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646268(v=vs.85).aspx
Member 12891988 14-Mar-17 10:31am    
Thank you so much for your help.
I will try.
Regards
You can use a two channel communication. Once a connection has been established the server can create a new connection to the client to send the commands. In this scenario (and code implementation), the server acts now as client and your application as server (when your client opens a connection it creates another listening socket to handle commands from the server).
 
Share this answer
 
Comments
Member 12891988 18-Mar-17 6:57am    
Hi,I need one more advise, I am aware that there are ways to check if a process is already running (via enumeration). However, I was wondering if there was a way to listen for when a process starts and ends (for example, notepad.exe) and then perform some action when the starting or ending of that process has been detected. I assume that one could run a continuous enumeration and check loop for every marginal unit of time, but I was wondering if there was a cleaner solution.
Thancks in advance
Regards

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