KeyHit() when AppSuspended()?
BlitzMax Forums/BlitzMax Programming/KeyHit() when AppSuspended()?
| ||
Is it possible, in any way, via maybe win32 functions, to have a BlitzMax application detect input from the keyboard, even though the application is not active? Asking because I want to make a small program that has to have "global" windows shortcuts. |
| ||
Surely someone must have an idea if this is possible or not? |
| ||
Yes it is possible through WinAPI |
| ||
What, like a keylogger? You naughty boy! |
| ||
I suppose it could be used for a keylogger yes, but that's not my purpose. I want to make a small app that runs in the background, enabling multiple clipboards. |
| ||
getasynckeystate() had what I needed :) Now I've got another stupid question.. Is it possible to draw anything directly onto the desktop/over active windows? Sort of like a superlayer on top of everything (look at control panel > display > settings > identify monitors - the numbers showing there, that's what I mean) - and if so, what would be needed to do this? 'prints out keys hit/pressed in win32, irregardles of what is focused Framework BRL.RamStream Import BRL.StandardIO Import pub.win32 Extern "win32" Function GetAsyncKeyState(character) EndExtern Local loop = True While loop Delay 40 For Local i = 8 To 222 Local state = getasynckeystate(i) Select state Case 32767 Print "special key hit: "+Chr(i)+" ("+i+") "+state Case 32768 Print "special key down: "+Chr(i)+" ("+i+") "+state Case -32767 Print "key hit: "+Chr(i)+" ("+i+") "+state If i = 27 Then loop = False Case -32768 Print "key down: "+Chr(i)+" ("+i+") "+state EndSelect Next Wend |
| ||
You need to make a top most window, with a color-transparent key. Both things can be done using WinApi. I can't remember wich apis were, but I did exactly this a long time ago. |
| ||
Lol nice bump ziggy :) But thanks mate, good to know that. |
| ||
This is the winapi declaration to make a windows topmost on visual basic 6. I think it should be easy for you to convert it to BlitzMax. I think Long integers on Visual basic 6 were 32 bits, so you should consider this longs as integers on blitzmax (I think)Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal iWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Const SWP_NOMOVE = 2 Private Const SWP_NOSIZE = 1 Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2 Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE this was a typic call to make a window topmost: SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) to the transparency thing of the window, I think there was a blitzmax sample on the maxgui forum, take a look. |