Is there an online compiler?

Propose new features and changes
Bruttosozialprodukt
Posts: 463
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

18 Oct 2017, 05:33

If performance is not an issue, you could use an emulator. QEMU probably being the most popular one on Linux for x86 emulation.
But expect extremely terrible performance. Several hours for the boot wouldn't surprise me at all.

For a translation layer, well on the one side we have the ZenFone which, thanks to its CPU, can translate ARM instructions to x64 instructions without major performance issues.
And software-wise I'm only aware of Wine which can translate Win32 functionality to its Linux equivalents, but only for the same architecture.

About your "solutions":
- Parallels just seems to a a remote access application, similar to OpenVNC or TeamViewer.
- CrossOver on Android seems to heavily rely on Intel's ARM to x64 translation magic and thus would only work on the ZenFone and some ChromeBooks apparently.
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: Is there an online compiler?

18 Oct 2017, 07:58

Or you just can use Resource Hacker™ a Perfect Working .exe to .ahk compiler
Bruttosozialprodukt
Posts: 463
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

18 Oct 2017, 08:01

We've been through this. We are talking about actually running AHK code. Besides that, the tool you linked does not look like it would run on either Linux or ARM, not to mention the two combined.
murataygun
Posts: 104
Joined: 07 Aug 2015, 15:53

Re: Is there an online compiler?

10 Jan 2019, 08:24

Bruttosozialprodukt wrote:
20 May 2016, 02:48
An online compiler should be pretty easy to set up if you have a windows server.
In node.js it could be something as simple as that:

Code: Select all

var fs = require('fs');
var express = require('express');
var app = express.createServer();
var bodyParser = require('body-parser');
var execFile = require('child_process').execFile;

app.use(bodyParser.urlencoded({
  extended: true
})); 

app.post('/ahk-online-compiler', function(req, res) {
    fs.writeFile("%temp%/script.ahk", req.body.scriptcode, function(err) {
        if (!err) {
            exexFile("%programfiles%/AutoHotkey/Compiler/Ahk2Exe.exe",  "/in %temp%/script.ahk /out %temp%/script.exe", function(err, stdout, stderr) {
                if (!err) {
                    res.sendFile("temp%/script.exe");
                }
            });
        }
    }); 
});

app.get('/ahk-online-compiler', function(req, res) {
    var htmlCode = `
      <!DOCTYPE html>
      <html>
        <head>
          <title>AHK Online compiler</title>
        </head>
        <body>
          <form action="/ahk-online-compiler" method="post">
            <textarea name="scriptcode"></textarea>
            <input type="submit" value="Compile">
          </form>
        </body>
      </html>
    `;
    res.send(htmlCode);
});
(untested)
Can you give a little more info about this please. Thats what i need right now.
Bruttosozialprodukt
Posts: 463
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

21 Feb 2019, 16:58

Sure, you just need a Windows machine and install autohotkey and node.js on it. Then you create a new folder and put these files in it:

install.bat

Code: Select all

npm i express body-parser
start.bat

Code: Select all

node index.js
index.js

Code: Select all

var fs = require('fs');
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var execFile = require('child_process').execFile;

app.use(bodyParser.urlencoded({
  extended: true
})); 

app.post('/ahk-online-compiler', function(req, res) {
    console.log(req.body.scriptcode)
    fs.writeFile("%temp%/script.ahk", req.body.scriptcode, function(err) {
        if (!err) {
            exexFile("%programfiles%/AutoHotkey/Compiler/Ahk2Exe.exe",  "/in %temp%/script.ahk /out %temp%/script.exe", function(err, stdout, stderr) {
                if (!err) {
                    res.sendFile("temp%/script.exe");
                } else {
                    res.status(500).send("Compiling the script failed!");
                }
            });
        } else {
            res.status(500).send("Saving the script failed!");
        }
    }); 
});

app.get('/ahk-online-compiler', function(req, res) {
    var htmlCode = `
      <!DOCTYPE html>
      <html>
        <head>
          <title>AHK Online compiler</title>
        </head>
        <body>
          <form action="/ahk-online-compiler" method="post">
            <textarea name="scriptcode" placeholder="Paste your script code here..."></textarea>
            <input type="submit" value="Compile">
          </form>
        </body>
      </html>
    `;
    res.send(htmlCode);
});

app.listen(3000, function () {
  console.log('AhkOnline is listening on port 3000! Try http://localhost:3000/ahk-online-compiler');
});
Then run install.bat to install the dependencies. Then you can start the nodejs server by running the start.bat and check if it works in your browser by opening: http://localhost:3000/ahk-online-compiler
Last edited by Bruttosozialprodukt on 28 Feb 2019, 15:53, edited 1 time in total.
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: Is there an online compiler?

22 Feb 2019, 13:46

Let me brainstorm a bit here.

Could an official online compiler be useful in response to the problem of false positives for compiled AutoHotkey scripts?

I'm thinking it would enable an intermediary between
(1) the script developer posts a compiled binary .exe and the user chooses to trust that there is nothing malign in the binary
(2) the script developer posts only the .ahk source and the users have to install AutoHotkey and compile it themselves

Is it also possible to create deterministic binaries with AutoHotkey? I mean binaries that are identical given the same .ahk input and given the same version of AutoHotkey regardless of what PC and what Windows version they're compiled on. If possible then an official online compiler might help even more with the false positives problem. Since everyone, including the anti-malware vendors, could then check if a script binary is compiled from the .ahk source and AutoHotkey version that it is claimed to be compiled from by running the .ahk code through the online compiler and then compare hashes for the binaries.

It might also be possible to create some automatic build service for AutoHotkey scripts on GitHub and GitLab. Developers could then push .ahk code updates and binaries would be automatically created using the trusted official online compiler.
Bruttosozialprodukt
Posts: 463
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

28 Feb 2019, 12:49

Having a trusted source that compiles the script for you would indeed be a nice thing to have. For source code that compiles on Linux, TravisCI and GitLab CI are very commonly used.

The AHK compiler essentially just makes a copy of autohotkey.exe and adds the script as a resource to it. So yes, builds are reproducible as long as the AHK version is the same.

Since you can probably compile AHK scripts on Linux using Wine, you could create a GitHub or GitLab repository and set it up with TravisCI/GitLab CI + a Wine docker image with AHK installed and make it automatically compile your code + release the binaries every time you commit code changes to the repository.
It would be pretty trivial to set something like that up, but everyone would have to set up their own repositories.

If anyone would like to see that, I might be willing to give it a shot.


edit:
I think it would actually be possible to set up a website that compiles AHK scripts using client-sided JavaScript with https://developer.mozilla.org/en-US/docs/Web/API/FileReader
This way you wouldn't waste server resources.
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: Is there an online compiler?

03 Mar 2019, 16:23

Bruttosozialprodukt wrote:
28 Feb 2019, 12:49
The AHK compiler essentially just makes a copy of autohotkey.exe and adds the script as a resource to it. So yes, builds are reproducible as long as the AHK version is the same.
Good. I assume that in addition to AutoHotkey version differences the exe would also vary with the file encoding of the .ahk source file. Still useful.
Bruttosozialprodukt wrote:
28 Feb 2019, 12:49
Since you can probably compile AHK scripts on Linux using Wine, you could create a GitHub or GitLab repository and set it up with TravisCI/GitLab CI + a Wine docker image with AHK installed and make it automatically compile your code + release the binaries every time you commit code changes to the repository.
It would be pretty trivial to set something like that up, but everyone would have to set up their own repositories.
I don't think setting something like that up indvidually would help much with the false positives issue, since it is only a shifts from "blindly trust my binary" to "blindly trust my personal online compiler". To do better there'd need to be one single online compiler set up transparently and by some trusted party. Another approach is to have a single trusted online de-compiler/analyzer. It would take compiled AHK scripts as input and unpack them, hash verify that the autohotkey.exe component is not tampered with and output the source .ahk file and any other unpacked files. Developers could then compile and host binaries themselves but also submit/link each new compiled version to the de-compiler and get a "test results" page there to link back to.
Bruttosozialprodukt
Posts: 463
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

04 Mar 2019, 02:55

I don't think that a different script name would change the result. There are however other properties that you can add when compiling the script that would cause a different output.

I wouldn't be blindly trusting your compiler. I would only blindly trust the TravisCI or GitLab server. The exact commands that are used to compile the script are transparent.
And I would trust both of these.
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: Is there an online compiler?

08 Mar 2019, 03:16

Bruttosozialprodukt wrote:
04 Mar 2019, 02:55
I don't think that a different script name would change the result. There are however other properties that you can add when compiling the script that would cause a different output.
I didn't mean filename but file encoding. Even though UTF-8 BOM is strongly adviced in the AutoHotkey FAQ some .ahk files online have other encodings. For example IIRC .ahk pasted into github using the web interface default to UTF-8 encoding (without BOM) when later downloaded.
Bruttosozialprodukt wrote:
04 Mar 2019, 02:55
I wouldn't be blindly trusting your compiler. I would only blindly trust the TravisCI or GitLab server. The exact commands that are used to compile the script are transparent. And I would trust both of these.
I see. I don't know much about TravisCI. Do you know if it can be set to show the hashes for the binary compiler and all other files thare are used? Otherwise I imagine a weak point would be that a malignant actor could modify the AutoHotkey binaries before uploading them to their TravisCI system. If on the other hand the hashes are shown then there would be a way to verify the integry of the compiler, especially if autohotkey.com also began posting file hashes for each release.
Bruttosozialprodukt
Posts: 463
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

09 Mar 2019, 05:03

Yes it can be set up to execute anything that can be executed from the commandline in Linux.
And you don't upload the autohotkey.exe, you write a script that tells the CI how to download it from the official website.

Also, if you upload your file to github the normal way, the encoding would not change. You should avoid the webinterface to modify your files. Just install git on your computer and run:

Code: Select all

git add myscript.ahk
git commit -m "my commit msg..."
git push -u origin master
to upload your file or changes the repository.
PhoenixArising
Posts: 1
Joined: 05 Mar 2021, 18:26

Re: Is there an online compiler?

05 Mar 2021, 19:42

While I know this topic has gone stale, I'd like to return back to the neosickle's original request just in case it helps someone. I've been at jobs where computers are extremely locked down, like at call centers. Or college student computer labs. While the request was for an online compiler, there are a couple of other ways around this issue.

Text Editor: There are multiple text editors out there that don't require installation. There are also online text editors. Just search for "text editor no install". If you are doing option #3 below, most cloud drives have text editing capabilities.

Running/Compiling Scripts:

Option 1: As mentioned here: https://autohotkey.com/board/topic/8863-run-script-without-autohotkey-installed/, you can run uncompiled AHK scripts without having AutoHotkey installed on the computer. Download the ZIP version of the installer by going to https://www.autohotkey.com/download/. Unzip the downloaded file. Contained within are three EXE's - ASCII 32-bit (AutoHotkeyA32.exe), Unicode 32-bit (AutoHotkeyU32.exe) and Unicode 64-bit (AutoHotkeyU64.exe). While the post above mentioned making shortcuts or batch files, you can also just drag the AHK script onto the AutoHotkey EXE of your preference. That's right - drag and drop and it launches the script - no install needed.

Option 2: A slight variation on Option #1 - once you have the ZIP version of AHK extracted, notice the "Compiler" folder. Contained within that folder is Ahk2Exe.exe, the AHK Compiler. If you double click on it a GUI will launch which gives you the option to compile a script. Again - no install needed.

Option 3: Are you ready for that remote compiler? You can easily set one up with the help of Google Drive, OneDrive, etc. On your Windows computer at home, install the client for your cloud drive. (For Google Drive it is called "Backup and Sync". For OneDrive, it is integrated into Windows.) In a folder within your cloud drive, save and run this script:

Code: Select all

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance force

;---------------------------------------------
; Compile any *.ahk files in this folder
Loop
{
    Loop, Files, %A_ScriptDir%\*.ahk
    {
        ; ignore this script
        if(A_LoopFileName == A_ScriptName)
            Continue

        fileNameNoExtension := SubStr(A_LoopFileName, 1, StrLen(A_LoopFileName)-4)

        ; if the script is already compiled, ignore
        if(FileExist(fileNameNoExtension . ".exe"))
            continue

        ; compile script
        Run, Ahk2Exe.exe /in "%A_LoopFileName%"
    }
    Sleep, 60000
}

This script will automatically compile any AHK files dropped into the same folder as this script. When you are at work/school, pull up the web interface to your cloud drive. To compile a new script, upload the script to this folder and it will be compiled, then download it to your work computer. To edit a script already in the folder, most cloud drives have text editors, so you can edit the script (or even create a new one) right through your browser. Then delete the existing compiled script, and the newly edited script will get compiled. (The drawback to this option is that you have to leave on your home computer and the script has to remain running.)
User avatar
lmstearn
Posts: 688
Joined: 11 Aug 2016, 02:32
Contact:

Re: Is there an online compiler?

07 Mar 2021, 08:17

tidbit wrote:
04 May 2016, 09:36
once upon a time someone made one:
https://autohotkey.com/board/topic/76002-cloudahk-cloud-compiling/page-1
links are long since dead.
Looks like it has been updated, and very much worth a look! :)
https://cloudahk.com
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
gregster
Posts: 8921
Joined: 30 Sep 2013, 06:48

Re: Is there an online compiler?

07 Mar 2021, 11:11

lmstearn wrote:
07 Mar 2021, 08:17
tidbit wrote:
04 May 2016, 09:36
once upon a time someone made one:
https://autohotkey.com/board/topic/76002-cloudahk-cloud-compiling/page-1
links are long since dead.
Looks like it has been updated, and very much worth a look! :)
https://cloudahk.com
Sure, that's a nice project by our forum member GeekDude (topic -> see here) - but it has no relation to the original online compiler that was once hosted there in 2012, afaik.
That said, GeekDude's project is probably more interesting ;)

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 33 guests