TheBrokenRail / AutoHotKey.js

Make AutoHotKey Scripts In JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:MIT License


Languages

Language:JavaScript 94.9%Language:AutoHotkey 5.1%