read external key strokes (key logger)?
BlitzMax Forums/BlitzMax Programming/read external key strokes (key logger)?
| ||
Does anyone know how to read key strokes that are not pressed in my own application. I need to know if a user is AFK, so its not even important to know the exact key that is pressed. |
| ||
The GHotkey stuff in here may be of interest. |
| ||
Wouldn't virus software flag this as dangerous? |
| ||
I think you could even write something that deletes the entire System32 content and virus softwares wouldn't detect it, perhaps only with some high-tech heuristics. It'd be all about the signature. |
| ||
Wouldn't virus software flag this as dangerous? If you use the Windows API (as I have done), no.It's not a particularly good way of 'key logging' though. |
| ||
i'm not actually trying to create a keylogger. I just want to know if a user is AFK. |
| ||
can anyone tell me why this doesn't work with letters and numbers? Only shift, control, enter, backspace etc.Extern "Win32" Function GetAsyncKeyState:Int(vKey:Int) EndExtern Global state% = 0 Repeat state% = checkGlobalKeys() If state% DebugLog(state + ": A KEY PRESSED!" + Rand(1000, 9999)) EndIf Forever Function checkGlobalKeys%() Local state% = 0 For i% = 0 To 255 state% = GetAsyncKeyState(i%) If state% > 0 Then Return i% + 1 Next Return False End Function |
| ||
it doesent work because state can be negative.. (you can test this using debuglog(state)) so, if state%<>0 Then return i%works but i suggest you catch only keyhits so use: if (state% & 1) then return i |
| ||
thanks, can you explain me what does & as an operator do? |
| ||
[Bitwise and]-operator.if (state% & 1) then return i This line above checks if the "rightmost" bit (bit #0) of the state% int-variable is set. Source: http://en.wikibooks.org/wiki/BlitzMax/Language/Expressions |
| ||
Inside the second post's link there's a line:Return (GetAsyncKeyState:Int(VirtualKey) And %1000000000000000) > 0 Int is 4 bytes (32 bit). %1000000000000000 has 16 zeros in it, so this one checks the middle bit to be one? and if i want to check the left-most i have to use 32 zeros? or to check the second buit from right-most i have to use "& 2"? but what does %1000000000000000 do then? :P |
| ||
hi, check: http://msdn.microsoft.com/en-us/library/ms646293(VS.85).aspx the most significant bit (leftmost) is checked by the And %1000...0 it signals if the vKey is down at this moment. (and the number has fifteen 0's not sixteen, and int is 16 bits signed in some contexts, in blitz is 32 signed, but nor for windows i think, 32 signed are called Long) juan |