Caps Lock etc.
Blitz3D Forums/Blitz3D Userlibs/Caps Lock etc.
| ||
I was searchign the forums to find a means of testing for whether Caps lock or such was on and I found this by Jim Brown in the BMax forums:Extern "win32" Function GetKeyboardState%(pbKeyState:Byte Ptr) End Extern Const VK_CAPITAL = $14 Const VK_NUMLOCK = $90 Const VK_SCROLL = $91 Const VK_INSERT = $2d Global kbstate:Byte[256] Graphics 640,480,0 Repeat Cls GetKeyboardState kbstate DrawText "Caps Lock = "+kbstate[VK_CAPITAL] , 10,20 DrawText "Num Lock = "+kbstate[VK_NUMLOCK] , 10,40 DrawText "Scroll Lock = "+kbstate[VK_SCROLL] , 10,60 DrawText "Insert = "+kbstate[VK_INSERT] , 10,80 Delay 5 Flip Until KeyHit(KEY_ESCAPE) End It looks fairly similar to an effective use of CallDLL or decls files to achieve the same thing in B3D, so I thought I'd have a go myself.. But I am not sure how to use the inbank/outbank parameters for CallDLL. Can anyone help me with this? Const VK_CAPITAL = $14 Const VK_NUMLOCK = $90 Const VK_SCROLL = $91 Const VK_INSERT = $2d While Not KeyDown(1) Print "Caps Lock = "+GetKeyState(VK_CAPITAL) Wend Function GetKeyState(Check) Local bBank=CreateBank(256) Return CallDLL("Win32.dll","GetKeyboardState%()",bBank,Check) End Function |
| ||
Const NUM_LOCK% = $90 Const SCROLL_LOCK% = $91 Const CAPS_LOCK% = $14 Repeat Cls Text 10,10,"NUM_LOCK: "+api_GetKeyState(NUM_LOCK%) Text 10,30,"SCROLL_LOCK: "+api_GetKeyState(CAPS_LOCK%) Text 10,50,"CAPS_LOCK: "+api_GetKeyState(SCROLL_LOCK%) Delay 10 Flip 0 Until KeyHit(1) End ; user32.decls .lib "user32.dll" api_GetKeyState% (nVirtKey%) or: http://www.blitzbasic.com/Community/posts.php?topic=40670 (DJWoodgate) ... just donīt use CallDll anymore since itīs the old way of calling a dll. use .decls instead! greetings, chi |
| ||
Thanks, chi! Incidentally, I had the decls for user32 already! Silly me, I didn't realise this was the actual dll used :) |