- Introduction
- Developer Information
- Installation
- User Interface
- Configuration File (config.json)
- How Molly-macro Works
- Use Cases and Examples
- Linux Compatibility
- Windows Adaptation
- Troubleshooting
- Contributing
- License
Molly-macro is a sophisticated data transfer tool designed to automate the process of inputting data into various applications. It provides both a graphical user interface for easy operation and a command-line interface for advanced users and automation scenarios. Molly-macro is particularly useful in environments where traditional clipboard operations or file imports are restricted or unavailable.
- Developer: Jerry Keen
- Email: jkeen871@gmail.com
- Ensure you have Python 3.6 or later installed on your Linux system.
- Clone the Molly-macro repository:
git clone https://github.com/yourusername/molly-macro.git - Navigate to the project directory:
cd molly-macro - Install the required dependencies:
pip install -r requirements.txt
The main window of Molly-macro provides a user-friendly interface for configuring and executing data transfers. It consists of several key components:
- A dropdown menu allows users to select from pre-defined configurations stored in the config.json file.
- Each configuration represents a set of parameters for a specific application or scenario.
- Users can edit existing configurations or create new ones using the "Edit Config" button.
- Users can choose between using clipboard content or a file as the data source.
- A checkbox toggles between these two options.
- When "Use Clipboard" is unchecked, a file selection field and browse button become available.
- A dropdown menu lists all currently open windows.
- Users select the target window for the data transfer.
- A "Refresh" button updates the list of available windows.
- A checkbox enables debug logging for troubleshooting purposes.
- When enabled, detailed logs are generated during the transfer process.
- Displays the command that will be executed based on the current settings.
- Updates in real-time as users modify options.
- A progress bar shows the status of the ongoing transfer.
- Percentage completion is displayed numerically.
- The current status (e.g., "Running", "Completed") is shown in a status bar.
- A "View Content" button opens a new window displaying the content to be transferred.
- Supports both clipboard and file content.
- Content is displayed in a scrollable, formatted text area.
The config.json file is a crucial component of Molly-macro, containing detailed configurations for various applications and scenarios. This file allows users to customize the behavior of Molly-macro for different target applications.
The config.json file has the following high-level structure:
{
"applications": {
"app_name_1": {
// Application-specific configuration
},
"app_name_2": {
// Application-specific configuration
}
// ... more applications ...
}
}Each application configuration can include the following fields:
type(string): Specifies whether the application is "local" or "vdi" (Virtual Desktop Infrastructure).mode(string): Defines the input mode, e.g., "text", "spreadsheet", "code".WINDOW_TITLE(string): The title pattern to match for identifying the application window.DELAY_BETWEEN_KEYS(float): Time delay (in seconds) between individual keystrokes.DELAY_BETWEEN_COMMANDS(float): Time delay (in seconds) between separate commands or actions.APP_LOAD_TIME(float): Time (in seconds) to wait for the application to load after launching.CHUNK_SIZE(integer): Number of characters to send in each chunk during data transfer.DELAY_BETWEEN_CHUNKS(float): Time delay (in seconds) between sending chunks of data.launch_command(string, optional): Command to launch the application (for local applications).window_match(string): Pattern to match when searching for the application window.no_payload(boolean): If true, no data will be sent (useful for applications that only need to be opened).
The open_steps array defines a series of actions to be performed after the application window is found or launched. Each step is an object with the following properties:
action(string): The type of action to perform. Can be "key" (send a keystroke), "type" (type a string), "launch_window" (launch the application), or "raise_window" (bring the window to the foreground).value(string): The value associated with the action (e.g., the key to press or the string to type).
Here's a detailed example of a configuration for a text editor application:
{
"applications": {
"gnome_text_editor": {
"type": "local",
"mode": "text",
"WINDOW_TITLE": "Text Editor",
"DELAY_BETWEEN_KEYS": 0.05,
"DELAY_BETWEEN_COMMANDS": 0.1,
"APP_LOAD_TIME": 3.0,
"CHUNK_SIZE": 20,
"DELAY_BETWEEN_CHUNKS": 0.2,
"launch_command": "gnome-text-editor -s",
"window_match": "Text Editor",
"no_payload": false,
"open_steps": [
{
"action": "launch_window",
"value": ""
},
{
"action": "raise_window",
"value": ""
},
{
"action": "key",
"value": "ctrl+n"
}
]
}
}
}In this example:
- The application is a local GNOME Text Editor.
- It operates in text mode.
- There are specific delays defined for various operations.
- The application is launched using the
gnome-text-editor -scommand. - After launching, it waits 3 seconds for the app to load.
- The open steps launch the window, bring it to the foreground, and then open a new document (Ctrl+N).
Molly-macro operates by simulating keyboard input to transfer data into target applications. It uses a combination of Python scripts and system utilities to achieve this automation.
The core functionality is implemented in molly-macro.py, which accepts several command-line arguments:
-s: Spreadsheet mode-t: Text editor mode-i: Image transfer mode (placeholder for future implementation)-e: Code editor mode-w <window_id>: Specify the target window ID-c: Use clipboard contents as input-d: Enable debug logging--config <path>: Path to the JSON configuration file--config_name <name>: Name of the configuration to use--local: Indicate that this is a local configuration<path_to_file>: Path to the input file (when not using clipboard)
- Parse command-line arguments and load the specified configuration from config.json.
- Identify or launch the target application window using the
window_matchpattern. - Execute any specified "open steps" to prepare the application.
- Read input data from the clipboard or specified file.
- Transfer the data to the target window using simulated keystrokes, respecting the
CHUNK_SIZEand various delay settings. - Report progress and completion status.
Molly-macro uses the xdotool utility to interact with windows in the X Window System. It can:
- Search for windows by title or other attributes using the
window_matchpattern. - Activate, focus, and raise windows.
- Send keystrokes to specific windows, adhering to the
DELAY_BETWEEN_KEYSsetting.
The data transfer process is chunk-based to handle large volumes of data efficiently:
- The input is divided into manageable chunks based on the
CHUNK_SIZEsetting. - Each chunk is sent to the target window using simulated keystrokes.
- Delays between chunks (
DELAY_BETWEEN_CHUNKS) and keystrokes (DELAY_BETWEEN_KEYS) are applied to accommodate different application behaviors.
-
Transferring spreadsheet data to a VDI environment:
python molly-macro.py -s -c --config_name excel_vdiThis command transfers clipboard content to an Excel application in a VDI environment using the "excel_vdi" configuration.
-
Inputting code into a local IDE:
python molly-macro.py -e --config_name vscode --local /path/to/code.pyThis command inputs the contents of
code.pyinto a local Visual Studio Code instance, using the settings defined in the "vscode" configuration. -
Transferring text to a remote text editor:
python molly-macro.py -t -w 12345678 --config_name remote_notepadThis command sends clipboard content to a specific window (ID: 12345678) using the "remote_notepad" configuration.
Molly-macro is designed specifically for Linux systems due to its reliance on X Window System utilities, particularly xdotool. These tools provide low-level access to window management and input simulation, which are crucial for Molly-macro's functionality.
To adapt Molly-macro for Windows, several key changes would be necessary:
- Replace
xdotoolfunctionality with Windows-equivalent APIs (e.g., Win32 API or UI Automation). - Modify window management code to use Windows-specific methods for finding, activating, and focusing windows.
- Implement an alternative method for simulating keystrokes, possibly using the
SendInputfunction or similar Windows APIs. - Adjust the configuration structure in config.json to accommodate Windows-specific parameters and behaviors.
- Update file path handling and environment variable usage to align with Windows conventions.
These changes would require significant refactoring and testing to ensure compatibility and performance on Windows systems.
- Window not found: Ensure the target application is running and visible. Try refreshing the window list or adjusting the
window_matchpattern in the configuration. - Transfer not starting: Check that you have the necessary permissions to interact with the target window. Some applications or system settings may prevent automated input.
- Incomplete transfers: Adjust the timing parameters (
DELAY_BETWEEN_KEYS,DELAY_BETWEEN_CHUNKS) in the configuration. Some applications may require longer delays between keystrokes or chunks. - Garbled output: Verify that the input encoding matches the target application's expectations. You may need to modify the input preprocessing in extreme cases.
Contributions to Molly-macro are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes with clear, descriptive messages.
- Push your branch and submit a pull request.
Please ensure your code adheres to the project's styling guidelines and includes appropriate documentation and tests.
Molly-macro is released under the MIT License. See the LICENSE file in the repository for full details.