-
Notifications
You must be signed in to change notification settings - Fork 537
/
Both_Accelerated_Scrolling_1.3_AND_Cursor_click_visualizer.ahk
323 lines (250 loc) · 6.55 KB
/
Both_Accelerated_Scrolling_1.3_AND_Cursor_click_visualizer.ahk
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
; Accelerated Scrolling
; V1.3
; By BoffinbraiN
; https://www.youtube.com/watch?v=OobKVPojFmg
; ORIGINAL: https://autohotkey.com/board/topic/48426-accelerated-scrolling-script/
/*
PLUS cursor click visualization 1.0, By Taran Van Hemert.
PROBLEMS WITH THE CURSOR VISUALIZER:
Background color behind the green text is not completely transparent on the edges --- there is no anti aliasing, so it looks jagged
Would be nice to use customizable pictures, instead of a dumb font (lucida console) that not everyone will have anyway.
The click visualizations do not linger at all -- I don't know how to do this if I wanted to.
Middle click visualization does not work. I don't know why but nothing I try will work to get it to show up.
Also, You'll have to modify the positioning of the GUI to suit your own computer and its UI scaling in Windows.
*/
;Use this script only if you want cursor visualization, AND accelrated scrolling.
;SOURCE: https://github.com/TaranVH/2nd-keyboard
Menu, Tray, Icon, shell32.dll, 44 ; changes the icon to a star -- makes it easy to see which one it is.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoEnv
;#NoTrayIcon
#SingleInstance
#MaxHotkeysPerInterval 2000
Process, Priority, , H
SendMode Input
#SingleInstance force
CoordMode, mouse, screen
;below is a bunch of GUI stuff that I need for cursor click visualization.
;Use WIN KEY and scroll down to turn it on or off.
size := 200
kolor := 11FF99
kolor2 := 008833
showClicks = 1
Gui, -Caption +ToolWindow +AlwaysOnTop +LastFound
;Gui, Color, %kolor2%
Gui, Color, 008833
GuiHwnd := WinExist()
DetectHiddenWindows, On
WinSet, Region, % "0-0 W" Size " H" Size, ahk_id %GuiHwnd%
WinSet, ExStyle, +0x20, ahk_id %GuiHwnd% ; set click through style
;WinSet, Transparent, 0, ahk_id %GuiHwnd% ;didn't work...
;WinSet, TransColor, %kolor2% 100
WinSet, TransColor, 008833 100
;WinSet, TransColor, %kolor% 100
Gui, Show, w%Size% h%Size% ;hide
Gui, Font, s32, lucida console ;This font has nearly perfect ()v^ characters. I also tried these: ;Estrangelo Edessa ;century gothic
Gui, Add, Text, vMyText cLime, ; xx auto-sizes the window.
If showClicks = 1
{
settimer, looper, -2
}
nokill = 1
delay = 200
; Show scroll velocity as a tooltip while scrolling. 1 or 0.
tooltips := 0
; The length of a scrolling session.
; Keep scrolling within this time to accumulate boost.
; Default: 500. Recommended between 400 and 1000.
timeout := 600
; If you scroll a long distance in one session, apply additional boost factor.
; The higher the value, the longer it takes to activate, and the slower it accumulates.
; Set to zero to disable completely. Default: 30.
boost := 40
; Spamming applications with hundreds of individual scroll events can slow them down.
; This sets the maximum number of scrolls sent per click, i.e. max velocity. Default: 60.
limit := 60
; Runtime variables. Do not modify.
distance := 0
vmax := 1
; Key bindings
;These allow for the visualizer to work with modifier keys, but do NOT affect any sort of clicking at all.
; ^ is CTRL
; + is SHIFT
; ! is ALT
; ~ allows the key to also pass through normally
~^WheelUp::
~+WheelUp::
~^+WheelUp::
~!WheelUp::
Wup = 1
return
~^WheelDown::
~+WheelDown::
~^+WheelDown::
~!WheelDown::
Wdown = 1
return
WheelUp:: ;notice the deliberate lack of a ~
Gui, hide
Wup = 1
Goto Scroll ;this is what does the acceleration
return
WheelDown::
Gui, hide
Wdown = 1
Goto Scroll
return
;remember, in this case the # means the WIN KEY.
;So you can toggle this in order to disable or re-enable the script
;#Wheelup:: Suspend
#mbutton:: Suspend
#WheelDown:: ; this turns the click visualizer and fast scroll :( on or off.
If showClicks = 1
{
tooltip, changing visualization
showClicks = 0
settimer, looper, -20
sleep 555
tooltip,
Return
}
else if showClicks = 0
{
showClicks = 1
settimer, looper, off
}
Return
Scroll:
t := A_TimeSincePriorHotkey
if (A_PriorHotkey = A_ThisHotkey && t < timeout)
{
; Remember how many times we've scrolled in the current direction
distance++
; Calculate acceleration factor using a 1/x curve
v := (t < 80 && t > 1) ? (250.0 / t) - 1 : 1
; Apply boost
if (boost > 1 && distance > boost)
{
; Hold onto the highest speed we've achieved during this boost
if (v > vmax)
vmax := v
else
v := vmax
v *= distance / boost
}
; Validate
v := (v > 1) ? ((v > limit) ? limit : Floor(v)) : 1
if (v > 1 && tooltips)
QuickToolTip(v, timeout)
MouseClick, %A_ThisHotkey%, , , v
}
else
{
; Combo broken, so reset session variables
distance := 0
vmax := 1
MouseClick %A_ThisHotkey%
}
return
Quit:
QuickToolTip("Exiting Accelerated Scrolling...", 1000)
Sleep 1000
ExitApp
QuickToolTip(text, delay)
{
ToolTip, %text%
SetTimer ToolTipOff, %delay%
return
ToolTipOff:
SetTimer ToolTipOff, Off
ToolTip
return
}
; pgup::send {wheelup 50}
; pgdn::send {wheeldown 50}
;Begin cursor click visualization stuff:
~*$LButton::
Lbuttondown = 1
Return
~*$LButton up::
Lbuttondown = -1
Return
~*$RButton::
Rbuttondown = 1
Return
~*$RButton up::
Rbuttondown = -1
Return
wheelkiller:
;msgbox, wheelkiller
if Wup = -1
{
Wup = 0
Gui, hide
}
if Wdown = -1
{
Wdown = 0
Gui, hide
}
Return
looper:
MouseGetPos, realposX, realposY
;tooltip,^ ;this is just in case my cursor vanishes in premiere, as it has done sometimes...
posX := realposX - Size/2.4, posY := realposY - Size/3.1 + 0 ; puts the gui in the middle rather than the corner. this is for 150% UI
posX := realposX - Size/3.4, posY := realposY - Size/4.1 + 0 ; puts the gui in the middle rather than the corner. this is for 100% UI.
If(Lbuttondown = 1 and Rbuttondown = 1) ;this doesn't really work. Often the ) will be out of alignment or will not show up.
{
GuiControl,, MyText, ()
posX := posX-10
Gui, Show, x%posX% y%posY% NA
settimer, looper, -20
return
}
If Lbuttondown = 1
{
;tooltip, <, posX-25, posY-8, 2 ;this code was used for bug testing.
;SoundBeep, 400, 50
;soundplay, C:\AHK\3.wav,
GuiControl,, MyText, (
posXX := posX-10
Gui, Show, x%posXX% y%posY% NA
}
If Lbuttondown = -1
{
;tooltip, , , , 2
Lbuttondown = 0
Gui, hide
}
If Rbuttondown = 1
{
posX := posX+20
GuiControl,, MyText, )
Gui, Show, x%posX% y%posY% NA
}
If Rbuttondown = -1
{
Rbuttondown = 0
Gui, hide
}
If Wup = 1
{
posYu := posY-10
posxu := posX+8
GuiControl,, MyText, ^
Gui, Show, x%posXu% y%posYu% NA
settimer, wheelkiller, -200
Wup = -1
}
If Wdown = 1
{
posYd := posY+32
posXd := posX+8
Gui, Font, s20 cBlue, Verdana
GuiControl,, mytext, v
Gui, Show, x%posXd% y%posYd% NA
settimer, wheelkiller, -200
Wdown = -1
}
settimer, looper, -1
Return