procedure TForm1.Button3Click(Sender: TObject); begin keybd_event( VK_NUMLOCK,$45,KEYEVENTF_EXTENDEDKEY or 0, 0 ); keybd_event( VK_NUMLOCK,$45,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0); end;
CapsLock:procedure TForm1.Button2Click(Sender: TObject); begin keybd_event( VK_CAPITAL,20,KEYEVENTF_EXTENDEDKEY or 0, 0 ); keybd_event( VK_CAPITAL,20,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0); end;
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 ); bVk 虚拟键值 bScan 硬件扫描码 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.dwExtraInfoSpecifies an additional 32-bit value associated with the key stroke.
begin
keybd_event( VK_NUMLOCK,$45,KEYEVENTF_EXTENDEDKEY or 0, 0 );
keybd_event( VK_NUMLOCK,$45,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);
end;
begin
keybd_event( VK_CAPITAL,20,KEYEVENTF_EXTENDEDKEY or 0, 0 );
keybd_event( VK_CAPITAL,20,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);
end;
BYTE bScan, // hardware scan code
DWORD dwFlags, // flags specifying various function options
DWORD dwExtraInfo // additional data associated with keystroke
);
bVk 虚拟键值
bScan 硬件扫描码
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.dwExtraInfoSpecifies an additional 32-bit value associated with the key stroke.