Hi,

I need a sure way (all windows) to detect, if capslock and numlock led is burning (active).
GetKeyboardState() works fine here, but only, if my window has the mouse focus. Otherwise it won't work...
Is there a way to get the infos without mouse focus in window or even better without any window in use?
It should work on all window platforms...

Thanks & greetings,
Nordwind64
Posted on 2003-06-16 09:28:38 by Nordwind64
No way...?
:confused:
Posted on 2003-06-16 23:24:36 by Nordwind64
GetAsyncKeyState
Posted on 2003-06-16 23:36:53 by iblis
Using GetKeyState
with the arg VK_CAPITAL ;caplock
Returns the state of the key without a window for me.



; ##########################################

.486
.model flat, stdcall
option casemap :none ; case sensitive

; ###########################################

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
include \masm32\include\masm32.inc
include \masm32\include\debug.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\debug.lib

main PROTO


; ################################################

.code

start:

call main

invoke ExitProcess,0

; ############################################

main proc

invoke GetKeyState,VK_CAPITAL
PrintDec eax

ret

main endp

; ##########################################


is this what u needed?

EDIT: didn't see a followup post when I posted this.
Posted on 2003-06-16 23:40:47 by RobotBob
Hi Nordwind64,

My old work, :)

Regards,
Posted on 2003-06-17 06:52:19 by CYDONIA
Hi,

iblis: GetASyncKeyState() kann only detect, if capslock or numlock key actually is pressed down or not.
RobotBob & CYDONIA: GetKeyState() only works, if the program window has the focus...

I could need something like GetAsyncKeyboardState()...
Any other ideas ?

Greetings,
Nordwind64
Posted on 2003-06-17 10:04:56 by Nordwind64
I don't know what the problem is.
Those APIs work fine for me regardless of keyboard or mouse focus.
Posted on 2003-06-17 11:57:37 by iblis
Hook the keyboard and you will always have state information, regardless of focus.
Of course, you will need to SendMessage, for any state changes, to your window.

Regards, P1 :cool:
Posted on 2003-06-17 13:43:09 by Pone
Hi,

Thanks, Pone. Can you give me a little example ?
Iblis, yes, they work fine, but not system wide, only task wide.

Thanks,
Nordwind64
Posted on 2003-06-17 14:17:43 by Nordwind64
No, you misunderstand.

Originally posted by Nordwind64
RobotBob & CYDONIA: GetKeyState() only works, if the program window has the focus...


I was saying that, for me, that is not the case. I wrote up a test program and found that GetKeyState() works fine, and reports the state of the Caps Lock key without error, no matter what window I give the focus. For example, even with Notepad in the foreground, the test program was still reporting the correct Caps Lock state.
Posted on 2003-06-18 00:34:05 by iblis
I tested GetKetState inside a skeleton NT service and it reports fine there too.
I guess I dont understand what you are trying to do.

Maybe posting the source snip you are having problems with would help.

RobotBob
Posted on 2003-06-18 01:21:56 by RobotBob
Hi,

I've tested the program under XP Home, and it was still reporting not the correct Caps Lock state, if the window had lost the focus... Without focus the window is still dead.
Can please another XP User test this ?

The source is not ready finished, I'm testing this an that.
It's part of a Dll function.
I trie to get all keys, the user is pressing system wide. Later the programm should be a textbuffer agains loosing data.

What about hooking the keyboard ?

Sorry for my bad english... :(

Greetings
Nordwind64
Posted on 2003-06-18 09:59:21 by Nordwind64
I am using XP home service pack 1.
Noone will probably be able to help you without a direct idea of what
you are trying to accomplish.

EDIT:
Just notice you -dll function- part, ill test that later today for you.

RobotBob
Posted on 2003-06-18 14:11:09 by RobotBob
I created a dll that used the function GetKeyState .
I create another app WITHOUT a window, simple gui-free that calls
-my- GetKeyState dll function. It worked perfectly. There is no window
to get focus too.

So then I guess without further code or a description of what you are doing...

EDIT:
In your original post, you stated you wanted to find out whether capslock and numlock were active. But now I am thinking your trying to store all keyboard hits. Are you writing a 'key logger' ??

RobotBob.
Posted on 2003-06-18 14:26:41 by RobotBob
Hi,

"Key logger" ?
No, not really. I'm only interested in making/having a copy of my own written texts.
Very often I'm posting in a forum (not only Assembler) and I had often lost my text, because the server could not find the side ect.
It should only be a small text backup programm.

Thank you for testing under XP.
My Testprogramm using the Dll wasn't an Assembler programm. Perhaps there lies the error...

Greetings,
Nordwind64
Posted on 2003-06-19 06:12:28 by Nordwind64
That sounds like a cool programm.
I have (haven't we all) type something only to have the
web page expire or something.

RobotBob
Posted on 2003-06-19 07:32:36 by RobotBob
Hi,

now I found exactly what I want to code in the internet:

Home Key Logger Free Edition v1.70
http://www.spyarsenal.com/

It seems not include spy software or trojan horses... I hope...

Greetings,
Nordwind64
Posted on 2003-06-19 08:03:12 by Nordwind64