Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TKeyboardState under Windows XP 1

Status
Not open for further replies.

dredfern

Technical User
Dec 7, 2003
14
GB
Sorry the previous message should have read:-
The following code to turn on the NumKey works under previous Windows versions but not under Windows XP. Any suggestions?

procedure TfrmMain.FormCreate(Sender: TObject);
var
numkey: TKeyboardState;
begin
//set Num Lock on
GetKeyboardState(numkey);
numkey[VK_NUMLOCK] := 1;
SetKeyboardState(numkey);
end;
 
This code changes numlock state on-off/off-on

Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  keybd_event(VK_NUMLOCK, MapVirtualKey(VK_NUMLOCK, 0), KEYEVENTF_EXTENDEDKEY, 0);
  keybd_event(VK_NUMLOCK, MapVirtualKey(VK_NUMLOCK, 0), KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
end;

Giovanni Caramia
 
Giovanni,
Thank you, you're piece of code did the trick.

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top