Click here to Skip to main content
11,709,529 members (53,928 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ TurboC++ ANSI VC
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 29-Jan-13 6:58am
K4Sh!F103
Edited 29-Jan-13 7:00am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
v3

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 565
1 OriginalGriff 250
2 Maciej Los 225
3 Peter Leow 219
4 Mika Wendelius 160
0 OriginalGriff 9,428
1 Sergey Alexandrovich Kryukov 9,037
2 CPallini 5,189
3 Maciej Los 4,991
4 Mika Wendelius 3,856


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 1 Oct 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100