edhasted
asked on
Delphi - get status of Num Lock / Caps Lock / Scroll Lock lights (on or off)
This has been asked historically but I was wondering if there has been any progress on this issue in the intervening years.
What I need is a was of accurately displaying whether the Num/Caps/Scoll lock lights are on or off.
The reasons behind this is simple. I am writing a key stroke logger to be used with blind users. Rather than second guess what keystrokes they have pressed the logger displays what buttons they have actually pressed. However it is vital for their remote tutors to know whether the Num and Caps locks are on or off.
Can this be done reliably?
With thanks,
Ed
What I need is a was of accurately displaying whether the Num/Caps/Scoll lock lights are on or off.
The reasons behind this is simple. I am writing a key stroke logger to be used with blind users. Rather than second guess what keystrokes they have pressed the logger displays what buttons they have actually pressed. However it is vital for their remote tutors to know whether the Num and Caps locks are on or off.
Can this be done reliably?
With thanks,
Ed
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does LowOrderBitSet work in Delphi 5? If not is there a workaround - I'm getting an "Undeclared Idenfier" from the compiler.
Thanks,
Ed
Thanks,
Ed
ASKER
Apologies - I copied over the code and left out the LowOrderBit function.
Ed
Ed
ASKER
Firstly many thanks to Mike Littlewood for his answer. I have set it up so three panels alter their colour from black to green depending on whether the lights are on or off. So far it works perfectly.
What I find strange reading the previous stabs at this problem was that the contributors felt that it could not be done.
This appears to crack the problem.
With many thanks,
Ed
What I find strange reading the previous stabs at this problem was that the contributors felt that it could not be done.
This appears to crack the problem.
With many thanks,
Ed
Glad I could help.
var
k: TKeyboardState;
begin
GetKeyboardState(k);
Edit1.Text := IntToStr(k[VK_NUMLOCK]);
Edit2.Text := IntToStr(k[VK_CAPITAL]);
Edit3.Text := IntToStr(k[VK_SCROLL]);