79585529

Date: 2025-04-22 00:46:39
Score: 0.5
Natty:
Report link

I worked it out! It was rather simple.

launch.bat

@echo off

:: Assumes native_bridge.py and the 'venv' folder are in the same directory as this batch file.

:: Path to venv python relative to this batch file
set VENV_PYTHON="%~dp0venv\Scripts\python.exe"

:: Path to the python script relative to this batch file
set SCRIPT_PATH="%~dp0native_bridge.py"

:: Define log file paths relative to this batch file's location
set STDOUT_LOG="%~dp0native_bridge_stdout.log"
set STDERR_LOG="%~dp0native_bridge_stderr.log"

:: Execute the script using the venv's python, redirecting output
%VENV_PYTHON% %SCRIPT_PATH% > %STDOUT_LOG% 2> %STDERR_LOG%

com.nativebridge.test.json

{
  "name": "com.nativebridge.test",
  "description": "Persistent event bridge",
  "path": "C:\\NativeBridgeTest\\native_host\\launch.bat",
  "type": "stdio",
  "allowed_origins": [
    "chrome-extension://fedjpkbjlhmmnaipkljgbhfofpnmbamc/"
  ]
}

As you can see the manifest is launching launch.bat. Great. My AHK script sends messages down the pipe, they arrive in native_bridge.py but never reach the browser? Why? Because I'm redirecting stdout of native_bridge.py for logging... Well whatever I guess I worked it out. I'll leave this repo public in it's fixed state in case anyone wants to copy it in future.

Reasons:
  • Blacklisted phrase (0.5): Why?
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Modf