-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccelerated Scrolling 1.3.ahk
170 lines (131 loc) · 4.98 KB
/
Accelerated Scrolling 1.3.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
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetBatchLines, -1
#KeyHistory 0
ListLines Off
; Accelerated Scrolling
; V1.3
; By BoffinbraiN
#NoTrayIcon
#MaxHotkeysPerInterval 120
RunAsTask()
RunAsTask() { ; By SKAN, http://goo.gl/yG6A1F, CD:19/Aug/2014 | MD:24/Apr/2020
Local CmdLine, TaskName, TaskExists, XML, TaskSchd, TaskRoot, RunAsTask
Local TASK_CREATE := 0x2, TASK_LOGON_INTERACTIVE_TOKEN := 3
Try TaskSchd := ComObjCreate( "Schedule.Service" ), TaskSchd.Connect()
, TaskRoot := TaskSchd.GetFolder( "\" )
Catch
Return "", ErrorLevel := 1
CmdLine := ( A_IsCompiled ? "" : """" A_AhkPath """" ) A_Space ( """" A_ScriptFullpath """" )
TaskName := "[RunAsTask] " A_ScriptName " @" SubStr( "000000000" DllCall( "NTDLL\RtlComputeCrc32"
, "Int",0, "WStr",CmdLine, "UInt",StrLen( CmdLine ) * 2, "UInt" ), -9 )
Try RunAsTask := TaskRoot.GetTask( TaskName )
TaskExists := ! A_LastError
If ( not A_IsAdmin and TaskExists ) {
RunAsTask.Run( "" )
ExitApp
}
If ( not A_IsAdmin and not TaskExists ) {
Run *RunAs %CmdLine%, %A_ScriptDir%, UseErrorLevel
ExitApp
}
If ( A_IsAdmin and not TaskExists ) {
XML := "
( LTrim Join
<?xml version=""1.0"" ?><Task xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task""><Regi
strationInfo /><Triggers /><Principals><Principal id=""Author""><LogonType>InteractiveToken</LogonT
ype><RunLevel>HighestAvailable</RunLevel></Principal></Principals><Settings><MultipleInstancesPolic
y>Parallel</MultipleInstancesPolicy><DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries><
StopIfGoingOnBatteries>false</StopIfGoingOnBatteries><AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable><RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAva
ilable><IdleSettings><StopOnIdleEnd>true</StopOnIdleEnd><RestartOnIdle>false</RestartOnIdle></IdleS
ettings><AllowStartOnDemand>true</AllowStartOnDemand><Enabled>true</Enabled><Hidden>false</Hidden><
RunOnlyIfIdle>false</RunOnlyIfIdle><DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteApp
Session><UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine><WakeToRun>false</WakeToRun><
ExecutionTimeLimit>PT0S</ExecutionTimeLimit></Settings><Actions Context=""Author""><Exec>
<Command>""" ( A_IsCompiled ? A_ScriptFullpath : A_AhkPath ) """</Command>
<Arguments>" ( !A_IsCompiled ? """" A_ScriptFullpath """" : "" ) "</Arguments>
<WorkingDirectory>" A_ScriptDir "</WorkingDirectory></Exec></Actions></Task>
)"
TaskRoot.RegisterTask( TaskName, XML, TASK_CREATE, "", "", TASK_LOGON_INTERACTIVE_TOKEN )
}
Return TaskName, ErrorLevel := 0
} ;
Process, Priority, , H
SendMode Input
; Show scroll velocity as a tooltip while scrolling. 1 or 0.
tooltips := 1
; The length of a scrolling session.
; Keep scrolling within this time to accumulate boost.
; Default: 500. Recommended between 400 and 1000.
timeout := 500
; 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 := 999999999999999999
; boost := 999999999999999999999999999999
; boost := 999999999999999999999999999999999999999
; 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 := 25
; limit := 15
; limit := 7
; Runtime variables. Do not modify.
distance := 0
vmax := 1
; Key bindings
WheelUp:: Goto Scroll
WheelDown:: Goto Scroll
#WheelUp:: Suspend
;#WheelDown:: Goto Quit
;f3:: Goto Quit
Scroll:
global boost, distance
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("x"v, timeout)
MouseClick, %A_ThisHotkey%, , , v
}
else
{
; Combo broken, so reset session variables
distance := 0
vmax := 1
MouseClick %A_ThisHotkey%
}
return
F3::Goto Quit
Quit:
QuickToolTip("Exiting Accelerated Scrolling...", 1000)
Sleep 1000
ExitApp
QuickToolTip(text, delay)
{
ToolTip, %text%
SetTimer ToolTipOff, %delay%
return
ToolTipOff:
SetTimer ToolTipOff, Off
ToolTip
return
}