How to detect ANY keyboard activity?

Windows specific forum
Seymour Clufley
Addict
Addict
Posts: 1266
Joined: Wed Feb 28, 2007 9:13 am
Location: London

How to detect ANY keyboard activity?

Post by Seymour Clufley »

I could run a For..Next loop going through all the VK codes with GetASyncKeyState, but is there a simpler way to find out if ANY keys have been pressed?

I don't actually need to know what the keys are, you see, I just need to know if the user is typing.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

Add a callback procedure and check for #WM_KEYDOWN.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

#PB_Key_All ?
PB 4.30

Code: Select all

onErrorGoto(?Fred)
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

A keyboard hook with WH_KEYBOARD could be a solution.
When the dll catch a message, you (the dll) can then send a msg to your app.
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Code: Select all


OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))


Repeat
  Select WaitWindowEvent()
    Case #WM_KEYDOWN, #WM_KEYUP
      Debug "Type, type"
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver


User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

AND51 wrote:#PB_Key_All ?
+1 (see doc for KeyboardPushed), only for directx apps
Seymour Clufley
Addict
Addict
Posts: 1266
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Post by Seymour Clufley »

Thank you all for your advice.
hardfalcon
User
User
Posts: 89
Joined: Fri Apr 29, 2005 3:03 pm
Location: Luxembourg
Contact:

Post by hardfalcon »

Have a look at lowlevel keyboard hooks. There's some example code in the code archive, too...
"And God caused a deep sleep to fall upon Adam, and he slept: and he took one of his ribs, and closed up the flesh instead thereof; And the spare rib, which God had taken from man, made he a woman, and brought her unto the man"
Post Reply