Link to home
Start Free TrialLog in
Avatar of Christian de Bellefeuille
Christian de BellefeuilleFlag for Canada

asked on

QT equivalent for SendInput from Windows API

I am developping an application with C++ & QT on Windows at the moment (and later on Mac).  

I would like to know if there's an equivalent for SendInput from Windows API.  That mean that the keyboard event must be sent, to the active application, not only my QT application.
ex:  Let's say that Notepad is on top and my application is running in background, i would like to be able to send in the keyboard buffer "Hello World" so the Notepad application grab it, and display it.

Thanks you
Avatar of irfan_omair
irfan_omair
Flag of United States of America image

in case of Note pad example if notepad is active then all key events will go to it, your Qt application wont get it.

If you have Qt app running as daemon then I am sorry there is no API/class in Qt which can do this thing for you , and you will have to do it explicitly using some IPC, may be socket or something.
Avatar of Christian de Bellefeuille

ASKER

Actually, the app we are developing is like VNC.   The viewer type in some stuff, then the same input must be reproduced on server side.  That's why we need "Global SendInput".

Our application on server side doesn't really have any widget, and it must send keyboard input & mouse input to any application just like a local user would do with his mouse & keyboard.

So i guess will have to stay OS Specific.  

Any other people have different opinion about this?
ASKER CERTIFIED SOLUTION
Avatar of irfan_omair
irfan_omair
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BeyondWu, thanks but we are already using SendInput from WinAPI.  

We are looking for a QT equivalent to make our code as portable as possible, to have less changes to program when we will code the Mac version of our software.

I'll wait 1 more day before i close this Question to give some chances to people who could bring a solution that fit our need.
Okay as per the description of send key strok to different application posted by BeyoundWu in MSDN,
"Activate the application window that will receive the keystrokes, and then call the Send or SendWait method. "

You can call Qt's activateWindow() or changeFocus() which will bring the application on top and will make it active to take the mouse/key input , See if this helps

Again if it is alltogether a different application window you have no other way but to send the input via IPC
I think we are getting away from the question and i've got confirmation that Qt doesn't have any mechanism similar to SendInput.

We are not using .NET, it's plain C++ with Qt, so SendWait is not possible.

Thanks for the help you have provided