AutoHotkey
On Windows, AutoHotkey turns any key combination into a timer button. The script needs nothing but AutoHotkey v2 and the HTTP interface built into Windows, no further libraries; after every press a notification shows where you stand.
- Under Settings, API and devices, add a device of the kind "Other device" and copy the token.
- Install AutoHotkey v2.
- Save the script below as
horaka.ahk(UTF-8) and start it with a double click. For more projects, copy the line with^!F9and give it its own key and alias. - To start the script when you sign in, put a shortcut into the startup folder (Windows+R,
shell:startup).
#Requires AutoHotkey v2.0
#SingleInstance Force
Address := "https://api.horaka.com/v1"
Token := "YOUR_TOKEN"
; Ctrl+Alt+F9: toggle project, Ctrl+Alt+F10: stop, Ctrl+Alt+F11: show status
^!F9::Notify("/track/toggle", '{"project": "PROJECT"}')
^!F10::Notify("/track/stop")
^!F11::Notify()
Horaka(Method, Path, Body := "") {
Request := ComObject("WinHttp.WinHttpRequest.5.1")
Request.Open(Method, Address Path, false)
Request.SetRequestHeader("Authorization", "Bearer " Token)
Request.SetRequestHeader("Content-Type", "application/json; charset=utf-8")
Request.Send(Body)
if (Request.Status != 200)
throw Error("HTTP " Request.Status)
return Request.ResponseText
}
Notify(Path := "", Body := "{}") {
try {
if (Path != "")
Horaka("POST", Path, Body)
TrayTip(Horaka("GET", "/track/status?format=text"), "Horaka")
} catch as Problem {
TrayTip(Problem.Message, "Horaka", "Iconx")
}
}
Instead of /track/toggle you can use /track/start and /track/switch with the same body; add "activity" next to "project" to book a specific activity. After every press the notification shows today's hours and the running timer. "HTTP 401" means a wrong token, "HTTP 403" means the device may not book on this project or the device limit of your plan is reached.
On some keyboard layouts Ctrl+Alt with a letter is the same as AltGr, which is why the example uses the function keys. Every endpoint is described in the API documentation.