mkey — Mouse and Key

mkey automates tasks such as double-click, write a sentense, run delayed commands in a terminal, open a web page and connect with login and password.

Dependencies

Usage

pip install mkey
mkey file1.mkey file2.mkey

Exit status:

0: success 1: missing file 2: syntax error

The mkey command calls the mkey() function:

from mkey import *
mkey('file1.mkey', 'file2.mkey')

The *.mkey scripts must be in UTF-8 but not necessarily signed. The *.ahk scripts created by mkey are in UTF-8 with BOM signature because the Unicode version of AutoHotkey 2 assumes that an unsigned file is ANSI encoded.

Syntax

example.mkey[ctrl]
h Hello world!
m john.doe@gmail.com
r Regards,;John Doe
c0 clear;ls --color
p_ printf("Hello");

[left]
g accounts.google.com/ServiceLogin?service=mail: john.doe 1234
l cs.lpi.org/caf/Xamman: john.doe@gmail.com>1234
y youtube.com

[middle]
explorer 7zFM:
mpv sumatrapdf: q
soffice.bin: translate.google.com deepl.com/translator

The [ctrl] and [shift] sections are the right keys of the keyboard, the left keys are unchanged. [left], [middle], [right] are the mouse buttons.

Each shortcut is defined by a key or an executable, followed by the action to be performed.

The default line splitter is ;. If a number is specified c0 clear;ls --color each character is delayed by 10ms, mandatory in a terminal or a virtual machine, in this case a final “Enter” is sent. The specified number is the delay in seconds after each line, 0 is 200ms. To generate a semicolon, redefine the splitter p_ printf("Hello");.

An URL opens a tab in the browser, can be followed by : and the words to be written and validated by “Enter” at each left click, validation is avoided if the word ends with ., the > symbol sends a tabulation for fill the next field. The left click is restored once all fields filled or the “Esc” key pressed.

In the line explore 7zFM: no action is defined, the default action is the left double-click. A middle click in mpv.exe is equivalent to writing “q” to quit MPV. Specify the extension if it is not “.exe”: soffice.bin: translate.google.com deepl.com/translator a middle click in LibreOffice opens two tabs in the browser. The executable name is case sensitive.

Versions

0.4: February 16, 2019 — First beta release
0.3: February 8, 2019 — import * imports mkey() only
0.2: January 29, 2019 — Packaging with setuptools and metadata
0.1: January 28, 2019 — First alpha release