Imagine the power of AHK (File/OS/Keyboard/Mouse/GUI Management) in the hands of JavaScript.
Imagine the ecosystem of JavaScript libraries (jQuery, CreateJS, etc.) in the hands of AHK.
Exo makes this happen!
Description
Exo exposes most built-in commands/functions/variables of AHK to JavaScript, allowing you to practically write AHK inside JS (with JS syntax).
There are several advantages to using JS, rather than AhkScript:
- A lot of people are already familiar with JS, so there's no need to learn the peculiarities of the AhkScript-syntax.
- Gain access to a huge repository of libraries written in JS.
- You can use JS-specific constructs (eval, anonymous functions, prototype, etc.).
- You get to code in your favorite JS editor (IDE).
It does all this by embedding a browser (Internet Explorer) and hooking into it with ComObject. It then bridges the JS global functions to their AHK counterpart.
Goals
While migrating the keywords, the following goals were set:
- try to port 100% of the functionality (89% achieved)
- try as much as possible to conform with the AHK documentation
- provide useful typing (i.e. we shouldn't return String types everywhere only because it's easy)
Launch Exo with a ".js" file argument (either through drag-and-drop, or from the command-line):
> Exo.ahk "demo.js"
Sample code:
Code: Select all
alert(A_Now);
FileAppend('Hello, World!', 'hello.txt')
var list = Loop('*.txt');
for (var i = 0; i < list.length; i++) {
var fileProperties = list[i];
MsgBox(fileProperties.LongPath);
}
Sleep(1000);
ExitApp();
The GitHub readme lists all relevant AHK keywords (Commands, Function, Directives and Variables) and illustrates their counterpart in JS. In most cases, there is no significant change and everything is intuitive.
The breakdown for the 470 keywords:
- 0) 13% were disregarded because they provided duplicate functionality
- 1) 37% were directly migrated (AHK Functions became JS Functions, AHK Variables became JS Variables)
- 2) 33% were migrated through subtle conversion (AHK Commands became JS Functions)
- 3) 6% were migrated through minor adjustment (AHK multiple-OutputVars became JS return Objects)
- 4) 7% could not be migrated, but there are alternatives or future prospects of being implemented.
- 5) 4% will never be migrated (mainly Directives and some very specific AHK Commands)