Added some form of sorting
This commit is contained in:
40
Echo.ahk
40
Echo.ahk
@@ -15,8 +15,8 @@ global enabledWindows := Array()
|
||||
enabledWindows.Push(Array())
|
||||
enabledWindows.Push(Array())
|
||||
|
||||
global keyLog := {}
|
||||
global whitelistKeys := {}
|
||||
global keyLog := Array()
|
||||
global whitelistKeys := Array()
|
||||
|
||||
OnKeyDown(InputHook, VK, SC) {
|
||||
key := GetKeyName(Format("vk{:x}sc{:x}", VK, SC))
|
||||
@@ -41,6 +41,39 @@ OnKeyUp(InputHook, VK, SC) {
|
||||
}
|
||||
}
|
||||
|
||||
; Not really mine at all
|
||||
SortArray(Array, Order="A") {
|
||||
;Order A: Ascending, D: Descending, R: Reverse
|
||||
MaxIndex := ObjMaxIndex(Array)
|
||||
If (Order = "R") {
|
||||
count := 0
|
||||
Loop, % MaxIndex
|
||||
ObjInsert(Array, ObjRemove(Array, MaxIndex - count++))
|
||||
Return
|
||||
}
|
||||
Partitions := "|" ObjMinIndex(Array) "," MaxIndex
|
||||
Loop {
|
||||
comma := InStr(this_partition := SubStr(Partitions, InStr(Partitions, "|", False, 0)+1), ",")
|
||||
spos := pivot := SubStr(this_partition, 1, comma-1) , epos := SubStr(this_partition, comma+1)
|
||||
if (Order = "A") {
|
||||
Loop, % epos - spos {
|
||||
if (Array[pivot] > Array[A_Index+spos])
|
||||
ObjInsert(Array, pivot++, ObjRemove(Array, A_Index+spos))
|
||||
}
|
||||
} else {
|
||||
Loop, % epos - spos {
|
||||
if (Array[pivot] < Array[A_Index+spos])
|
||||
ObjInsert(Array, pivot++, ObjRemove(Array, A_Index+spos))
|
||||
}
|
||||
}
|
||||
Partitions := SubStr(Partitions, 1, InStr(Partitions, "|", False, 0)-1)
|
||||
if (pivot - spos) > 1 ;if more than one elements
|
||||
Partitions .= "|" spos "," pivot-1 ;the left partition
|
||||
if (epos - pivot) > 1 ;if more than one elements
|
||||
Partitions .= "|" pivot+1 "," epos ;the right partition
|
||||
} Until !Partitions
|
||||
}
|
||||
|
||||
WinGetAll() {
|
||||
PIDs := Array()
|
||||
winTitles := Array()
|
||||
@@ -142,6 +175,7 @@ KeyLogToString() {
|
||||
|
||||
WhitelistButtonUI() {
|
||||
Gui, Destroy
|
||||
SortArray(keyLog)
|
||||
string := KeyLogToString()
|
||||
Gui, Add, ListBox, Multi w500 vKeyLogUI r10, %string%
|
||||
Gui, Add, Button, Default, Save
|
||||
@@ -154,7 +188,7 @@ WhitelistButtonUI() {
|
||||
|
||||
WhitelistKeys(string) {
|
||||
for k, v in StrSplit(string, "|") {
|
||||
whitelistKeys[v] := true
|
||||
whitelistKeys.Insert(v)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user