?
Solved

How do i set NUMLOCK OFF

Posted on 1998-12-17
5
Medium Priority
?
233 Views
Last Modified: 2010-04-04
How can i set numlock on when my program start running. This should switch on the numlock light. SetKeyboardState
only sets the program not the system keyboard buffer.
Assembler code generate GPF on my NT system. I am using
NT4 and delphi3 client server on my system.
0
Comment
Question by:dziedzir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:dziedzir
ID: 1351731
Edited text of question
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 1351732
Use the keybd_event API function. Here is the API help for it:

Cheers,

Raymond.

The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver's interrupt handler calls the keybd_event function.

VOID keybd_event(

    BYTE  bVk,      // virtual-key code
    BYTE  bScan,      // hardware scan code
    DWORD  dwFlags,      // flags specifying various function options
    DWORD  dwExtraInfo       // additional data associated with keystroke
   );      
Parameters

bVk

Specifies a virtual-key code. The code must be a value in the range 1 to 254.

bScan

Specifies a hardware scan code for the key.

dwFlags

A set of flag bits that specify various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags:

Value      Meaning
KEYEVENTF_EXTENDEDKEY      If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).
KEYEVENTF_KEYUP      If specified, the key is being released. If not specified, the key is being depressed.
dwExtraInfo

Specifies an additional 32-bit value associated with the key stroke.

Return Value

This function has no return value.

Remarks

Although keybd_event passes an OEM-dependent hardware scan code to Windows, applications should not use the scan code. Windows converts scan codes to virtual-key codes internally and clears the up/down bit in the scan code before passing it to applications.
An application can simulate a press of the PRINTSCREEN key in order to obtain a screen snapshot and save it to the Windows clipboard. To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT, and the bScan parameter set to 0 for a snapshot of the full screen or set bScan to 1 for a snapshot of the active window.

See Also

GetAsyncKeyState, GetKeyState, MapVirtualKey, SetKeyboardState

0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1351733
... Set bVK to VK_NUMLOCK ...

Cheers,

Raymond.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1351734
There are at list 2 methods (tested on D3, NT4):

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

procedure TForm1.Button2Click(Sender: TObject);
var
  TmpKeyBuffer:    TKeyboardState;
  TmpScan:         Integer;
begin
 GetKeyboardState(TmpKeyBuffer);
  SetKeyboardState(TmpKeyBuffer);
  TmpScan := MapVirtualKey(VK_NUMLOCK,0);
  Keybd_event(VK_NUMLOCK,TmpScan,0,0);
  Keybd_event(VK_NUMLOCK,TmpScan,KEYEVENTF_KEYUP,0);
end;

0
 

Author Comment

by:dziedzir
ID: 1351735
Thanks a lot for your help.

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question