-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathreload.ahk
More file actions
37 lines (32 loc) · 883 Bytes
/
reload.ahk
File metadata and controls
37 lines (32 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
; This file can be used to quickly restart the HotkeylessAHK server and client.
#Requires AutoHotkey v2.0
SendMode("Input")
SetWorkingDir(A_ScriptDir)
TraySetIcon("files\icon.ico")
A_IconTip := "Reloading HotkeylessAHK..."
#SingleInstance force
; Shutdown the server if it is running
if (isHotkeylessAHKRunning()) {
whr := ComObject("WinHttp.WinHttpRequest.5.1")
KILL_URL := "http://localhost:42800/send/kill"
try {
whr.Open("GET", KILL_URL, false)
whr.Send()
} catch error {
}
}
; Restart the script once the server is down
loop 50 {
Sleep(100)
if (!isHotkeylessAHKRunning()) {
Run("HotkeylessAHK.ahk")
return
}
}
MsgBox("Unable to start HotkeylessAHK. Please reload it manually.")
return
isHotkeylessAHKRunning() {
SetTitleMatchMode(2)
DetectHiddenWindows(1)
return !!WinExist("HotkeylessAHK.ahk")
}