How to detect key press from outside of Qt program ?
-
Yes something like that. But i actually don't need to know which key has been pressed, but i just need to get informed that a key has been pressed.
-
You can use the system API libraries but your solution will not be portable and highly platform specific. I might be wrong but I think windows provides libraries with components that allow you to create handless to low level, system scale events. If you plan on doing it in windows you might want to dig around in "MSDN":http://msdn.microsoft.com
-
Yes, I don't need to make it portable. But i am ignorant about the usage of Windows API. If i want to use that API in Qt what should i do? would you kindly suggest me something ?
-
-
-
hi Aseramanca,
How could i add the API while I am using Qt SDK 1.1.3 ?
Or, the necessary API is already added ?
What is the headerfile i have to add ?
Never mind I am a newbie in this sort of programming.Thank you.
-
The necessary header files are mentioned in the documentation of the specific functions. I have done most of my API work in other languages, so I can't give you a working solution for Qt SDK. But in general, you need the header files at compile time, and a DLL at run time. You might need to get a Windows SDK for the former, the latter should be on your system already.
-
Hi,
if you are using MSVC tool chain, it is all there.
In mingw, I hope it is also, but I can't guarantee.Windows API can just be used as any other API. Includ ethe needed headers, call the methods, add the needed libraries to the linker in qmake files.
What you need from the API is the system hooks stuff.
-
bq. What you need from the API is the system hooks stuff.
Not in this use case. MS recommends using RawInput as replacement for Hooks in all use cases where this is possible.
Hooks increase the load on the kernel stacks, which can lead to strange and hard-to-track effects, if too many programs use them. Also, starting with Windows 7, hooks can be silently removed if they take too long to respond. Therefore, you cannot reliably use hooks to detect user input (well, it's one of those things that's probably going to work 98 % of the time, but still).
-
I have seen some examples of hook somewhere, But I don't know about RawInput which seems to work better as your suggestion. Would you kindly post a snippet or a link so that i can learn about RawInput.
Thank you.
[quote author="Asperamanca" date="1331627603"]bq. What you need from the API is the system hooks stuff.
Not in this use case. MS recommends using RawInput as replacement for Hooks in all use cases where this is possible.
Hooks increase the load on the kernel stacks, which can lead to strange and hard-to-track effects, if too many programs use them. Also, starting with Windows 7, hooks can be silently removed if they take too long to respond. Therefore, you cannot reliably use hooks to detect user input (well, it's one of those things that's probably going to work 98 % of the time, but still).[/quote]
-
MSDN is a good starting point:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645536(v=vs.85).aspx
In "using raw input", there are a few examples.