Hello. I want to intercept key to my program even if it is non active. I'am working on linux machine(ubuntu)..what should i use to do this?
Hello. I want to intercept key to my program even if it is non active. I'am working on linux machine(ubuntu)..what should i use to do this?
you mean like for a keylogger?
Ok, for educational purposes, let's just say that what you want to do is OS-dependant, and its difficulty varies depending on whether you want to intercept or interrupt keyboard strokes.
I'l also give you a hint about logging keys in Windows: GetKeyState , GetAsyncKeyState & GetKeyboardState
Devoted my life to programming...
Plus, it would probably require root access for your program, or very lax permissions on the appropriate input devices, or being part of an administrative group with access to those devices. Giving any program you write such access on a system is a really bad and silly idea. Distributing such a program is even worse.
And, to be honest, of course you don't have malicious intent. No. Of course. And there aren't a million and one other things you could do first before you leap into device intervention. No. Of course.
Hint: If you have permission to do that on the machines you want to do it on, go look through the specification of HID devices and their device nodes in Linux. That'll tell you everything you need to know. If you want a one-click "I get all the keystrokes on this secure machine even without having to do anything", then - pretty much - forget it. There's a reason it's secured and only certain programs have permission to play with input devices. The kind of reason you're trying to create. And if you have that sort of access to the machine (e.g. a virtual machine for testing), you could just change those permissions so that it did work anyway.
(If you haven't guessed, we aren't going to help you much without you getting off your backside and saying what you've tried, why it failed, what you plan to do next, where you're stuck, show us your code, etc.)
- Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
- A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
- The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.