Learn How to Pass arguments to a Python Script and run it using Autohotkey Macro in Windows

Learn  How to Pass arguments to a Python Script and run it using Autohotkey Macro in Windows

Here I have provided you with a two little scripts that work in harmony. You can call a python script and provide arguments to it.

The script is called using an autohotkey script. Enjoy

The code is given below

Breakdown of Above Scripts

Arguments.py

This script on line 5 requests for an argument in command line.

Line 6 receives all the passed arguments

Line 8 gets the actual argument’s value in “value” variable.

Line 9 obviously prints it on the screen.

execute_python_with_args.ahk

Line 6 stands for the hotkey of WIN+CTRL+SPACE

Line 7 opens a CMD terminal in windows

Line 9 keeps the autohotkey script waiting until CMD opens.

Line 10, 11 navigate to the script folder.

Line 12 executes the python script by passing the required arguments.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: