Created by Gabriezv1233
Welcome to PyMacro, a versatile and simple macro scripting system! This documentation covers all supported commands, configuration options, and usage.
You can find an example script loader at scriptloader.py.
Documentation by our savior ChatGPT (enhanced manually).
- Commands are separated by semicolons (
;
) unless redefined by a configuration option. - Arguments are separated by spaces.
- Variables can be defined and used in any command using
${var}
. - Environment variables are referenced using
${~envvar~}
(user) or${+envvar+}
(system). - Clipboard content can be referenced as
!{%clip%}
.
Configuration options allow customization of how the macro script behaves. They must be defined at the start of the script and begin with @
.
Disables warnings when the script attempts to modify system environment variables.
Example:
@DisableAdminVarWarning
Defines the character(s) used to split commands in the script. The default is ;
.
- Use
"\n"
to split commands by newlines, treating each non-blank line as a command. - Use any custom character or string for splitting.
Example:
@FuncSplit = "\n"
set var1 Hello
set var2 World
log ${var1} ${var2}
Defines the character(s) that mark the start of a comment. Text after the defined character(s) is ignored. The default is None
(comments disabled).
Example:
@CommentOverride = "//"
set var1 Hello; // This is a comment
log ${var1}; // Another comment
Disable Comments:
@CommentOverride = "None"
set var1 Hello; # This will NOT be treated as a comment
Move the mouse cursor to specific screen coordinates.
Syntax:
cursor {x} {y};
Arguments:
{x}
: Horizontal position in pixels. Supports math and variables.{y}
: Vertical position in pixels. Supports math and variables.
Examples:
cursor 500 300;
cursor ${x} + 50 ${y} - 100;
Simulate pressing or releasing a key.
Syntax:
key {key} [(press)/up/down];
Simulate pressing multiple keys simultaneously.
Syntax:
hotkey {key1} {key2} ... {keyN};
Pause the macro for a specified duration.
Syntax:
wait {time} [(ms)/s/sec];
Examples:
wait 1000 ms;
wait ${delay} * 2 s;
Type a string of text.
Syntax:
write {text};
Simulate mouse button actions.
Syntax:
mb {button} [(press)/up/down];
Simulate mouse wheel scrolling.
Syntax:
scroll {amount};
Arguments:
{amount}
: Scroll units. Supports math and variables.
Examples:
scroll -5;
scroll ${scrollSpeed} * 10;
Perform operations with the clipboard, including copying, pasting, clearing content, and accessing the clipboard value as a variable.
clip {copy/paste/paste-m/clear} {text};
You can access the current clipboard content directly using the special syntax !{%clip%}
. This allows you to use the clipboard content in variables or commands.
-
Basic Clipboard Operations:
clip copy Hello, World!; clip paste; clip clear;
-
Using
paste-m
for Compatibility:clip paste-m;
-
Accessing Clipboard Content as a Variable:
clip copy Clipboard Test!; set clipboardContent !{%clip%}; log Clipboard contains: ${clipboardContent};
Define, use, and delete variables.
Syntax:
set {varname} {value};
del {varname};
Retrieve, set, or delete environment variables.
Syntax:
set {~var~|+var+} {value};
del {~var~|+var+};
Pause the macro until a specific key or key combination is pressed.
Syntax:
continue {key};
Print a message to the console.
Syntax:
log {message};
Example Script:
@FuncSplit = "\n"
@CommentOverride = "//"
set text1 "Hello, Macro World!"
set text2 "Powered by PyMacro."
set combinedText "${text1} ${text2}"
// Simulate opening Notepad and typing text
hotkey win r
wait 500 ms
write notepad
key enter
wait 1 s
write ${combinedText}
key enter
write "Goodbye!"
Errors during command execution output the command and exception details. Example:
Error processing command: set x ${undefined_var} + 1
Exception: Invalid expression: ${undefined_var}. Error: name 'undefined_var' is not defined