Package: keyio
KeyIO Package DocumentationThis library provides various functions to control and manage IO eventsAs of version 0.0.1, there are three modules in this package.keyutils-used to manage keyboard IO eventsmouseutils-used to manage mouse IO eventswindowutils-used to manage window IO eventsTo install this package, type in command prompt:pip install keyio[1] Controlling and Monitoring Keyboard Events(1-A) Simulating Key Pressingpress_key(self, target_key : int) -> KeyUtils#example 1
from keyio.keyutils import KeyUtils
key_utils  = KeyUtils()
target_key = KeyUtils.Key.KEY_ESC
key_utils.press_key(target_key)(1-B) Simulating Key Releasingrelease_key(self, target_key : int) -> KeyUtils#example 2
from keyio.keyutils import KeyUtils
key_utils  = KeyUtils()
target_key = KeyUtils.Key.KEY_ESC
key_utils.release_key(target_key)(1-C-1) KeyCode ListKeyUtils.KeyCodeKeyCodeValueDescriptionCHAR_0480CHAR_1491CHAR_2502CHAR_3513CHAR_4524CHAR_5535CHAR_6546CHAR_7557CHAR_8568CHAR_9579CHAR_A65ACHAR_B66BCHAR_C67CCHAR_D68DCHAR_E69ECHAR_F70FCHAR_G71GCHAR_H72HCHAR_I73ICHAR_J74JCHAR_K75KCHAR_L76LCHAR_M77MCHAR_N78NCHAR_O79OCHAR_P80PCHAR_Q81QCHAR_R82RCHAR_S83SCHAR_T84TCHAR_U85UCHAR_V86VCHAR_W87WCHAR_X88XCHAR_Y89YCHAR_Z90Z(1-C-2) Key ListKeyUtils.KeyKeyValueDescriptionKEY_BACKSPACE0x08~KEY_TAB0x09~KEY_CLEAR0x0C~KEY_ENTER0x0D~KEY_SHIFT0x10~KEY_CTRL0x11~KEY_ALT0x12~KEY_PAUSE0x13~KEY_CAPS_LOCK0x14~KEY_ESC0x1B~KEY_SPACE0x20~KEY_PAGE_UP0x21~KEY_PAGE_DOWN0x22~KEY_END0x23~KEY_HOME0x24~KEY_LEFT_ARROW0x25~KEY_UP_ARROW0x26~KEY_RIGHT_ARROW0x27~KEY_DOWN_ARROW0x28~KEY_SELECT0x29~KEY_PRINT0x2A~KEY_EXECUTE0x2B~KEY_SNAPSHOT0x2C~KEY_INSERT0x2D~KEY_DELETE0x2E~KEY_HELP0x2F~KEY_LEFT_WINDOW0x5B~KEY_RIGHT_WINDOW0x5C~KEY_APPLICATION0x5D~KEY_SLEEP0x5F~KEY_NUMPAD_00x60~KEY_NUMPAD_10x61~KEY_NUMPAD_20x62~KEY_NUMPAD_30x63~KEY_NUMPAD_40x64~KEY_NUMPAD_50x65~KEY_NUMPAD_60x66~KEY_NUMPAD_70x67~KEY_NUMPAD_80x68~KEY_NUMPAD_90x69~KEY_MULTIPLY0x6A~KEY_ADD0x6B~KEY_SEPARATOR0x6C~KEY_SUBTRACT0x6D~KEY_DECIMAL0x6E~KEY_DIVIDE0x6F~KEY_F10x70~KEY_F20x71~KEY_F30x72~KEY_F40x73~KEY_F50x74~KEY_F60x75~KEY_F70x76~KEY_F80x77~KEY_F90x78~KEY_F100x79~KEY_F110x7A~KEY_F120x7B~KEY_F130x7C~KEY_F140x7D~KEY_F150x7E~KEY_F160x7F~KEY_F170x80~KEY_F180x81~KEY_F190x82~KEY_F200x83~KEY_F210x84~KEY_F220x85~KEY_F230x86~KEY_F240x87~KEY_NUMLOCK0x90~KEY_SCROLL0x91~KEY_LEFT_SHIFT0xA0~KEY_RIGHT_SHIFT0xA1~KEY_LEFT_CTRL0xA2~KEY_RIGHT_CTRL0xA3~KEY_LEFT_ALT0xA4~KEY_RIGHT_ALT0xA5~KEY_OEM_10xBA~KEY_OEM_PLUS0xBB~KEY_OEM_COMMA0xBC~KEY_OEM_MINUS0xBD~KEY_OEM_PERIOD0xBE~KEY_OEM_20xBF~KEY_OEM_30xC0~KEY_OEM_40xDB~KEY_OEM_50xDC~KEY_OEM_60xDD~KEY_OEM_70xDE~KEY_OEM_80xDF~KEY_OEM_1020xE2~(1-D) Monitoring Key EventsExample#example 3
from keyio.keyutils import KeyUtils
key_utils    = KeyUtils()
key_1        = KeyUtils.Key.KEY_ESC
key_2        = KeyUtils.Key.KEY_SPACE
keep_running = True
@key_utils.monitor([ key_1, key_2 ])
def monitor_exit(key_code : int, key_pressed : bool) -> None:
    global keep_running
    keep_running = False
@key_utils.monitor("abcdefg092")
def monitor_char(key_code : int, key_pressed : bool) -> None:
    print(chr(key_code), end = ' ')
    if (key_pressed):
        print("pressed")
    else:
        print("released")
key_utils.initialize_monitors()
key_utils.start_thread()
while (keep_running):
    pass
key_utils.stop_thread()[2] Controlling and Monitoring Mouse Events(2-A) Simulating Mouse Pressingpress_button(self, mouse_button : int) -> MouseUtils#example 4
from keyio.mouseutils import MouseUtils
mouse_utils  = MouseUtils()
mouse_button = MouseUtils.LEFT_BUTTON
mouse_utils.press_button(mouse_button)(2-B) Simulating Mouse Releasingrelease_button(self, mouse_button : int) -> MouseUtils#example 5
from keyio.mouseutils import MouseUtils
mouse_utils  = MouseUtils()
mouse_button = MouseUtils.MIDDLE_BUTTON
mouse_utils.release_button(mouse_button)(2-C) Simulating Scrollscroll(self, dy : int) -> MouseUtils#example 6
from keyio.mouseutils import MouseUtils
mouse_utils  = MouseUtils()
dy           = -10
mouse_utils.scroll(dy)(2-D) Obtaining Cursor Coordinatesget_mouse_coord(self) -> Tuple[ int, int ]#example 7
from keyio.mouseutils import MouseUtils
mouse_utils = MouseUtils()
(x, y)      = mouse_utils.get_mouse_coord()
print("({},{})".format(x, y))(2-E) Setting Cursor Coordinatesset_mouse_coord(self, x : int, y : int) -> MouseUtils#example 8
from keyio.mouseutils import MouseUtils
mouse_utils = MouseUtils()
(x, y)      = (127, 89)
mouse_utils.set_mouse_coord(x, y)(2-F) Mouse Event ListMouseUtilsButton/EventValueDescriptionLEFT_BUTTON00MIDDLE_BUTTON11RIGHT_BUTTON22MOUSE_MOVE33(2-G) Monitoring Mouse EventsExample#example 9
from typing import Tuple
from keyio.mouseutils import MouseUtils
mouse_utils  = MouseUtils()
button_1     = MouseUtils.LEFT_BUTTON
button_2     = MouseUtils.RIGHT_BUTTON
button_3     = MouseUtils.MIDDLE_BUTTON
keep_running = True
@mouse_utils.monitor([ button_1, button_2, button_3 ])
def monitor_exit(mouse_button : int, button_pressed : bool) -> None:
    global keep_running
    keep_running = False
@mouse_utils.monitor(MouseUtils.MOUSE_MOVE)
def monitor_char(mouse_button : int, mouse_coord : Tuple[ int, int ]) -> None:
    print("({},{})".format(*mouse_coord))
mouse_utils.initialize_monitors()
mouse_utils.start_thread()
while (keep_running):
    pass
mouse_utils.stop_thread()[3] Controlling and Observing Window Events(3-A) Obtain Bounding Box of Selected Windowget_foreground_window(self) -> Tuple[ int, int, int, int ]#example 10
from keyio.windowutils import WindowUtils
window_utils = WindowUtils()
(sx, sy, ex, ey) = window_utils.get_foreground_window()
print("Window: ({},{},{},{})".format(sx, sy, ex, ey))(3-B) Set Bounding Box of Selected Windowset_foreground_window(self, sx : int, sy : int, dx : int = -1, dy : int = -1, flag : int = 0x0040) -> WindowUtils#example 11
from keyio.windowutils import WindowUtils
window_utils = WindowUtils()
window_utils.set_foreground_window(0, 0, 800, 625)(3-C) Set Position of Selected Windowmove_foreground_window(self, sx : int, sy : int, flag : int = 0x0040) -> WindowUtils#example 12
from keyio.windowutils import WindowUtils
window_utils = WindowUtils()
window_utils.move_foreground_window(0, 0)(3-D) Flag ListWindowUtils.WindowFlagsWindowFlagsValueDescriptionSWP_DRAWFRAME0x0020~SWP_FRAMECHANGED0x0020~SWP_HIDEWINDOW0x0080~SWP_NOACTIVATE0x0010~SWP_NOCOPYBITS0x0100~SWP_NOMOVE0x0002~SWP_NOSIZE0x0001~SWP_NOREDRAW0x0008~SWP_NOZORDER0x0004~SWP_SHOWWINDOW0x0040~SWP_NOOWNERZORDER0x0200~SWP_NOREPOSITION0x0200~SWP_NOSENDCHANGING0x0400~SWP_DEFERERASE0x2000~SWP_ASYNCWINDOWPOS0x4000~