Skip to content

gabrielzv1233/PyMacro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyMacro Documentation

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).


Table of Contents

  1. General Syntax
  2. Configuration Options
  3. Command List
  4. Examples
  5. Error Handling

General Syntax

  • 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

Configuration options allow customization of how the macro script behaves. They must be defined at the start of the script and begin with @.

Available Options

1. @DisableAdminVarWarning

Disables warnings when the script attempts to modify system environment variables.

Example:

@DisableAdminVarWarning

2. @FuncSplit = "char(s)"

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}

3. @CommentOverride = "char(s)"

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

Command List

Cursor Control

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;

Key Press

Simulate pressing or releasing a key.

Syntax:

key {key} [(press)/up/down];

Hotkey Combination

Simulate pressing multiple keys simultaneously.

Syntax:

hotkey {key1} {key2} ... {keyN};

Wait

Pause the macro for a specified duration.

Syntax:

wait {time} [(ms)/s/sec];

Examples:

wait 1000 ms;
wait ${delay} * 2 s;

Write Text

Type a string of text.

Syntax:

write {text};

Mouse Buttons

Simulate mouse button actions.

Syntax:

mb {button} [(press)/up/down];

Scrolling

Simulate mouse wheel scrolling.

Syntax:

scroll {amount};

Arguments:

  • {amount}: Scroll units. Supports math and variables.

Examples:

scroll -5;
scroll ${scrollSpeed} * 10;

Clipboard Management

Perform operations with the clipboard, including copying, pasting, clearing content, and accessing the clipboard value as a variable.

Syntax

clip {copy/paste/paste-m/clear} {text};

Using Clipboard Content as a Variable

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.


Examples

  1. Basic Clipboard Operations:

    clip copy Hello, World!;
    clip paste;
    clip clear;
    
  2. Using paste-m for Compatibility:

    clip paste-m;
    
  3. Accessing Clipboard Content as a Variable:

    clip copy Clipboard Test!;
    set clipboardContent !{%clip%};
    log Clipboard contains: ${clipboardContent};
    

Variable Management

Define, use, and delete variables.

Syntax:

set {varname} {value};
del {varname};

Environment Variable Management

Retrieve, set, or delete environment variables.

Syntax:

set {~var~|+var+} {value};
del {~var~|+var+};

Continue

Pause the macro until a specific key or key combination is pressed.

Syntax:

continue {key};

Log

Print a message to the console.

Syntax:

log {message};

Examples

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!"

Error Handling

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

About

A simple macro language made in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages