SendKeys is a function used to simulate keystrokes and key combinations as if they were being manually typed by a user.
While the Write action typically suffices for most tasks, there are instances where the SendKeys action is necessary, such as:
- Using key combinations like Control + Shift + Enter.
- Employing it within fields that are not free-text input areas.
Example of Usage:
SendKeys CONTROL + SHIFT + VK_4
// Simulates pressing the number 4 while holding down the Control and Shift keys.
Complete SendKeys Options
// Left mouse button
LBUTTON = 1,
// Right mouse button
RBUTTON = 2,
// Control-break processing
CANCEL = 3,
// Middle mouse button (three-button mouse) - NOT contiguous with LBUTTON and RBUTTON
MBUTTON = 4,
// Windows 2000/XP: X1 mouse button - NOT contiguous with LBUTTON and RBUTTON
XBUTTON1 = 5,
// Windows 2000/XP: X2 mouse button - NOT contiguous with LBUTTON and RBUTTON
XBUTTON2 = 6,
// BACKSPACE key
BACK = 8,
// TAB key
TAB = 9,
// CLEAR key
CLEAR = 12,
// ENTER key
RETURN = 13,
// SHIFT key
SHIFT = 0x10,
// CTRL key
CONTROL = 17,
// ALT key
MENU = 18,
// PAUSE key
PAUSE = 19,
// CAPS LOCK key
CAPITAL = 20,
// Input Method Editor (IME) Kana mode
KANA = 21,
// IME Hanguel mode (maintained for compatibility; use HANGUL)
HANGEUL = 21,
// IME Hangul mode
HANGUL = 21,
// IME Junja mode
JUNJA = 23,
// IME final mode
FINAL = 24,
// IME Hanja mode
HANJA = 25,
// IME Kanji mode
KANJI = 25,
// ESC key
ESCAPE = 27,
// IME convert
CONVERT = 28,
// IME nonconvert
NONCONVERT = 29,
// IME accept
ACCEPT = 30,
// IME mode change request
MODECHANGE = 0x1F,
// SPACEBAR
SPACE = 0x20,
// PAGE UP key
PRIOR = 33,
// PAGE DOWN key
NEXT = 34,
// END key
END = 35,
// HOME key
HOME = 36,
// LEFT ARROW key
LEFT = 37,
// UP ARROW key
UP = 38,
// RIGHT ARROW key
RIGHT = 39,
// DOWN ARROW key
DOWN = 40,
// SELECT key
SELECT = 41,
// PRINT key
PRINT = 42,
// EXECUTE key
EXECUTE = 43,
// PRINT SCREEN key
SNAPSHOT = 44,
// INS key
INSERT = 45,
// DEL key
DELETE = 46,
// HELP key
HELP = 47,
// 0 key
VK_0 = 48,
// 1 key
VK_1 = 49,
// 2 key
VK_2 = 50,
// 3 key
VK_3 = 51,
// 4 key
VK_4 = 52,
// 5 key
VK_5 = 53,
// 6 key
VK_6 = 54,
// 7 key
VK_7 = 55,
// 8 key
VK_8 = 56,
// 9 key
VK_9 = 57,
// A key
VK_A = 65,
// B key
VK_B = 66,
// C key
VK_C = 67,
// D key
VK_D = 68,
// E key
VK_E = 69,
// F key
VK_F = 70,
// G key
VK_G = 71,
// H key
VK_H = 72,
// I key
VK_I = 73,
// J key
VK_J = 74,
// K key
VK_K = 75,
// L key
VK_L = 76,
// M key
VK_M = 77,
// N key
VK_N = 78,
// O key
VK_O = 79,
// P key
VK_P = 80,
// Q key
VK_Q = 81,
// R key
VK_R = 82,
// S key
VK_S = 83,
// T key
VK_T = 84,
// U key
VK_U = 85,
// V key
VK_V = 86,
// W key
VK_W = 87,
// X key
VK_X = 88,
// Y key
VK_Y = 89,
// Z key
VK_Z = 90,
// Left Windows key (Microsoft Natural keyboard)
LWIN = 91,
// Right Windows key (Natural keyboard)
RWIN = 92,
// Applications key (Natural keyboard)
APPS = 93,
// Computer Sleep key
SLEEP = 95,
// Numeric keypad 0 key
NUMPAD0 = 96,
// Numeric keypad 1 key
NUMPAD1 = 97,
// Numeric keypad 2 key
NUMPAD2 = 98,
// Numeric keypad 3 key
NUMPAD3 = 99,
// Numeric keypad 4 key
NUMPAD4 = 100,
// Numeric keypad 5 key
NUMPAD5 = 101,
// Numeric keypad 6 key
NUMPAD6 = 102,
// Numeric keypad 7 key
NUMPAD7 = 103,
// Numeric keypad 8 key
NUMPAD8 = 104,
// Numeric keypad 9 key
NUMPAD9 = 105,
// Multiply key
MULTIPLY = 106,
// Add key
ADD = 107,
// Separator key
SEPARATOR = 108,
// Subtract key
SUBTRACT = 109,
// Decimal key
DECIMAL = 110,
// Divide key
DIVIDE = 111,
// F1 key
F1 = 112,
// F2 key
F2 = 113,
// F3 key
F3 = 114,
// F4 key
F4 = 115,
// F5 key
F5 = 116,
// F6 key
F6 = 117,
// F7 key
F7 = 118,
// F8 key
F8 = 119,
// F9 key
F9 = 120,
// F10 key
F10 = 121,
// F11 key
F11 = 122,
// F12 key
F12 = 123,
// F13 key
F13 = 124,
// F14 key
F14 = 125,
// F15 key
F15 = 126,
// F16 key
F16 = 0x7F,
// F17 key
F17 = 0x80,
// F18 key
F18 = 129,
// F19 key
F19 = 130,
// F20 key
F20 = 131,
// F21 key
F21 = 132,
// F22 key
F22 = 133,
// F23 key
F23 = 134,
// F24 key
F24 = 135,
// NUM LOCK key
NUMLOCK = 144,
// SCROLL LOCK key
SCROLL = 145,
// Left SHIFT key - Used only as parameters to GetAsyncKeyState() and GetKeyState()
LSHIFT = 160,
// Right SHIFT key - Used only as parameters to GetAsyncKeyState() and GetKeyState()
RSHIFT = 161,
// Left CONTROL key - Used only as parameters to GetAsyncKeyState() and GetKeyState()
LCONTROL = 162,
// Right CONTROL key - Used only as parameters to GetAsyncKeyState() and GetKeyState()
RCONTROL = 163,
// Left MENU key - Used only as parameters to GetAsyncKeyState() and GetKeyState()
LMENU = 164,
// Right MENU key - Used only as parameters to GetAsyncKeyState() and GetKeyState()
RMENU = 165,
// Windows 2000/XP: Browser Back key
BROWSER_BACK = 166,
// Windows 2000/XP: Browser Forward key
BROWSER_FORWARD = 167,
// Windows 2000/XP: Browser Refresh key
BROWSER_REFRESH = 168,
// Windows 2000/XP: Browser Stop key
BROWSER_STOP = 169,
// Windows 2000/XP: Browser Search key
BROWSER_SEARCH = 170,
// Windows 2000/XP: Browser Favorites key
BROWSER_FAVORITES = 171,
// Windows 2000/XP: Browser Start and Home key
BROWSER_HOME = 172,
// Windows 2000/XP: Volume Mute key
VOLUME_MUTE = 173,
// Windows 2000/XP: Volume Down key
VOLUME_DOWN = 174,
// Windows 2000/XP: Volume Up key
VOLUME_UP = 175,
// Windows 2000/XP: Next Track key
MEDIA_NEXT_TRACK = 176,
// Windows 2000/XP: Previous Track key
MEDIA_PREV_TRACK = 177,
// Windows 2000/XP: Stop Media key
MEDIA_STOP = 178,
// Windows 2000/XP: Play/Pause Media key
MEDIA_PLAY_PAUSE = 179,
// Windows 2000/XP: Start Mail key
LAUNCH_MAIL = 180,
// Windows 2000/XP: Select Media key
LAUNCH_MEDIA_SELECT = 181,
// Windows 2000/XP: Start Application 1 key
LAUNCH_APP1 = 182,
// Windows 2000/XP: Start Application 2 key
LAUNCH_APP2 = 183,
// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP:
// For the US standard keyboard, the ';:' key
OEM_1 = 186,
// Windows 2000/XP: For any country/region, the '+' key
OEM_PLUS = 187,
// Windows 2000/XP: For any country/region, the ',' key
OEM_COMMA = 188,
// Windows 2000/XP: For any country/region, the '-' key
OEM_MINUS = 189,
// Windows 2000/XP: For any country/region, the '.' key
OEM_PERIOD = 190,
// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP:
// For the US standard keyboard, the '/?' key
OEM_2 = 191,
// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP:
// For the US standard keyboard, the '`~' key
OEM_3 = 192,
// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP:
// For the US standard keyboard, the '[{' key
OEM_4 = 219,
// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP:
// For the US standard keyboard, the '\|' key
OEM_5 = 220,
// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP:
// For the US standard keyboard, the ']}' key
OEM_6 = 221,
// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP:
// For the US standard keyboard, the 'single-quote/double-quote' key
OEM_7 = 222,
// Used for miscellaneous characters; it can vary by keyboard.
OEM_8 = 223,
// Windows 2000/XP: Either the angle bracket key or the backslash key on the RT
// 102-key keyboard
OEM_102 = 226,
// Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
PROCESSKEY = 229,
// Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes.
// The PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard
// input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN,
// and WM_KEYUP
PACKET = 231,
// Attn key
ATTN = 246,
// CrSel key
CRSEL = 247,
// ExSel key
EXSEL = 248,
// Erase EOF key
EREOF = 249,
// Play key
PLAY = 250,
// Zoom key
ZOOM = 251,
// Reserved
NONAME = 252,
// PA1 key
PA1 = 253,
// Clear key
OEM_CLEAR = 254