Show / Hide Table of Contents

Class keys

Keyboard functions. Send virtual keystrokes and text to the active window, get key state, wait for key.

public class keys
Remarks

The main function is keys.send. Most documentation is there. See also keys.sendt. These functions use opt.key. Alternatively can be used keys variables, see keys.keys.

Examples
keys.send("Ctrl+Shift+Left"); //press Ctrl+Shift+Left

opt.key.KeySpeed = 300; //set options for static functions
keys.send("Ctrl+A Del Tab*3", "!text", "Enter", 500); //press Ctrl+A, Del, Tab 3 times, send text, Enter, wait 500 ms

keys.sendt("text\r\n"); //send text that ends with newline

Namespace: Au
Assembly: Au.dll
Inheritance
object
keys

Constructors

Name Description
keys(OKey)

Properties

Name Description
Options

Options used by this variable.

isAlt

Returns true if the Alt key is pressed. Calls keys.isPressed. In UI code use keys.gui instead.

isCapsLock

Returns true if the CapsLock key is toggled.

isCtrl

Returns true if the Ctrl key is pressed. Calls keys.isPressed. In UI code use keys.gui instead.

isNumLock

Returns true if the NumLock key is toggled.

isScrollLock

Returns true if the ScrollLock key is toggled.

isShift

Returns true if the Shift key is pressed. Calls keys.isPressed. In UI code use keys.gui instead.

isWin

Returns true if the Win key is pressed. Calls keys.isPressed. In UI code use keys.gui instead.

Methods

Name Description
Add(params KKeysEtc[])

Adds keystrokes, text, sleep and other events to the internal collection. They will be sent/executed by keys.SendNow.

AddAction(Action)

Adds a callback function.

AddChar(char)

Adds single character to the internal collection. It will be sent like text with option OKeyText.KeysOrChar.

AddClipboardData(clipboardData)

Adds clipboard data, for example several formats. It will be pasted by keys.SendNow.

AddKey(KKey, bool?)

Adds single key, specified as KKey, to the internal collection. It will be sent by keys.SendNow.

AddKey(KKey, ushort, bool, bool?)

Adds single key to the internal collection. Allows to specify scan code and whether it is an extended key. It will be sent by keys.SendNow.

AddKeys(string)

Adds keystrokes to the internal collection. They will be sent by keys.SendNow.

AddRepeat(int)

Adds the repeat operator. Then keys.SendNow will send the last added key or character count times.

AddSleep(int)

Adds a short pause. Then keys.SendNow will sleep (wait).

AddText(string, OKeyText)

Adds text with explicitly specified sending method (keys, characters or paste).

AddText(string, string)

Adds text or HTML. It will be sent by keys.SendNow.

SendNow(bool)

Sends keys, text and executes other events added with the AddX functions.

getMod(KMod)

Gets flags indicating which modifier keys are pressed: Ctrl, Shift, Alt, Win. Calls keys.isPressed. In UI code use keys.gui instead.

isMod(KMod)

Returns true if some modifier keys are pressed: Ctrl, Shift, Alt, Win. Calls keys.isPressed. In UI code use keys.gui instead.

isPressed(KKey)

Returns true if the specified key or mouse button is pressed. In UI code use keys.gui instead.

send(params KKeysEtc[])

Generates virtual keystrokes (keys, text).

sendL(params KKeysEtc[])

Generates virtual keystrokes. Like keys.send, but without reliability features: delays, user input blocking, resetting modifiers/CapsLock.

sendt(string, string)

Sends text to the active window, using virtual keystrokes or clipboard.

waitForHotkey(Seconds, KHotkey, bool)

Registers a temporary hotkey and waits for it.

waitForHotkeys(Seconds, KHotkey[], bool, bool)

Sets a temporary keyboard hook and waits for a hotkey.

waitForKey(Seconds, KKey, bool, bool)

Waits for key-down or key-up event of the specified key.

waitForKey(Seconds, bool, bool)

Waits for key-down or key-up event of any key, and gets the key code.

waitForKey(Seconds, string, bool, bool)

Waits for key-down or key-up event of the specified key.

waitForKeys(Seconds, Func<Keyboard, bool>, bool)

Waits for keyboard events using callback function.

waitForNoModifierKeys(Seconds, KMod)

Waits while some modifier keys (Ctrl, Shift, Alt, Win) are pressed. See keys.isMod.

waitForNoModifierKeysAndMouseButtons(Seconds, KMod, MButtons)

Waits while some modifier keys (Ctrl, Shift, Alt, Win) or mouse buttons are pressed.

waitForReleased(Seconds, params KKey[])

Waits while the specified keys or/and mouse buttons are pressed.

waitForReleased(Seconds, string)

Waits while the specified keys are pressed.

Events

Name Description
Pasting

Before pasting text through clipboard.