Create an HTML page with a button. in the button, add: onclick="console.log('AHK:spitMessage,Hello World!')"
At this point, you can see that message get logged in your console. When this happens, the callback function, which is monitoring the console will trigger.
ChromeInst := new Chrome("ChromeProfile", "--app=http://localhost/index.php") ;We'll run chrome in "app" mode, which strips out all the UI buttons. We can run a reg instance by removing --app=
PageInst := ChromeInst.GetPageByURL("http://localhost/index.php",,, "Callback") ;connect to the page we just launched.
PageInst.Call("Console.enable") ;make sure the console is enabled!!!
if (Event.Method == "Console.messageAdded" && InStr(Event.params.message.text,"AHK:") >= 1) ;we only want to run our function if the console message is prefixed with AHK:, however, you can change this if you want.
Text := Event.params.message.text
Split := StrSplit(Text, ",","AHK:") ;Turn our console message into an array, but we'll drop the AHK: from it.
fnName := Split ;Grab the name of our function
Split.RemoveAt(1) ;Drop function name from the array, all we need now are the params.
%fnName%(Split*) ; Call that function, passing in the rest of the array as parameters
msgBox, %msg% ;We'll show a messagebox with the first param you sent thru your console.