Thread: Waiting for PrintScreen to be pressed

  1. #1
    Registered User
    Join Date
    Oct 2005

    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 :
    #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

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


    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
    do some reading on using SetWindowsHookEx and installing a keyboard hook, there are some good articles on doing stuff like this on, 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