Instructions Info¶
In apparser.instructions, every concrete instruction inherits from
BaseInstruction and must define the id property. This numeric
identifier is used for instruction lookup by number and for scenarios where an
instruction is described as (instruction_id, instruction_args).
How id lookup works¶
The base contract is defined in
apparser.instructions.base.BaseInstruction: theidproperty is required and must return anint.get_instruction_by_id()accepts only an integer and requiresinstruction_id >= 0.Lookup is performed by exact
idmatch without creating an instruction instance.If no match is found,
InstructionWithIdNotFoundExceptionis raised.iduniqueness is not validated separately. Based on the current implementation, if duplicates appear, the first matching class will be returned.
Lookup is performed through get_all_instructions(), which scans the
default, ocr, speak, and ui packages and keeps only concrete,
non-abstract instruction classes.
Important
Algorithm instructions currently not included in
get_instruction_by_id().
Current numbering layout¶
In the current codebase, identifiers are effectively grouped as follows:
1-999- base instructions fromapparser.instructions.default1000-1499- UI instructions fromapparser.instructions.ui1500-1999- algorithms fromapparser.instructions.ui.algorithms2000-2999- OCR instructions fromapparser.instructions.ocr3000-3999- speech instructions fromapparser.instructions.speak
Numbering does not need to be continuous: the code only requires a non-negative
id and no conflicts between classes that should be resolved by numeric
identifier.
Instructions available through get_instruction_by_id()¶
|
Class |
Purpose |
|---|---|---|
|
|
Perform a mouse click |
|
|
Press a single key |
|
|
Press a key combination |
|
|
Type text from the keyboard |
|
|
Play audio through an output device |
|
|
Play audio through a device used as a microphone target |
|
|
Play an audio file |
|
|
Play an audio file through a device used as a microphone target |
|
|
Pause execution for a fixed amount of time |
|
|
Bring the window to the foreground |
|
|
Send the window to the background |
|
|
Move the window |
|
|
Resize the window |
|
|
Move the mouse cursor |
|
|
Move the cursor to a point and click |
|
|
Read text from a screen region |
|
|
Move the cursor to matched text |
|
|
Find text and click it |
|
|
Print all detected text blocks |
|
|
Draw detected text on top of a screenshot |
|
|
Synthesize text and play it as regular audio |
|
|
Synthesize text and play it through a device used as a microphone target |
Classes with their own id but not resolved by get_instruction_by_id()¶
|
Class |
Purpose |
|---|---|---|
|
|
Sequentially execute regular and UI instructions |
|
|
Execute instructions described by numeric |
|
|
Execute instructions described by class names and arguments |
|
|
Execute instructions with a provided |
|
|
Execute instructions with a provided |
|
|
Inject dependencies into instructions by argument type |