Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
keybd_event simulates keyboard input by placing a keyboard input event into the input stream. The function can simulate a single press or release of a single key. This function should only be used when a key's state changes. For example, do not tell the function to simulate pressing the Z key if the Z key is already pressed.
keybd_event does not return a value.
None.
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
' This code is licensed according to the terms and conditions listed here.
' Simulate the user pressing Alt+Space followed by N. This
' key combination will minimize the active window.
' Hold the Alt key while typing Space.
keybd_event VK_MENU, 0, 0, 0 ' press Alt
keybd_event VK_SPACE, 0, 0, 0 ' press Space
keybd_event VK_SPACE, 0, KEYEVENTF_KEYUP, 0 ' release Space
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0 ' release Alt
' Type the N key.
keybd_event VK_N, 0, 0, 0 ' press N
keybd_event VK_N, 0, KEYEVENTF_KEYUP, 0 ' release N
Go back to the alphabetical Function listing.
Go back to the Reference section index.
Last Modified: August 7, 1999
This page is copyright © 1999 Paul Kuliniewicz.
Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/k/keybd_event.html