-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumberCounter.ahk
150 lines (122 loc) · 4.53 KB
/
NumberCounter.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
; === IMPORT NUMBER FUNCTIONS FROM https://www.autohotkey.com/board/topic/123215-convert-number-to-text/?p=693512 BEGIN ===
FormatNumber(n) { ; recursive function to spell out the name of a max 36 digit integer, after leading 0s removed
Static p1=" thousand ",p2=" million ",p3=" billion ",p4=" trillion ",p5=" quadrillion ",p6=" quintillion "
, p7=" sextillion ",p8=" septillion ",p9=" octillion ",p10=" nonillion ",p11=" decillion "
, t2="twenty",t3="thirty",t4="forty",t5="fifty",t6="sixty",t7="seventy",t8="eighty",t9="ninety"
, o0="zero",o1="one",o2="two",o3="three",o4="four",o5="five",o6="six",o7="seven",o8="eight"
, o9="nine",o10="ten",o11="eleven",o12="twelve",o13="thirteen",o14="fourteen",o15="fifteen"
, o16="sixteen",o17="seventeen",o18="eighteen",o19="nineteen"
n :=RegExReplace(n,"^0+(\d)","$1") ; remove leading 0s from n
If (11 < d := (StrLen(n)-1)//3) ; #of digit groups of 3
Return "Number too big"
If (d) ; more than 3 digits
Return FormatNumber(SubStr(n,1,-3*d)) p%d% ((s:=SubStr(n,1-3*d)) ? ", " FormatNumber(s) : "")
i := SubStr(n,1,1)
If (n > 99) ; 3 digits
Return o%i% " hundred" ((s:=SubStr(n,2)) ? " and " FormatNumber(s) : "")
If (n > 19) ; n = 20..99
Return t%i% ((o:=SubStr(n,2)) ? "-" o%o% : "")
Return o%n% ; n = 0..19
}
PrettyNumber(n) { ; inserts thousands separators into a number string
Return RegExReplace( RegExReplace(n,"^0+(\d)","$1"), "\G\d+?(?=(\d{3})+(?:\D|$))", "$0,")
}
; ============================================ IMPORT NUMBER FUNCTIONS END ================================================
; This small AHK script allows you to easily do the repetetive task of spelling out numbers in multiple games.
; Copyright (C) 2023 ccuser44
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
msgbox, Ctr + Alt + Z to Open options, Ctr + Alt + X to pause. Copyright (C) 2023 ccuser44
!^z::
Gui, Add, Text, section, Maximum:
Gui, Add, Text, , Minimum:
Gui, Add, Text, , ChatKey:
Gui, Add, Text, , FormattedNumber:
Gui, Add, Text, , Silent:
Gui, Add, Text, , NoJump:
Gui, Add, Text, , Delay (in ms):
Gui, Add, Text, , Rand delay range (in ms):
Gui, Add, Text, , Prefix:
Gui, Add, Text, , Postfix:
Gui, Add, Text, , Completemessage:
Gui, Add, Text, , Is uppercase:
Gui, Add, Edit, vMAXIMUM ys
Gui, Add, Edit, vMINIMUM
Gui, Add, Edit, vCHAT_KEY
Gui, Add, Checkbox, vNUM_IS_FORMATTED
Gui, Add, Checkbox, vIS_SILENT
Gui, Add, Text, ; This exists to fix invalid spacing
Gui, Add, Checkbox, vNO_JUMP
Gui, Add, Edit, vDELAY
Gui, Add, Edit, vRAND_DELAY
Gui, Add, Edit, vPREFIX
Gui, Add, Edit, vPOSTFIX
Gui, Add, Edit, vCOMPLETE_MESSAGE
Gui, Add, Checkbox, vUPPER_CASE
Gui, Add, Button, default, Ok
Gui, Show,, NumberCounter
return
GuiClose:
ButtonOk:
Gui, Submit
msgbox, Will start in 2 seconds
sleep, 2000
SmallWait()
{
Random rand, 1, 15
sleep 2 + rand
}
ChatMessage(chatKeyLocal, message)
{
send %chatKeyLocal%
SmallWait()
send %message%
SmallWait()
SmallWait()
send {Enter}
SmallWait()
}
ChatAndJump(chatKeyLocal, message, isSilent, noJump) {
if (isSilent != true) {
ChatMessage(chatKeyLocal, message)
}
SmallWait()
if (noJump != true) {
send {space down}
Random rand, 1, 20
sleep 22 + rand
send {space up}
}
SmallWait()
}
loopcount := MAXIMUM - MINIMUM + 1
count := MINIMUM
RegExMatch(RAND_DELAY, "O)^\s*(\d+);(\d+)+\s*$", regexMatches)
delayMin := (regexMatches[1] ? regexMatches[1] : 50)
delayMax := (regexMatches[2] ? regexMatches[2] : 700)
loop, %loopcount%
{
ChatAndJump(CHAT_KEY, (PREFIX . (NUM_IS_FORMATTED ? Format(UPPER_CASE ? "{:U}" : "{s}", FormatNumber(count)) : count) . POSTFIX), IS_SILENT, NO_JUMP)
Random rand, delayMin, delayMax
sleep ((DELAY != "" ? DELAY : 2500) + rand)
count++
}
if (COMPLETE_MESSAGE != "") {
ChatMessage(CHAT_KEY, COMPLETE_MESSAGE)
}
sleep 500
msgbox, Number counter completed
!^x::
msgbox, Stopped number counter
ExitApp