-
Notifications
You must be signed in to change notification settings - Fork 1
/
buffers.au3
114 lines (111 loc) · 2.89 KB
/
buffers.au3
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <WinAPI.au3>;used to play default beep
Dim $Buffers[1];Each element will be a nested array containing all lines of a monitored window, this will be redimmed at initialisation
$WhichBuffer=0
$BufferCursor=0
$BufferKeysActive=0
Func BufferNavigate()
If IsArray($Buffers[$WhichBuffer]) then
select
case @HotkeyPressed="!{up}"
If $BufferCursor>0 then
$BufferCursor=$BufferCursor-1
If $bufferCursor>UBound(($Buffers[$WhichBuffer]))-1 then $BufferCursor=UBound(($Buffers[$WhichBuffer]))-1
;Going up in a shrunken buffer while the cursor is out of bounds.
else
_WinAPI_MessageBeep(0)
EndIf
case @HotkeyPressed="!{down}"
If $BufferCursor<UBound($Buffers[$WhichBuffer])-1 then
$bufferCursor=$BufferCursor+1
else ;Out of bounds due to reading in a larger buffer before and switching to a smaller one
_WinAPI_MessageBeep(0)
$BufferCursor=UBound(($buffers[$WhichBuffer]))-1
EndIf
Case @HotkeyPressed="!{home}"
$BufferCursor=0
Case @HotkeyPressed="!{end}"
$BufferCursor=UBound($Buffers[$WhichBuffer])-1
EndSelect
If ($Buffers[$WhichBuffer])[$BufferCursor]="" then
speak("blank")
else
speak(($Buffers[$WhichBuffer])[$BufferCursor])
EndIf
else;Buffer is not a nested array which means the buffer is empty
speak("empty")
EndIf
EndFunc
Func BufferSwitch()
Select
Case @HotkeyPressed="!{right}"
If $WhichBuffer<UBound($WindowList)-1 then
$WhichBuffer=$WhichBuffer+1
else ;Last buffer, so wrap around to the first
$WhichBuffer=0
EndIf
Case @HotkeyPressed="!{left}"
If $WhichBuffer>0 then
$WhichBuffer=$WhichBuffer-1
else ;First Buffer, so wrap around to the last
$WhichBuffer=UBound($WindowList)-1
EndIf
EndSelect
;Now do Alt+Numbers
For $i=1 to 9 step 1
If @HotkeyPressed="!"&$i then
If $i<=UBound($buffers) then
$WhichBuffer=$i-1
else;No buffer with that number
_WinAPI_MessageBeep(0)
EndIf
EndIf
next
Speak($WindowList[$WhichBuffer])
EndFunc
Func BufferCopy()
If ClipPut(($Buffers[$WhichBuffer])[$BufferCursor]) then
Speak("Copied " & (($Buffers[$WhichBuffer])[$BufferCursor]))
EndIf
EndFunc
Func RegisterBufferKeys($OnOrOff)
If $OnOrOff=1 then
HotkeySet("!{down}", "BufferNavigate")
HotkeySet("!{up}", "BufferNavigate")
HotkeySet("!{home}", "BufferNavigate")
HotkeySet("!{end}", "BufferNavigate")
HotKeySet("!{right}", "BufferSwitch")
HotKeySet("!{left}", "BufferSwitch")
For $i=1 to 9 step 1
HotKeySet("!"&$i, "BufferSwitch")
next
HotKeySet("!c", "BufferCopy")
return
else
HotkeySet("!{down}")
HotkeySet("!{up}")
HotkeySet("!{home}")
HotkeySet("!{end}")
HotKeySet("!{right}")
HotKeySet("!{left}")
For $i=1 to 9 step 1
HotKeySet("!"&$i)
next
HotKeySet("!c")
EndIf
EndFunc
func IsInGame()
For $i=0 to UBound($WindowList)-1 step 1
If WinGetHandle("[ACTIVE]")=$HandleList[$i][0] then
Return true
ExitLoop
EndIf
next
If WinGetHandle("[ACTIVE]")=$STSHandle then
return true
EndIf
If WinActive("Prompt") then
return true
else
return false
EndIf
EndFunc