Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

TheBrokenRail/AutoHotKey.js

Repository files navigation

AutoHotKey.js

Make AutoHotKey Scripts In JavaScript

Greenkeeper badge Travis Codecov npm npm node contributions welcome

Examples

Basic Script

require('autohotkey.js').init('Name Of File');

on('^t', function () {
  send('Hi');
});

Which Outputs

^t::
  Send, Hi
Return

Basic Script With If Statement

require('autohotkey.js').init('Name Of File');

on('^t', function () {
  If(winExist('"Untitled - Notepad"'), function () {
    send('Notepad Open');
  })
});

Which Outputs

^t::
  if (winExist("Untitled - Notepad")) {
    Send, Notepad Open
  }
Return

Basic Script With If/Else Statement

require('autohotkey.js').init('Name Of File');

on('^t', function () {
  If(winExist('"Untitled - Notepad"'), function () {
    send('Notepad Open');
  }).Else(function () {
    send('Notepad Not Open');
  });
});

Which Outputs

^t::
  if (winExist("Untitled - Notepad")) {
    Send, Notepad Open
  }
  else {
    Send, Notepad Not Open
  }
Return

Basic Script With Variables

require('autohotkey.js').init('Name Of File');

on('^t', function () {
  set('Variable', '"Untitled - Notepad"');
  If(winExist(get('Variable')), function () {
    send('Notepad Open');
  }).Else(function () {
    send('Notepad Not Open');
  });
  send(get('Variable').contents());
});

Which Outputs

^t::
  Variable := "Untitled - Notepad"
  if (WinExist(Variable)) {
    Send, Notepad Open
  }
  else {
    Send, Notepad Not Open
  }
  Send, %Variable%
Return

Runing Functions

get('Variable').get('Function').run('"Argrument"');
winExist(get('Variable').get('Function').runInline('"Argrument"'));

Store Output Script In Variable

const autohotkey = require('autohotkey.js');
var script = new autohotkey.Script();
autohotkey.init('Name Of File', script);

on('^t', function () {
  send('Hi');
});

Script Object

Script {
  text: '^t::\n  Send, Hi\nReturn\n',
  name: 'Name Of File.ahk',
  getText: function () {...},
  setText: function (text) {...},
  getName: function () {...},
  setName: function (name) {...}
}

About

Make AutoHotKey Scripts In JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published