Cleanup gui and some unused shit

This commit is contained in:
2025-01-01 01:04:02 +01:00
parent f6bb50438d
commit 56a7a26760

120
Echo.ahk2
View File

@@ -13,14 +13,13 @@ ih.Start()
addNext := 0
removeNext := 0
enabledWindows := Map()
keyLog := Map()
whitelistedKeys := Map()
paused := 0
SetTimer(ResetHook, -60000)
OnKeyDown(InputHook, VK, SC) {
global paused, addNext, removeNext, enabledWindows, keyLog, whitelistedKeys
global paused, addNext, removeNext, enabledWindows, whitelistedKeys
if (paused) {
return
}
@@ -56,9 +55,6 @@ OnKeyDown(InputHook, VK, SC) {
ControlSend("{" . key . " down}",, "ahk_id " . hwnd)
}
}
if (!keyLog.Has(key)) {
keyLog.Set(key, SC)
}
}
OnKeyUp(InputHook, VK, SC) {
@@ -91,96 +87,6 @@ WinGetAll() {
return [PIDs, winTitles]
}
AllWindowsToString() {
allWindows := WinGetAll()
output := ""
for k, v in allWindows[1] {
output .= allWindows[1][k] . ", " . allWindows[2][k] . "|"
}
return SubStr(output, 1, -1)
}
Find(arr, val) {
for k, v in arr {
if (v = val) {
return k
}
}
return 0
}
EnableWindows(istring) {
enabledWindows[1].Clear()
enabledWindows[2].Clear()
if (!InStr(istring, "|")) {
ostring := StrSplit(istring, ", ")
if (Find(enabledWindows[1], ostring[1]) = 0) {
enabledWindows[1].Push(ostring[1])
enabledWindows[2].Push(ostring[2])
}
} else {
ostring := StrSplit(istring, "|")
for v in ostring {
ostring2 := StrSplit(v, ", ")
if (Find(enabledWindows[1], ostring2[1]) = 0) {
enabledWindows[1].Push(ostring2[1])
enabledWindows[2].Push(ostring2[2])
}
}
}
}
GuiSelectActiveWindows(allWindows) {
output := []
for k, v in allWindows[1] {
if (Find(enabledWindows[1], v) != 0) {
output.Push(k)
}
}
return output
}
MakeUI() {
Gui := Gui()
Gui.Destroy()
string := AllWindowsToString()
Gui.Add("ListBox", "Multi w800 h600 vWindowListGUI", string)
Gui.Add("Button", "Default", "OK")
Gui.Show()
selections := GuiSelectActiveWindows(WinGetAll())
for k in selections {
Gui.Window.ListBox("WindowListGUI").Selected(k, true)
}
}
KeyLogToString() {
output := ""
for key in keyLog {
output .= key . "|"
}
return SubStr(output, 1, -1)
}
WhitelistButtonUI() {
Gui := Gui()
Gui.Destroy()
string := KeyLogToString()
Gui.Add("ListBox", "Multi w800 h600 vKeyLogUI", string)
Gui.Add("Button", "Default", "Save")
Gui.Show()
selections := GuiSelectActiveWindows(WinGetAll())
for k in selections {
Gui.Window.ListBox("KeyLogUI").Selected(k, true)
}
}
WhitelistKeys(string) {
whitelistKeys := Map()
for key in StrSplit(string, "|") {
whitelistKeys.Set(key, 1)
}
}
ResetHook() {
global ih
ih.Stop()
@@ -208,13 +114,13 @@ TogglePause() {
F5:: {
global ih
ih.Stop()
ih := InputHook("B")
ih.KeyOpt("{All}", "NV")
ih.OnKeyDown := OnKeyDown
ih.OnKeyUp := OnKeyUp
ih.Start()
Reload
; ih.Stop()
; ih := InputHook("B")
; ih.KeyOpt("{All}", "NV")
; ih.OnKeyDown := OnKeyDown
; ih.OnKeyUp := OnKeyUp
; ih.Start()
}
F3:: {
@@ -266,15 +172,3 @@ F4:: {
}
F6:: TogglePause()
ButtonSave() {
Gui := Gui()
Gui.Submit()
WhitelistKeys(Gui.Control("KeyLogUI").Value)
}
ButtonOK() {
Gui := Gui()
Gui.Submit()
EnableWindows(Gui.Control("WindowListGUI").Value)
}