Skip to content

Keyboard

Keyboard module for autopylot.This module contains functions for keyboard input and output.

Examples:

>>> from autopylot import keyboard
>>> keyboard.press(key_1='a')
>>> keyboard.write(text='Hello World!')
>>> keyboard.write(text='Hello World!', end='enter')
>>> keyboard.hit_enter(window="Notepad")

This module contains the following functions:

  • press(key_1, key_2, key_3, window): Check if a key is pressed.
  • write(text, window, end): Write text and press enter.
  • hit_enter(window): Press enter.

hit_enter(window='')

Hit enter key

Parameters:

Name Type Description Default
window str

The window to press enter key. Defaults to Active window

''

Returns:

Type Description
None

None

Examples:

>>> keyboard.hit_enter(window="Notepad")

press(key_1, key_2='', key_3='', window='')

Press a key or a combination of keys.

Parameters:

Name Type Description Default
key_1 str

The first key to press.

required
key_2 str

The second key to press.

''
key_3 str

The third key to press.

''
window str

The window to press the key in. Defaults to Active Window.

''

Returns:

Type Description
None

None

Examples:

>>> keyboard.press(key_1='a', window='Notepad')
>>> keyboard.press(key_1='ctrl', key_2='a')
>>> keyboard.press(key_1='ctrl', key_2='shift',key_3='esc')

write(text, window='', end='enter')

Write text to window and press enter key

Parameters:

Name Type Description Default
text str

Text to write

required
window str

The window to write to. Defaults to Active window

''
end str

Key to press at end. Available options are 'enter', 'tab'.

'enter'

Returns:

Type Description
None

None

Examples:

>>> keyboard.write(text="Hello World", window="Notepad")