Firefox Native Messaging

Get help with using AutoHotkey and its commands and hotkeys
Posts: 19
Joined: 05 Aug 2015, 03:19

Firefox Native Messaging

17 Mar 2017, 09:17

I'm studying the native messaging used in Firefox WebExtension, but it only provides example in Python.

It says:
App side

On the application side, you use standard input to receive messages and standard output to send them.

Each message is serialized using JSON, UTF-8 encoded and is preceded with a 32-bit value containing the message length in native byte order.

Currently I know FileAppend can do the stdout and JXON library can dump object to json string, but how do I produce the "32-bit value" and how to combine this value with following string?
Posts: 397
Joined: 04 Mar 2016, 04:33
GitHub: qwerty12

Re: Firefox Native Messaging

21 Mar 2017, 10:13

Here's a conversion of the Python sample Mozilla provide, using cocobelgica's JXON library:

Code: [Select all] [Expand] [Download] (ping_pong.ahk)GeSHi © Codebox Plus

I tested it here (AutoHotkey A32 and U64 with Firefox 54.0a2) and it worked fine. However, there's an important step you need to perform: with either the compiled script or a copy of an AutoHotkey exe, you need to edit it so that it uses the console subsystem instead of AutoHotkey's default of the GUI subsystem. I used CFF Explorer to do it (Nt Headers -> Optional Header -> Subsystem: Windows Console), but I know Lexikos wrote an AutoHotkey script to do it as well - I just can't remember where. :) After that, just edit the batch file to run your compiled exe/console-subsystem-using-AutoHotkey.exe.

Return to “Ask For Help”

Who is online

Users browsing this forum: dontetris, eagerahk, liij, masheen, Taurus, UpgrAde, Yahoo [Bot] and 48 guests