Detect keypress outside of program


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Detect keypress outside of program

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Detect keypress outside of program

    [Originally posted by Erik L.]

    Hi!

    I have a problem... I want to be able to detect a keypress outside of my own program. If my program's minimized and the user presses F12 for instance, my program should go to normal state or something like that.

    /Erik

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Detect keypress outside of program

    [Originally posted by Mikekay2]

    Use the GetAsyncKeystate function:

    Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer

    If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. The return value is zero if a window in another thread or process currently has the keyboard focus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center