?
Solved

QT equivalent for SendInput from Windows API

Posted on 2012-09-05
7
Medium Priority
?
1,594 Views
Last Modified: 2012-09-06
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
0
Comment
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:irfan_omair
ID: 38369808
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.
0
 
LVL 10

Author Comment

by:Christian de Bellefeuille
ID: 38369843
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?
0
 
LVL 7

Accepted Solution

by:
irfan_omair earned 2000 total points
ID: 38370407
VNC type application Okay so eventually you are doing IPC from viewer to server or vice versa, You can implement own  function like globalSendInput() using QTcp or UDP what ever you are using. to send the mouse and keyboard event to other side. Same as exactly how VNC does
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Author Comment

by:Christian de Bellefeuille
ID: 38372309
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.
0
 
LVL 7

Expert Comment

by:irfan_omair
ID: 38372699
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
0
 
LVL 10

Author Closing Comment

by:Christian de Bellefeuille
ID: 38372803
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
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question