Switch a Pacto Tech controller between 2 player, 4 player, twinstick, d-pad, analog, keyboard mode and more from a batch file, a front end, PowerShell, Python, AutoHotkey or Linux — and read the current mode back.
Before you script anything: try Game profiles.
If what you want is “this game should always start in 4 player”, “twinstick for Robotron”, “turbo for shmups” or “keyboard mode for this gamepad game”, the Pacto Tech Utility already does it by itself: it sees which game, emulator or front end is running, switches the controller, and puts it back when the game ends. Nothing to launch, nothing to time — and it can do things scripts cannot, such as turbo, per-game button remaps and the exit combo.
Use the scripts on this page when you want a front end, a launcher, a hotkey tool or your own program to be in charge.
While the Pacto Tech Utility runs (it sits in the tray and starts with Windows by default), it listens on a fixed local address that is the same on every PC:
http://127.117.73.87:47391
Opening /mode/<name> on that address switches the controller straight away —
no setup, no password. It only answers programs on the same PC, so nothing on your network
can reach it. On Linux, the PactoLink service does the same job.
| Group | Names |
|---|---|
| Player layout | 2p 4p twinstick twinstick-1p twinstick-2p |
| Stick output | dpad analog-fast analog-slow |
| Keyboard mode | keyboard-on keyboard-off |
| 8-to-6 | 8to6-on 8to6-off |
| Interlock | interlock-on interlock-off |
The answer is plain text: ok: 4 Player on success, or an error such as
controller rejected the command (not connected, or a kiosk lock refused it).
/modes lists every name.
Keyboard mode makes the controller restart as a keyboard (it disappears for a moment — that is normal). Coming back to gamepad mode takes about 12 seconds so Windows can forget the old controller.
One file per mode, per method — nothing to edit. Click to download a single file, or get them all:
PactoTech-Control-Examples.zip
(folder ready-made).
| Mode | Silent VBS | Batch | PowerShell | Python | AutoHotkey | Linux |
|---|---|---|---|---|---|---|
| Keyboard / disconnect mode DongleMaster gamepads take over | vbs | bat | ps1 | pyw | ahk | sh |
| Leave keyboard mode back to arcade gamepads (~12 s) | vbs | bat | ps1 | pyw | ahk | sh |
| 2 player | vbs | bat | ps1 | pyw | ahk | sh |
| 4 player | vbs | bat | ps1 | pyw | ahk | sh |
| Analog fast | vbs | bat | ps1 | pyw | ahk | sh |
| D-pad | vbs | bat | ps1 | pyw | ahk | sh |
| Analog slow | vbs | bat | ps1 | pyw | ahk | sh |
| 8-to-6 on | vbs | bat | ps1 | pyw | ahk | sh |
| 8-to-6 off | vbs | bat | ps1 | pyw | ahk | sh |
| Method | Shows anything on screen? | Needs |
|---|---|---|
Silent VBS (.vbs) | Nothing at all | Nothing — built into Windows |
Batch (.bat) | A console window can flash for a moment | Nothing (uses the curl built into Windows 10/11) |
PowerShell (.ps1) | A brief flash, even with -WindowStyle Hidden | Nothing |
Python (.pyw) | Nothing (.pyw runs without a window) | Python 3 |
AutoHotkey (.ahk) | Nothing (no tray icon) | AutoHotkey v2 |
Linux (.sh) | Nothing | PactoLink on the cabinet |
Every script exits with code 0 when the mode switched and 1 (or another
non-zero code) when it did not — for example when the Utility is not running or no controller is connected.
Turbo on / off cannot be switched from a script yet. Use the board’s turbo button or switch, or set turbo per game on the Utility’s Game profiles page.
Most reliable: Game profiles, no scripts. The Utility recognises LaunchBox / Big Box, CoinOps, RetroFE and 30+ emulators by the program that is running, switches the controller when a game starts and puts it back when the game ends. Nothing to launch, nothing to time, nothing to fail.
If you want the front end itself in charge, use the silent VBS scripts. They show nothing on screen — so they never steal focus from the front end (a flashing console window can, and some front ends ignore the controls while they are not in focus) — and they need nothing installed.
.vbs files to a fixed folder, for example C:\Pacto.C:\Windows\System32\wscript.exe, command-line parameters
"C:\Pacto\Pacto - 4 Player.vbs", and tick Automatically run before main application."C:\Pacto\Pacto - 2 Player.vbs" and
Automatically run after main application to switch back afterwards.Point the launcher at wscript.exe and let launch-with-mode.vbs start the emulator.
It sets the mode, waits for the emulator to close, then switches back to 2 player:
executable = C:\Windows\System32\wscript.exe
arguments = "C:\Pacto\launch-with-mode.vbs" 4p "C:\Emulators\MAME\mame.exe" %ITEM_NAME%
Keep the emulator’s usual arguments after its path. (%ITEM_NAME% is RetroFE’s placeholder
for the game — use whatever your launcher file already passes.)
Microsoft plans to phase VBScript out of a future Windows version; it is still built in
and on by default in Windows 11 24H2 and 25H2. If it is ever removed, the .bat files do the same
job (with a brief window flash).
Paste into any browser on the same PC:
http://127.117.73.87:47391/mode/4p
For a one-click desktop shortcut: right-click the desktop → New → Shortcut, paste the address above, and name it “4 Player”.
curl is built into Windows 10 and 11:
curl -s http://127.117.73.87:47391/mode/twinstick
The Utility already writes one .bat per mode for you: App Settings →
External control → Open scripts folder (files like Pacto - 4 Player.bat).
They are identical on every PC, so they are safe to copy between cabinets.
pacto-mode.bat 4p
pacto-mode.bat keyboard-on
pacto-mode.bat (lists every mode)
Sets %ERRORLEVEL% to 1 and prints why when the switch fails, so a calling
script can react. The core of it:
@echo off
curl -s --fail-with-body --max-time 5 http://127.117.73.87:47391/mode/%~1
if errorlevel 1 echo Could not switch - is the Pacto Tech Utility running?
launch-with-mode.bat 4p "C:\Emulators\MAME\mame.exe" gauntlet
launch-with-mode.bat twinstick "C:\Games\Robotron\robotron.exe"
Sets the mode, starts the program, waits for it to close, then returns to
2p (change AFTER_MODE at the top to taste).
Double-click it and press a number. Handy on a cabinet keyboard or over remote desktop.
Easiest: Game profiles. The Utility’s Game profiles page switches modes (and turbo, remaps, keyboard mode…) automatically when it sees a game or front end start — no scripts at all. Use scripts when you want the front end in charge.
Pacto - 4 Player.bat (from the scripts
folder) as an Additional App set to run before the game, or put
curl -s http://127.117.73.87:47391/mode/4p in the emulator’s Running Script.launch-with-mode.bat <mode> <emulator> <args>, or call a mode
.bat from the per-game launcher.Invoke-RestMethod http://127.117.73.87:47391/mode/dpad
PactoApi.ps1 wraps the whole API in a few functions:
. .\PactoApi.ps1
Set-PactoMode 4p # switch (no token)
Get-PactoStatus # live modes (full API)
Watch-PactoModes { param($m) "now: $($m -join ', ')" } # react to every change
Standard library only:
import urllib.request
urllib.request.urlopen("http://127.117.73.87:47391/mode/twinstick").read()
pacto_mode.py is a small command line tool and module:
python pacto_mode.py 4p # switch
python pacto_mode.py --status # print the live modes (full API)
python pacto_mode.py --watch # print every change live (full API)
pacto-hotkeys.ahk (AutoHotkey v2) puts every mode on Ctrl+Alt+1…0 and shows the answer as a tooltip:
PactoMode(mode) {
req := ComObject("WinHttp.WinHttpRequest.5.1")
req.Open("GET", "http://127.117.73.87:47391/mode/" mode, false)
req.Send()
}
^!1:: PactoMode("2p")
^!2:: PactoMode("4p")
(The Utility also has built-in PC hotkeys on its Modes page if you would rather not install AutoHotkey.)
Beyond switching modes, the Utility can read the live mode and change remaps, keyboard maps, board settings and game profiles. This part needs a key:
%LOCALAPPDATA%\PactoConfigurator\agent_token.txt
(created on first start). Keep it private.Authorization: Bearer <key>.$tok = (Get-Content "$env:LOCALAPPDATA\PactoConfigurator\agent_token.txt" -Raw).Trim()
$h = @{ Authorization = "Bearer $tok" }
(Invoke-RestMethod http://127.117.73.87:47391/agent/status -Headers $h).status.modes
Invoke-RestMethod -Method Post http://127.117.73.87:47391/agent/mode -Headers $h `
-ContentType application/json -Body '{"mode":"8to6-on"}'
| Request | What it does |
|---|---|
GET /agent/status | live modes: {"status":{"modes":["2P","ANALOG_FAST"],"mode_flags":17,…}} |
GET /agent/state | everything: settings, board, modes, remaps, profiles, running game |
POST /agent/mode | {"mode":"4p"} — same names as above |
POST /agent/remap | {"profile":0,"map":{"12":13,"13":12},"save":true} — swap A and B |
POST /agent/param | {"id":1,"value":1,"save":true} — e.g. start up in 4 player |
POST /agent/profiles | add or change game profiles |
POST /agent/save | keep board changes after a power cycle |
GET /agent/prompt | the complete reference (no key needed) |
Windows: GET /agent/status (full API) returns the live modes.
There is no push stream on Windows yet, so check it every 250 ms or so — cheap, and
Watch-PactoModes / pacto_mode.py --watch do exactly that.
Linux: PactoLink pushes every change instantly — see below.
| mode_flags bit | Mode | bit | Mode |
|---|---|---|---|
0x0001 | 2P | 0x0080 | KEYBOARD |
0x0002 | 4P | 0x0100 | 8TO6 (left) |
0x0004 | TWINSTICK | 0x0200 | 8TO6 (right) |
0x0008 | DPAD | 0x0400 | TWINSTICK 1P |
0x0010 | ANALOG_FAST | 0x0800 | TWINSTICK 2P |
0x0020 | ANALOG_SLOW | 0x1000 | TURBO |
0x0040 | INTERLOCK |
The Linux side has only been tested in virtual machines so far — not yet on real cabinet hardware.
With PactoLink
installed, the cabinet serves the configurator and an API on port 46810
(on the cabinet itself use 127.0.0.1; from another machine use its IP).
curl -s -X POST -H "Content-Type: application/json" -d '{"id":1,"on":true}' \
http://127.0.0.1:46810/api/v1/invoke/set_mode
| id | Mode | id | Mode |
|---|---|---|---|
| 0 | 2 player | 6 | keyboard mode ("on":false = off) |
| 1 | 4 player | 7 | 8-to-6 (on / off) |
| 2 | twinstick | 8 | interlock (on / off) |
| 3 / 4 / 5 | d-pad / analog fast / analog slow | 9 / 10 | twinstick 1P / 2P |
pactolink-mode.sh
takes the same names as Windows: ./pactolink-mode.sh 4p.
curl -N http://127.0.0.1:46810/api/v1/events
Every change arrives at once as data: {"event":"pacto://status","payload":{"mode_flags":…}}.
pactolink_watch.py
turns that into mode names and reconnects by itself — put your own action in on_change().
batocera-mode-per-system.sh
goes in /userdata/system/scripts/; Batocera runs it at every game start and stop.
(For per-game settings, the Game profiles page of the PactoLink web page needs no script.)
From another machine, if the cabinet owner set a PIN, add
-H "X-Pacto-Pin: 1234". On the cabinet itself no PIN is needed.
| You see | Why / fix |
|---|---|
| Connection refused / not reachable | The Pacto Tech Utility is not running — start it (tray icon). |
controller rejected the command | No controller connected, or a kiosk lock blocks that mode. |
unknown mode | Typo in the name — /modes lists them. |
401 on /agent/… | Missing or wrong key (agent_token.txt). |
403 on /agent/… | “Allow local AI agents” is off in App Settings. |
| Controller vanishes for a moment | Normal after keyboard-on / keyboard-off: it restarts as a different device. |