Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
1.50/5 (4 votes)
Here is what my project does:
Language: C++

Once the system has successfully logged-in, and this software that I am making is made to run or directly at start-up, if the user incidentally presses any of the pre-defined keys, the following function runs
"w" ===> MS Word Document
"b" ===> Default Browser
and more like shutdown, restart and opening MSPAINT, explorer, Calc and all ! ...

Addition Features:
Make the program perform a BIOS Beep that makes the user confused on what is happening.
A similar CHIME RAM BEEP can also be tried to implement.
Random movement of Cursor (to prevent the mouse from being operated)

I need help (advise on how to go about) in :
1. HOW TO READ THE KEYBOARD BUFFER EVEN WHEN MY PROGRAM IS MINIMIZED??
2. How to run System Files using the CLI ??
3. How to BIOS BEEP AND CHIME BEEP ?
Posted
Updated 29-Jan-13 7:00am
v2

1 solution

For #1 - reading the keyboard buffer even when the program does not have the input focus. Use the GetAsyncKeyState function. You will have to code it in a loop and search all scan codes. Be sure to include a call to Sleep for a few milliseconds between each call to GetAsyncKeyState to prevent hogging the CPU.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293%28v=vs.85%29.aspx[^]

The above technique will tell you which keys are de-pressed at any given moment. From that you can infer key events. You will also have to map key scan codes to actual ASCII characters. Example: VK_A is the letter 'A'. The above technique is also limited to the current workstation. If someone switches to a different workstation, key strokes in the other session won't be captured.

For #2 - how to run system files from the CLI. That's a bit vague. Do you want to programmatically start another program? If so, use CreateProcess or ShellExecute. If you want to start something from a command window, type the program name with full path, or type "start" followed by the program name (preferably with the full path).

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx[^]

For #3 - BIOS Beep. Use the MessageBeep function.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms680356%28v=vs.85%29.aspx[^]

For a chime, use the older (but deprecated) Beep function. Make several calls with different pitch and duration.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms679277%28v=vs.85%29.aspx[^]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900