The HTTP route is probably the right way to go. You can easily set up a small Server using Node.js Node.js, and have it spawn your AHK script using one of the Child Process functions. I don't know how the Chrome Extension security model works, so you might have to mitigate cross-site scripting concerns. I think that's solvable, but haven't done so.

Answer from Wade Hatler on Stack Overflow
🌐
GitHub
github.com › RichardX366 › AHKNodeJS
GitHub - RichardX366/AHKNodeJS: Allows for communication between AutoHotKey.exe and NodeJS, giving access to AHK functions in NodeJS.
Allows for communication between AutoHotKey.exe and NodeJS, giving access to AHK functions in NodeJS. - RichardX366/AHKNodeJS
Starred by 25 users
Forked by 8 users
Languages: JavaScript 76.6% | AutoHotkey 23.4%
🌐
AutoHotkey
autohotkey.com › boards › viewtopic.php
Communication between Autohotkey and Nodejs - AutoHotkey Community
"\TestNode.js" if !FileExist(jsPath) FileAppend, % script, % jsPath Run, % "node """ jsPath """",, Hide, PID Process, Wait, % PID OnExit( Func("CloseNode").Bind(PID) ) Gui, Add, ActiveX, w200 h100 vWB, Shell.Explorer WB.Navigate("http://127.0.0.1:3000/") Loop { Sleep, 100 coll := WB.document.getElementsByTagName("button") } until coll.length coll[0].addEventListener("click", Func("OnClick").Bind(WB)) Gui, Show Return OnClick(WB) { MsgBox, % WB.document.documentElement.outerHTML } GuiClose() { ExitApp } CloseNode(PID) { Process, Close, % PID }
🌐
AutoHotkey
autohotkey.com › boards › viewtopic.php
AHK and Node JS, communication possible? - AutoHotkey Community
I need your help with this, please! index.js ... const spawn = require('child_process').spawn ahk = spawn("C:/Program Files/AutoHotkey/v2/AutoHotkey64.exe", ['ahk/stdin.ahk']); dataString = ''; ahk.stdout.on('data', function (data) { dataString += data.toString(); let toSend = ''; for (let i = 0; i < data.length; i++) { toSend += String.fromCharCode(data[i]); } console.log(toSend); }); ahk.stdout.on('end', function () { console.log('end'); }); ahk.stdin.write('some example' + '\r\n'); This is ahk/stdin.ahk
🌐
AutoHotkey
autohotkey.com › boards › viewtopic.php
Using Node.js for stdout, how to listen stdin in AHKv2? - AutoHotkey Community
import { ChildProcessWithoutNullStreams, spawn } from "child_process"; const child = spawn("C:/Program Files/AutoHotkey/v2/AutoHotkey64.exe", ["C:/scripts/AutoHotkey/v2/myScript.ahk"]); and then I think I can do something like this: child.stdin.write("Up" + "\n"); setTimeout(() => { child.stdin.write("Left" + "\n"); }, 1000); setTimeout(() => { child.stdin.write("Stop" + "\n"); }, 2000); setTimeout(() => { child.kill(); }, 3000); From AHK side, how would I listen for these things so that the script stays open and listens?
🌐
Reddit
reddit.com › r/autohotkey › need to run node.js through autohotkey. so far my way is too slow.
Need to run node.js through autohotkey. So far my way is too slow. : r/AutoHotkey
December 8, 2018 - You need to add the "C:\My Scripts\Convex Hull" folder to your system path. That way you can run "node main.js" from any location, then the first "Run, cmd /k C:\My Scripts\Convex Hull" command will no longer be necessary.
🌐
Stack Overflow
stackoverflow.com › questions › 18483581 › how-can-i-activate-an-autohotkey-script-using-javascript
jquery - How can I activate an AutoHotkey script using JavaScript? - Stack Overflow

The HTTP route is probably the right way to go. You can easily set up a small Server using Node.js Node.js, and have it spawn your AHK script using one of the Child Process functions. I don't know how the Chrome Extension security model works, so you might have to mitigate cross-site scripting concerns. I think that's solvable, but haven't done so.

Answer from Wade Hatler on stackoverflow.com
🌐
Reddit
reddit.com › r/autohotkey › running autohotkey from javascript
r/AutoHotkey on Reddit: Running AutoHotkey from JavaScript
I have even searched for Chrome and Firefox plugins that wrap AutoHotkey :) It's a bit silly, but I'd be happy with bodgy solutions. I hope I didn't offend anyone by saying AHK is weird. It just makes me oddly uncomfortable. (I can't describe it better)
🌐
AutoHotkey
autohotkey.com › boards › viewtopic.php
What's the best way to send commands in a NODE JS console window? - AutoHotkey Community
Hello. So I basically a NODE JS script and I want to pass variables to it WHILE it's running. Unfortunately, these variables exist in an Autohotkey script.
Find elsewhere
🌐
AutoHotkey
autohotkey.com › boards › viewtopic.php
Javascript Wrapper (similar to Node.js) - AutoHotkey Community
FixIE(true) Gui Add, ActiveX, w800 h600 vwb, Shell.Explorer wb.Navigate("about:blank") blob = ( <script> function manualTrigger(){ var evt = document.createEvent('MouseEvents'); evt.initEvent("click", true, true); document.getElementById('btn').dispatchEvent(evt); } </script> <input type='button' id='btn' onclick='alert("JS says Hi!")' value='BUTTON'> <input type='button' onclick='manualTrigger()' value='BUTTON'> ) wb.document.write(blob) btn := wb.document.All.btn ComObjConnect(btn, "btn_") btn_onclick() { MsgBox, AHK says Hi!
🌐
Stack Overflow
stackoverflow.com › questions › 25582391 › is-it-possible-to-launch-a-node-js-program-from-outside-the-console
Is it possible to launch a node.js program from outside the console? - Stack Overflow

Yes, ahk supports running external executables and capturing their output. See the documentation

So, you use that to run your node command (something like c:\path_to_node\node.exe c:\path_to_script\script.js)

Answer from rollingBalls on stackoverflow.com
🌐
Stack Overflow
stackoverflow.com › questions › 44579210 › node-trigger-key-key-combination-on-server
node.js - Node - Trigger key/key combination on server - Stack Overflow
Though I have not used it myself. ... Sign up to request clarification or add additional context in comments. ... If you really like AutoHotkey, then you could simply trigger an AutoHotkey script from NodeJS.
🌐
Reddit
reddit.com › r/node › any currently updated library that can do something like autohotkey in on javascript?
r/node on Reddit: any currently updated library that can do something like autohotkey in on javascript?
April 8, 2022 - Comment deleted by user · thanks. actually, those are the 2 i am looking at right now. Robots seems to be the most used one, but it stopped being updated 2 years ago. and nuts look solid, but almost no people seem to be using it
🌐
Stack Overflow
stackoverflow.com › questions › 62580802 › how-to-exit-a-js-process-so-it-returns-a-stdout-value-to-ahk
How to exit a .JS process so it returns a StdOut value to AHK?

Your output is only the Process ID (PID). You need to run your .js in a WSH wrapper, and your .js needs to return StdOut as follows:

Here is the AHK "secret sauce" RunWaitStdOut:

MsgBox % RunWaitStdOut("C:\path_to_script\index.js")

RunWaitStdOut(command)
{
    shell := ComObjCreate("WScript.Shell")
    exec := shell.Exec(ComSpec " /c node " command)
    return exec.StdOut.ReadAll() 
}

And in the meantime, the end of your .js should have something like the following generating the StdOut:

    process.stdout.write("The Result this javascript returns to AHK is " + myValue);

And remember, StdOut is a string, so if your myValue is a number or such, you may need the toString() method (as OP noticed, per OP's comment):

    process.stdout.write( myValue.toString() );

Hth,

Answer from PGilm on stackoverflow.com
🌐
Reddit
reddit.com › r/autohotkey › would one of you give me a quick crash course in how to interact with javascript using ahk to manipulate webpages?
r/AutoHotkey on Reddit: Would one of you give me a quick crash course in how to interact with JavaScript using AHK to manipulate webpages?
Well, I don't know that I'm the best person to teach this topic, but I can certainly can point you to the references I used to learn. AHK Forums COM Object Reference - AutoHotkey Community ... Basic Webpage Controls With Javascript / Com - Tutorial - Tutorials ... Make Winhttp.waitforresponse() To Wait More Than 30 Seconds ... Urldownloadtofile - Look at the WinHttp Examples StackOverflow How to do logins using the WinHttpRequest COM - Stack Overflow autohotkey - WinHttpRequest timeouts - Stack Overflow Misc RESTful - Wikipedia The Component Object Model WinHttpRequest object HtmlFile Object - iHTMLDocument IE Com Object Practice Code Abbey - Interactive Problems Code Abbey - Social Web Scrapper I'll be happy to answer any questions you have.
🌐
npm
npmjs.com › search
keywords:ahk - npm search
Communication between AutoHotKey and NodeJS.
🌐
GitHub
github.com › relipse › JsRoboKey
GitHub - relipse/JsRoboKey: Cross-Platform Desktop Automation and Script utility inspired by AutoHotKey
rk.trayMsg('Hi','Check if JsRoboKey executable file exists...', function(){ alert(__APPFILEPATH__ + ' exists: ' + rk.fileExists(__APPFILEPATH__)); }); rk.trayMsg('About','Click to open the JsRoboKey website', function(){ rk.openUrl('http://github.com/relipse/JsRoboKey'); }); In order to make this a reality, I am going to need some passionate helpers to get this working, we need most all of the features which AutoHotkey has, and cross-platform.
Starred by 95 users
Forked by 4 users
Languages: C++ 98.7% | QMake 1.3%
🌐
AutoHotkey
autohotkey.com › board › topic › 66045-nodejs
node.js - Offtopic - AutoHotkey Community
July 25, 2024 - Node simply enters the event loop after executing the input script. Node exits the event loop when there are no more callbacks to perform. This behavior is like browser javascript—the event loop is hidden from the user.Isn't node a lot like ...
🌐
Npm
npm.io › search › keyword:autohotkey
Autohotkey | npm.io
libnut is an N-API module for desktop automation with node · GUIAutomationmousekeyboardscreenshotimagedesktopscreenrecognitionautohotkey4.2.0 • Published 1 year ago · 🦅 cli syntax highlighting: any function - any object - 176 languages · syntaxhighlightclicolorconsoleterminallanguagehighlight.jschalkobject1.0.1 • Published 6 years ago
🌐
Npm
npm.io › package › node-ahk
Node-ahk NPM | npm.io
const nodeahk = require('node-ahk'); const fs = require('fs'); const gui = new nodeahk() .import(fs.readFileSync(__dirname + '/index.ahk')) .run(); gui.import("string"); // Imports this string as autohotkey. gui.write("event", "message"); // Send a buffer to autohotkey.