- Declared in: RT.Util.UtWin
Declaration
public static void SendKeystrokes(
IEnumerable<object> keys
)
Summary
Sends the specified sequence of key strokes to the active application. See remarks for details.
Parameters
IEnumerable<object> | keys |
A collection of objects of type Keys, Char, or System.Tuple<Keys,
bool> . |
Exceptions
- System.ArgumentNullException
keys was null.
- System.ArgumentException
keys contains an object which is of an unexpected type. Only Keys, Char and System.Tuple<System.Windows.Forms.Keys, bool>
are accepted.
Remarks
-
For objects of type Keys, the relevant key is pressed and released.
-
For objects of type Char, the specified Unicode character is simulated as a keypress and
release.
-
For objects of type
Tuple<Keys, bool>
or ValueTuple<Keys, bool>
, the bool
specifies whether to simulate only a key-down (false) or only a key-up (true).
Example
The following example demonstrates how to use this method to send the key combination Win+R:
Ut.SendKeystrokes(Ut.NewArray<object>(
(Keys.LWin, false),
Keys.R,
(Keys.LWin, true)
));