Waiting for PrintScreen to be pressed

This is a discussion on Waiting for PrintScreen to be pressed within the Windows Programming forums, part of the Platform Specific Boards category; I've tested using MSDN but I haven't had any luck there. What I want to do is to wait for ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    29

    Waiting for PrintScreen to be pressed

    I've tested using MSDN but I haven't had any luck there.

    What I want to do is to wait for the PrintScreen button( on the
    keyboard ) to be pressed and then do something.

    And I want to do this without eating all the CPU power I can get.

    I've so far been succesfull with stopping the program with this code
    chunk :
    Code:
    #include <windows.h>
    
    int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
    {
       WaitForSingleObject( GetCurrentProcess() , INFINITE );
       return 0;
    
    }
    But now I also want to continuesly check if the button has been
    pressed.

    I heard from someone that I should use the following functions :

    CreateThread
    WaitForMultipleObjects

    SetWindowsHookEx (where I should use a keyboard hook)

    but i don't know how to implement this.

  2. #2
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    do some reading on using SetWindowsHookEx and installing a keyboard hook, there are some good articles on doing stuff like this on codeproject.com, you will need to create a DLL that contains the hook routine and then an exe to start it all off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Check if a key has been pressed and released
    By xkrja in forum Windows Programming
    Replies: 3
    Last Post: 09-19-2006, 09:06 AM
  2. Waiting for a key to be pressed
    By Ne0 in forum C Programming
    Replies: 5
    Last Post: 07-28-2004, 01:07 AM
  3. Replies: 2
    Last Post: 07-25-2003, 03:01 AM
  4. how do you know when enter is pressed?
    By pinkcheese in forum Windows Programming
    Replies: 6
    Last Post: 07-26-2002, 12:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21