Awesome
Exo: JavaScript unleashed!
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!
Archived
Exo has been archived because it is somewhat outdated and is no longer actively maintained. Here are other paths to follow for OS automation through JS:
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). ... and more.
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)
Usage
Launch Exo with a ".js" file argument (either through drag-and-drop, or from the command-line).
> Exo.ahk "demo.js"
Sample code:
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();
About
- Authors: Aurelain (aurelain@gmail.com), with major contributions from Lexikos
- License: WTFPL
- Version: 0.96
- Minimum requirements:
- AutoHotkey v1.1.17.01
- Internet Explorer 8
- Windows XP
Migration Guide
This section 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 following 470 keywords:
- 0) 13% were disregarded because they provided duplicate functionality
-
- 37% were directly migrated (AHK Functions became JS Functions, AHK Variables became JS Variables)
-
- 33% were migrated through subtle conversion (AHK Commands became JS Functions)
-
- 6% were migrated through minor adjustment (AHK multiple-OutputVars became JS return Objects)
-
- 7% could not be migrated, but there are alternatives or future prospects of being implemented.
-
- 4% will never be migrated (mainly Directives and some very specific AHK Commands)
Keywords that were not migrated (categories 0, 4 and 5) are marked bold.
AHK Keyword | JS Implementation | JS Type |
---|---|---|
1, 2, 3, etc. | Replacement: "A_Args" | Array |
A_AhkPath | Identical | String |
A_AhkVersion | Identical | String |
A_AppData | Identical | String |
A_AppDataCommon | Identical | String |
A_AutoTrim | Not needed (AHK specific) | N/A |
A_BatchLines | Identical | String |
A_CaretX | Identical | String |
A_CaretY | Identical | String |
A_ComputerName | Identical | String |
A_ControlDelay | Identical | Number |
A_Cursor | Identical | String |
A_DD | Identical | String |
A_DDD | Identical | String |
A_DDDD | Identical | String |
A_DefaultMouseSpeed | Identical | Number |
A_Desktop | Identical | String |
A_DesktopCommon | Identical | String |
A_DetectHiddenText | Identical | String |
A_DetectHiddenWindows | Identical | String |
A_EndChar | Cannot use yet | N/A |
A_EventInfo | Identical | String |
A_ExitReason | Identical | String |
A_FileEncoding | Identical | String |
A_FormatFloat | Identical | String |
A_FormatInteger | Identical | String |
A_Gui | Identical | String |
A_GuiControl | Identical | String |
A_GuiControlEvent | Identical | String |
A_GuiEvent | Identical | String |
A_GuiHeight | Identical | Number |
A_GuiWidth | Identical | Number |
A_GuiX | Identical | Number |
A_GuiY | Identical | Number |
A_Hour | Identical | String |
A_IconFile | Identical | String |
A_IconHidden | Identical | Number |
A_IconNumber | Identical | String |
A_IconTip | Identical | String |
A_Index | Not needed (AHK specific) | N/A |
A_IPAddress1 | Identical | String |
A_IPAddress2 | Identical | String |
A_IPAddress3 | Identical | String |
A_IPAddress4 | Identical | String |
A_Is64bitOS | Identical | Number |
A_IsAdmin | Identical | Number |
A_IsCompiled | Identical | String |
A_IsCritical | Identical | Number |
A_IsPaused | Identical | Number |
A_IsSuspended | Identical | Number |
A_IsUnicode | Identical | String |
A_KeyDelay | Identical | Number |
A_Language | Identical | String |
A_LastError | Identical | String |
A_LineFile | Cannot use yet | N/A |
A_LineNumber | Cannot use yet | N/A |
A_LoopField | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileAttrib | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileDir | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileExt | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileFullPath | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileLongPath | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileName | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileShortName | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileShortPath | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileSize | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileSizeKB | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileSizeMB | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileTimeAccessed | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileTimeCreated | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopFileTimeModified | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopReadLine | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopRegKey | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopRegName | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopRegSubKey | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopRegTimeModified | Not needed as such (Returned by "Loop()"). | N/A |
A_LoopRegType | Not needed as such (Returned by "Loop()"). | N/A |
A_MDay | Identical | String |
A_Min | Identical | String |
A_MM | Identical | String |
A_MMM | Identical | String |
A_MMMM | Identical | String |
A_Mon | Identical | String |
A_MouseDelay | Identical | Number |
A_MSec | Identical | String |
A_MyDocuments | Identical | String |
A_Now | Identical | String |
A_NowUTC | Identical | String |
A_NumBatchLines | Identical | String |
A_OSType | Identical | String |
A_OSVersion | Identical | String |
A_PriorHotkey | Identical | String |
A_PriorKey | Identical | String |
A_ProgramFiles | Identical | String |
A_Programs | Identical | String |
A_ProgramsCommon | Identical | String |
A_PtrSize | Identical | Number |
A_RegView | Identical | String |
A_ScreenDPI | Identical | Number |
A_ScreenHeight | Identical | Number |
A_ScreenWidth | Identical | Number |
A_ScriptDir | Identical | String |
A_ScriptFullPath | Identical | String |
A_ScriptHwnd | Identical | String |
A_ScriptName | Identical | String |
A_Sec | Identical | String |
A_Space | Identical | String |
A_StartMenu | Identical | String |
A_StartMenuCommon | Identical | String |
A_Startup | Identical | String |
A_StartupCommon | Identical | String |
A_StringCaseSense | Identical | String |
A_Tab | Identical | String |
A_Temp | Identical | String |
A_ThisFunc | Not needed (AHK specific) | N/A |
A_ThisHotkey | Identical | String |
A_ThisLabel | Not needed (AHK specific) | N/A |
A_ThisMenu | Identical | String |
A_ThisMenuItem | Identical | String |
A_ThisMenuItemPos | Identical | String |
A_TickCount | Identical | Number |
A_TimeIdle | Identical | Number |
A_TimeIdlePhysical | Identical | Number |
A_TimeSincePriorHotkey | Identical | Number |
A_TimeSinceThisHotkey | Identical | Number |
A_TitleMatchMode | Identical | String |
A_TitleMatchModeSpeed | Identical | String |
A_UserName | Identical | String |
A_WDay | Identical | String |
A_WinDelay | Identical | Number |
A_WinDir | Identical | String |
A_WorkingDir | Identical | String |
A_YDay | Identical | String |
A_Year | Identical | String |
A_YWeek | Identical | String |
A_YYYY | Identical | String |
Abs() | Identical | Number |
ACos() | Identical | Number |
Array() | Not needed (AHK specific) | N/A |
Asc() | Identical | Number |
ASin() | Identical | Number |
ATan() | Identical | Number |
AutoTrim | Not needed (AHK specific) | N/A |
BlockInput | Normalization | Empty |
Ceil() | Identical | Number |
Chr() | Identical | String |
Click | Normalization | Empty |
Clipboard | Identical | String |
ClipboardAll | Identical | String |
ClipWait | Normalization | Empty |
ComObjActive() | Cannot use yet | N/A |
ComObjArray() | Cannot use yet | N/A |
ComObjConnect() | Cannot use yet | N/A |
ComObjCreate() | Cannot use yet | N/A |
ComObject() | Cannot use yet | N/A |
ComObjEnwrap() | Not needed (Deprecated) | N/A |
ComObjError() | Cannot use yet | N/A |
ComObjFlags() | Cannot use yet | N/A |
ComObjGet() | Cannot use yet | N/A |
ComObjMissing() | Not needed (Deprecated) | N/A |
ComObjParameter() | Cannot use yet | N/A |
ComObjQuery() | Cannot use yet | N/A |
ComObjType() | Cannot use yet | N/A |
ComObjUnwrap() | Not needed (Deprecated) | N/A |
ComObjValue() | Cannot use yet | N/A |
ComSpec | Identical | String |
Control | Normalization | Empty |
ControlClick | Normalization | Empty |
ControlFocus | Normalization | Empty |
ControlGet | Normalization | String |
ControlGetFocus | Normalization | String |
ControlGetPos | Minor change (returns Object) | {} |
ControlGetText | Normalization | String |
ControlMove | Normalization | Empty |
ControlSend | Normalization | Empty |
ControlSendRaw | Normalization | Empty |
ControlSetText | Normalization | Empty |
CoordMode | Normalization | Empty |
Cos() | Identical | Number |
Critical | Normalization | Empty |
DetectHiddenText | Normalization | Empty |
DetectHiddenWindows | Normalization | Empty |
DllCall() | Identical | String |
Drive | Normalization | Empty |
DriveGet | Normalization | String |
DriveSpaceFree | Normalization | Number |
Edit | Cannot use yet | N/A |
EnvAdd | Not needed (Feature duplication) | N/A |
EnvDiv | Not needed (Feature duplication) | N/A |
EnvGet | Normalization | String |
EnvMult | Not needed (Feature duplication) | N/A |
EnvSet | Normalization | Empty |
EnvSub | Not needed (Feature duplication) | N/A |
EnvUpdate | Normalization | Empty |
ErrorLevel | Identical | N/A |
Exception | Not needed (AHK specific) | N/A |
Exit | Not needed (AHK specific) | N/A |
ExitApp | Normalization | Empty |
Exp() | Identical | Number |
FileAppend | Normalization | Empty |
FileCopy | Normalization | Empty |
FileCopyDir | Normalization | Empty |
FileCreateDir | Normalization | Empty |
FileCreateShortcut | Normalization | Empty |
FileDelete | Normalization | Empty |
FileEncoding | Normalization | Empty |
FileExist() | Identical | String |
FileGetAttrib | Normalization | String |
FileGetShortcut | Minor change (returns Object) | {} |
FileGetSize | Normalization | Number |
FileGetTime | Normalization | String |
FileGetVersion | Normalization | String |
FileInstall | Cannot use compile-time features. | N/A |
FileMove | Normalization | Empty |
FileMoveDir | Normalization | Empty |
FileOpen() | Minor change (RawRead() multiple output) | File |
FileRead | Normalization | String |
FileReadLine | Normalization | String |
FileRecycle | Normalization | Empty |
FileRecycleEmpty | Normalization | Empty |
FileRemoveDir | Normalization | Empty |
FileSelectFile | Normalization | String |
FileSelectFolder | Normalization | String |
FileSetAttrib | Normalization | Empty |
FileSetTime | Normalization | Empty |
Floor() | Identical | Number |
FormatTime | Normalization | String |
Func() | Not needed (AHK specific) | N/A |
GetKeyName() | Identical | String |
GetKeySC() | Identical | Number |
GetKeyState | Not needed (occluded by homonym) | String |
GetKeyState() | Identical | Number |
GetKeyVK() | Identical | Number |
Gosub | Cannot use (AHK specific) | N/A |
Goto | Cannot use (AHK specific) | N/A |
GroupActivate | Normalization | Empty |
GroupAdd | Normalization | Empty |
GroupClose | Normalization | Empty |
GroupDeactivate | Normalization | Empty |
Gui | Normalization | Empty |
GuiClose | Minor change (built-in label becomes built-in function) | Empty |
GuiContextMenu | Minor change (built-in label becomes built-in function) | Empty |
GuiControl | Normalization | Empty |
GuiControlGet | Normalization | String |
GuiDropFiles | Minor change (built-in label becomes built-in function) | Empty |
GuiEscape | Minor change (built-in label becomes built-in function) | Empty |
GuiSize | Minor change (built-in label becomes built-in function) | Empty |
Hotkey | Minor change (target label becomes closure) | Empty |
IL_Add() | Identical | Number |
IL_Create() | Identical | Number |
IL_Destroy() | Identical | Number |
ImageSearch | Minor change (returns Object) | {} |
IniDelete | Normalization | Empty |
IniRead | Normalization | String |
IniWrite | Normalization | Empty |
Input | Normalization | String |
InputBox | Normalization | String |
InStr() | Identical | Number |
IsByRef() | Not needed (AHK specific) | N/A |
IsFunc() | Not needed (AHK specific) | N/A |
IsLabel() | Not needed (AHK specific) | N/A |
IsObject() | Not needed (AHK specific) | N/A |
KeyHistory | Normalization | Empty |
KeyWait | Normalization | Empty |
ListHotkeys | Normalization | Empty |
ListLines | Cannot implement for JS | N/A |
ListVars | Cannot implement for JS | N/A |
Ln() | Identical | Number |
Log() | Identical | Number |
Loop | Major change | {} |
LTrim() | Identical | String |
LV_Add() | Identical | Number |
LV_Delete() | Identical | Number |
LV_DeleteCol() | Identical | Number |
LV_GetCount() | Identical | Number |
LV_GetNext() | Identical | Number |
LV_GetText() | Major change | String/{} |
LV_Insert() | Identical | Number |
LV_InsertCol() | Identical | Number |
LV_Modify() | Identical | Number |
LV_ModifyCol() | Identical | Number |
LV_SetImageList() | Identical | Number |
Menu | Normalization | Empty |
Mod() | Identical | Number |
MouseClick | Normalization | Empty |
MouseClickDrag | Normalization | Empty |
MouseGetPos | Minor change (returns Object) | {} |
MouseMove | Normalization | Empty |
MsgBox | Normalization | Empty |
NumGet() | Cannot use yet | N/A |
NumPut() | Cannot use yet | N/A |
ObjAddRef() | Not needed (AHK specific) | N/A |
ObjClone() | Not needed (AHK specific) | N/A |
Object() | Not needed (AHK specific) | N/A |
ObjGetAddress() | Not needed (AHK specific) | N/A |
ObjGetCapacity() | Not needed (AHK specific) | N/A |
ObjHasKey() | Not needed (AHK specific) | N/A |
ObjInsert() | Not needed (AHK specific) | N/A |
ObjMaxIndex() | Not needed (AHK specific) | N/A |
ObjMinIndex() | Not needed (AHK specific) | N/A |
ObjNewEnum() | Not needed (AHK specific) | N/A |
ObjRelease() | Not needed (AHK specific) | N/A |
ObjRemove() | Not needed (AHK specific) | N/A |
ObjSetCapacity() | Not needed (AHK specific) | N/A |
OnClipboardChange | Minor change (built-in label becomes built-in function) | Empty |
OnExit | Minor change (target label becomes closure) | Empty |
OnMessage() | Minor change (target function becomes closure) | Empty |
OutputDebug | Normalization | Empty |
Pause | Normalization | Empty |
PixelGetColor | Normalization | String |
PixelSearch | Minor change (returns Object) | {} |
PostMessage | Normalization | Empty |
Process | Normalization | Empty |
ProgramFiles | Identical | String |
Progress | Normalization | Empty |
Random | Major change | Num/Empty |
RegDelete | Normalization | Empty |
RegExMatch() | Major change | Number/{} |
RegExReplace() | Major change | String/{} |
RegisterCallback() | Cannot use yet | N/A |
RegRead | Normalization | String |
RegWrite | Normalization | Empty |
Reload | Normalization | Empty |
Round() | Identical | Number |
RTrim() | Identical | String |
Run | Normalization | Empty |
RunAs | Normalization | Empty |
RunWait | Major change (doesn't return exit code) | String |
SB_SetIcon() | Identical | Number |
SB_SetParts() | Identical | Number |
SB_SetText() | Identical | Number |
Send | Normalization | Empty |
SendEvent | Normalization | Empty |
SendInput | Normalization | Empty |
SendLevel | Normalization | Empty |
SendMessage | Normalization | Empty |
SendMode | Normalization | Empty |
SendPlay | Normalization | Empty |
SendRaw | Normalization | Empty |
SetBatchLines | Normalization | Empty |
SetCapslockState | Normalization | Empty |
SetControlDelay | Normalization | Empty |
SetDefaultMouseSpeed | Normalization | Empty |
SetEnv | Not needed (AHK specific) | N/A |
SetFormat | Normalization | Empty |
SetKeyDelay | Normalization | Empty |
SetMouseDelay | Normalization | Empty |
SetNumLockState | Normalization | Empty |
SetRegView | Normalization | Empty |
SetScrollLockState | Normalization | Empty |
SetStoreCapslockMode | Normalization | Empty |
SetTimer | Cannot use yet | Empty |
SetTitleMatchMode | Normalization | Empty |
SetWinDelay | Normalization | Empty |
SetWorkingDir | Normalization | Empty |
Shutdown | Normalization | Empty |
Sin() | Identical | Number |
Sleep | Normalization | Empty |
Sort | Major change | String |
SoundBeep | Normalization | Empty |
SoundGet | Normalization | Str/Num |
SoundGetWaveVolume | Normalization | Number |
SoundPlay | Normalization | Empty |
SoundSet | Normalization | Empty |
SoundSetWaveVolume | Normalization | Empty |
SplashImage | Normalization | Empty |
SplashTextOff | Normalization | Empty |
SplashTextOn | Normalization | Empty |
SplitPath | Minor change (returns Object) | {} |
Sqrt() | Identical | Number |
StatusBarGetText | Normalization | String |
StatusBarWait | Normalization | Empty |
StrGet() | Identical | String |
StringCaseSense | Normalization | Empty |
StringGetPos | Normalization | Number |
StringLeft | Normalization | String |
StringLen | Normalization | String |
StringLower | Normalization | String |
StringMid | Normalization | String |
StringReplace | Normalization | String |
StringRight | Normalization | String |
StringSplit | Not needed (deprecated by StrSplit) | N/A |
StringTrimLeft | Normalization | String |
StringTrimRight | Normalization | String |
StringUpper | Normalization | String |
StrLen() | Identical | Number |
StrPut() | Identical | Str/Num |
StrSplit() | Identical | Array |
SubStr() | Identical | String |
Suspend | Normalization | Empty |
SysGet | Minor change (returns Object) | Str/Num/{} |
Tan() | Identical | Number |
Thread | Normalization | Empty |
ToolTip | Normalization | Empty |
Transform | Normalization | Str/Num |
TrayTip | Normalization | Empty |
Trim() | Identical | String |
TV_Add() | Identical | Number |
TV_Delete() | Identical | Number |
TV_Get() | Identical | Number |
TV_GetChild() | Identical | Number |
TV_GetCount() | Identical | Number |
TV_GetNext() | Identical | Number |
TV_GetParent() | Identical | Number |
TV_GetPrev() | Identical | Number |
TV_GetSelection() | Identical | Number |
TV_GetText() | Major change | String/{} |
TV_Modify() | Identical | Number |
TV_SetImageList() | Identical | Number |
UrlDownloadToFile | Normalization | Empty |
VarSetCapacity() | Cannot use yet | N/A |
WinActivate | Normalization | Empty |
WinActivateBottom | Normalization | Empty |
WinActive() | Identical | String |
WinClose | Normalization | Empty |
WinExist() | Identical | String |
WinGet | Minor change (returns Object) | Str/Num/{} |
WinGetActiveStats | Minor change (returns Object) | {} |
WinGetActiveTitle | Normalization | String |
WinGetClass | Normalization | String |
WinGetPos | Minor change (returns Object) | {} |
WinGetText | Normalization | String |
WinGetTitle | Normalization | String |
WinHide | Normalization | Empty |
WinKill | Normalization | Empty |
WinMaximize | Normalization | Empty |
WinMenuSelectItem | Normalization | Empty |
WinMinimize | Normalization | Empty |
WinMinimizeAll | Normalization | Empty |
WinMinimizeAllUndo | Normalization | Empty |
WinMove | Normalization | Empty |
WinRestore | Normalization | Empty |
WinSet | Normalization | Empty |
WinSetTitle | Normalization | Empty |
WinShow | Normalization | Empty |
WinWait | Normalization | Empty |
WinWaitActive | Normalization | Empty |
WinWaitClose | Normalization | Empty |
WinWaitNotActive | Normalization | Empty |
#ClipboardTimeout | Cannot use directives | N/A |
#CommentFlag | Not needed (AHK specific) | N/A |
#ErrorStdOut | Not needed (AHK specific) | N/A |
#EscapeChar | Not needed (AHK specific) | N/A |
#HotkeyInterval | Cannot use directives | N/A |
#HotkeyModifierTimeout | Cannot use directives | N/A |
#Hotstring | Cannot use directives. TODO: implement "Hotstring()" by Menixator | N/A |
#If | Cannot use directives. Try "Hotkey()"+"if" instead. | N/A |
#IfTimeout | Cannot use directives. Try "Hotkey()"+"if" instead. | N/A |
#IfWinActive | Cannot use directives. Try "Hotkey()"+"if" instead. | N/A |
#IfWinExist | Cannot use directives. Try "Hotkey()"+"if" instead. | N/A |
#Include | Cannot use yet. | N/A |
#InputLevel | Cannot use directives | N/A |
#InstallKeybdHook | Cannot use directives | N/A |
#InstallMouseHook | Cannot use directives | N/A |
#KeyHistory | Cannot use directives | N/A |
#LTrim | Not needed (AHK specific) | N/A |
#MaxHotkeysPerInterval | Cannot use directives | N/A |
#MaxMem | Cannot use directives | N/A |
#MaxThreads | Cannot use directives | N/A |
#MaxThreadsBuffer | Cannot use directives | N/A |
#MaxThreadsPerHotkey | Cannot use directives | N/A |
#MenuMaskKey | Cannot use directives | N/A |
#NoEnv | Not needed (AHK specific) | N/A |
#NoTrayIcon | Cannot use directives. Try "Menu()" instead. | N/A |
#Persistent | Cannot use directives. Try creating a (dummy) "hotkey()". | N/A |
#SingleInstance | Cannot use directives. Try "Run" and "/restart" instead. | N/A |
#UseHook | Cannot use directives. Try "Hotkey($)" instead. | N/A |
#Warn | Not needed (AHK specific) | N/A |
#WinActivateForce | Cannot use directives | N/A |
~ | Addition: "Require()" (a globally scoped #Include) | Empty |
TODO
- Test every keyword
- Accept/Provide URI paths in all transactions (not DOS-style paths)
- Allow "Include" to use online URL
- Implement "IncludeAgain"
- Implement "DateAdd" and "DateDiff"
- Implement some of the Directives (especially "#SingleInstance")
- Maybe implement a console (Firebug lite has some issues)