Creating action mods

In ACC v.1.4.2, action mods were introduced. Action mods are actions that aren't built in to ACC, but can be created and shared by everyone. You can make an action mode in many different program languages; as long as the file can be executed by ACC, and returns something valid, ACC acts as if action mods are just like any other built in action.

This guide will provide examples on how to create action mods.

Who can create an action mod. Do I need to know how to code?

Anyone with a little bit of coding experience can create action mods. The default supported languages are;

  • PowerShell
  • Batch
  • Python

Creating an action mod (any language)

Action mods are placed in; Documents/AssistantComputerControl/mods. In here, each mod must have its own folder. In this folder, there must be a file called info.json. The content of the JSON file tells ACC what to expect from the action, how to handle it, who has made it and so on.

Example;

{
    "author": "Albert MN.",
    "title": "Example action",
    "description": "This action does X",
    "version": 1,
    "for_version": "1.4.2",
    "action_name": "test",
    "options": {
        "file_name": "myscript.bat",
    }
}

This info file tells ACC to execute a file called myscript.bat, which should be located in the same folder as the info file.

When file is executed, ACC looks for an output starting with the text [ACC RETURN]. The content of this line is the reponse to ACC on whether the action failed or was successful. It should be set up as follows;

[ACC RETURN] {status; true/false}, {optional success/error message}

Example;

echo [ACC RETURN] true, it worked!

This action can now be executed like any other ACC action, and is executed by the action name test.

Using parameters

If the action receives parameters (primary and/or secondary), ACC sends the parameters to the file as arguments when opening the file. It's different from programming language to programming language how the argument is handled, but it's passed none the less.

You can tell ACC whether a parameter is required by the action, by including both / either of these two options into the options action of info.json. Like this;

"requires_param": true,
"require_second_param": true

See The use of parameters ] acticle for more info on how parameters in general work in ACC.

Basic batch example

This is an example of a very simple, but fully working, action mod made with batch;

In the Documents/AssistantComputerControl/mods folder, a folder for the action mod is created. Let's call it batch_example. In this folder, there are the two following files;

  • info.json
  • myscript.bat
693693

The content of the info.json file is;

{
    "author": "Albert MN.",
    "title": "X action",
    "description": "This action does X",
    "version": 1,
    "for_version": "1.4.2",
    "action_name": "test_batch",
    "options": {
        "file_name": "myscript.bat",
        "requires_param": true,
        "require_second_param": false
    }
}

This file indicates that ACC should execute the file called myscript.bat and that a primary parameter is required, but the second is either not needed, or optional. It also indicates that at least ACC v1.4.2 is required to do this action.

The content of the myscript.bat file is;

echo off
set arg1=%1
echo [ACC RETURN] true, it worked and I got the parameter; %arg1%

That's it. Passing the test_batch action to ACC will now execute this file, that simply returns the message; "it worked and I got the parameter; {whatever parameter was passed}" to ACC.

In this file, before the ACC return line, you can include anything you want the action to do. There are no limits.

Basic Python example

Python is a popular language, but one that isn't included in Windows by default. This means the user would have to have Python installed on their computer, for ACC to be able to execute Python action mods.

This also means Python action mods differ a bit from Batch and PowerShell ones.

If the extension of the file ACC should execute ("file_name" in the "options" section of the info.json file) is .py, ACC will try to detect whether Python is installed on the computer. If it's not, ACC will tell the user that the action cannot be run. If the user does have Python installed though, it will simply execute the file with Python and send the parameters if there are any.

You can use the following two options for Python action mods, in the info.json file (under the "options" section);

"min_python_version": "X.X",
"max_python_version": "X.X",

Neither of the options are required, but can be used to require at least version X and no less than version X.

Example content of a Python action mod file;

import sys

print("This is not picked up by ACC!")
print("[ACC RETURN] true, It worked! :D Args; " + str(sys.argv[1]))

For more info on how to use parameters in Python mods (called "arguments" in Python), see here; https://www.pythonforbeginners.com/system/python-sys-argv