Class RobotKeys
Intro
RobotKeys
class allows for a quick way to emulate keyboard input.
Keyboard input can be directed a active window or a Specific window can be specified.
Many ready made keyboard command have been put together. The following list can be found in Keys.
Examples:
This Simple example sends ALT+s
to the current focused window.
from odevgui_win.robot_keys import RobotKeys
from odevgui_win.class_args.send_key_info import SendKeyInfo, KeyCodes
from odevgui_win.keys.writer_key_codes import WriterKeyCodes
RobotKeys.send(SendKeyInfo.from_code_str(KeyCodes.ALT, "s"))
Sometimes you may need to focus window before sending keys.
In this example key are sent specifically to Calc Window with myfile.ods
open.
from odevgui_win.robot_keys import RobotKeys, SendKeyInfo, WindowTitle
from odevgui_win.keys.calc_key_codes import CalcKeyCodes
RobotKeys.send(
SendKeyInfo(CalcKeyCodes.TOGGLE_GRID_LINES),
WindowTitle(title="myfile.ods - LibreOffice Calc")
)
Class
- class odevgui_win.robot_keys.RobotKeys[source]
Robot Keys
- static send(key: SendKeyInfo) None [source]
- static send(key: SendKeyInfo, *titles: WindowTitle) None
Emulates typing keys with keyboard.
If titles are include then the first matching title will have keys sent to it.
- Parameters:
key (SendKeyInfo) – Keys to emulate
*titles – Optonal expandable list of
ooodev.utils.data_type.window_title.WindowTitle
- Raises:
ElementNotFoundError – If titles are include but no title is matched.
- Return type:
None
Note
There are many include keyboard shortcuts for LibreOffice included in this package.
- static send_current(key: SendKeyInfo) None [source]
Sends key to the current LibreOffice window. Assumes window was created with
ooodev.utils.lo.Lo.load_office()
.- Parameters:
key (SendKeyInfo) – Keys to emulate
- Raises:
ElementNotFoundError – If unable to find and focus window.
- Return type:
None
Note
There are many include keyboard shortcuts for LibreOffice included in this package.