aspose file tools*
The moose likes C / C++ and the fly likes How to read keyboard when program is out of scope using C language? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "How to read keyboard when program is out of scope using C language?" Watch "How to read keyboard when program is out of scope using C language?" New topic
Author

How to read keyboard when program is out of scope using C language?

Raju Felix
Greenhorn

Joined: Feb 07, 2014
Posts: 4
Hi All,
Please help me in How to read keyboard when program is out of scope using C.

Thanks,
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

Hi Raju - your question does not make sense. You want to read keyboard input when your program has already terminated ?
Raju Felix
Greenhorn

Joined: Feb 07, 2014
Posts: 4
Hi Roger Sterling,
No no, I just want to read the keys which are being pressed when the program is running only, but, Even when I work with another application (eg# a text editor, etc...) while my C program is running in background (i.e, console window is minimized) also, I want to read the keyboard.

Thanks,
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11411
    
  16

you want your program to be able to know what another program is doing? That sounds a little suspicious...


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Luke Leber
Ranch Hand

Joined: Sep 20, 2013
Posts: 41
    
    2

This program is not necessarily suspicious. Many facilities (NIST and other government labs) implement such things on sensitive systems as a security measure. Case in point: It doesn't matter what the OP wants to know this information for.




This would require platform-specific constructs that standard C does not offer. Such an example would be implementing a keyboard hook (in Windows) http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx

I'll leave the implementation details up to you as a learning experience.
Luke Leber
Ranch Hand

Joined: Sep 20, 2013
Posts: 41
    
    2

Roger Sterling wrote:Therefore, some of us refrain from helping answer a query if it appears like the use of the knowledge will be put to ill use.


Others can play judge in cases like this, but I will not lift myself up to the podium.

The best solution to "stop the evil" is to educate end-users about how to avoid exposing themselves to it and aiding system designers in patching security exploits exposed by the "evil".

Attempting to seal "the evil" behind bars is not a secure, or even a sensible solution.



Of course, we could just do like Sun / Oracle did and try to shroud vulnerabilities in a corporate hush, restricting as much dangerous information as possible, but I think we've all seen how that works out in the long-run...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

I suspect most people who are trying to write keystroke loggers and have to post here to ask how aren't aspiring malware writers. After all you can download one from the net after searching for less than a minute, so why bother to write your own? It's more likely that the people asking the question here think they are going to learn something useful from the exercise.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to read keyboard when program is out of scope using C language?