-
Notifications
You must be signed in to change notification settings - Fork 6
/
webGui.ahk
175 lines (164 loc) · 3.64 KB
/
webGui.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
SendMode Input
#Include Webapp.ahk
__Webapp_AppStart:
;<< Header End >>
;Get our HTML DOM object
iWebCtrl := getDOM()
;Change App name on run-time
setAppName("TTR Tools Web GUI Beta")
; Our custom protocol's url event handler
app_call(args) {
MsgBox %args%
if InStr(args,"msgbox/hello")
MsgBox Hello world!
else if InStr(args,"soundplay/ding")
SoundPlay, %A_WinDir%\Media\ding.wav
}
; function to run when page is loaded
app_page(NewURL) {
wb := getDOM()
if InStr(NewURL,"index.html") {
Sleep, 10
x := wb.document.getElementById("ahk_info")
x.innerHTML := "<i>Webapp.ahk is currently running on " . GetAHK_EnvInfo() . ".</i>"
}
OutputDebug Starting
;SetTimer updateToggles, 1500
}
sendJS(js) {
wb := getDOM()
;OutputDebug %js%
global lastJS .= js . "\r\n"
try wb.Navigate("javascript:" . js)
catch e{
OutputDebug error %e%
}
}
; Functions to be called from the html/js source
/*gardenLabel = startGarden
trampolineLabel = startTrampoline
afkLabel = startAFK
switchTo(mode){
OutputDebug test %mode%
if(mode == "t")
{
if(!looping)
startTrampoline()
else
exitTrampoline()
sleep, 500
}
if(mode =="a")
{
if(!toggle)
startAFK()
else
toggleAFK()
sleep, 500
}
if(mode == "g")
{
if(!gardening)
startGarden()
else
exitGardening()
sleep, 500
}
}
*/
documentReady(){
}
verifyError(){
OutputDebug error found at %lastjs%
}
updateToggles(afk,tram,gard){
wb := getDOM()
sendJS("clearStatus();")
sleep, 50
if(afk && wb.Document.getElementById("afk-switch").checked != afk)
{
sendJS("updateStatus('a', true)")
OutputDebug Updated AFK
}else if(tram && wb.Document.getElementById("trampoline-switch").checked != tram)
{
sendJS("updateStatus('t', true)")
OutputDebug Updated Trampoline %afk% %tram%
}else
if(gard && wb.Document.getElementById("garden-switch").checked !=gard)
{
sendJS("updateStatus('g', true)")
}
sleep, 50
}
updateSetting(setting,value){
OutputDebug ran s,%setting%v,%value%
if(setting == "water"){
;Times to water, adjust as your bucket upgrades.
;AFK Interval (minutes)
if(value is digit)
{
global timesToWater
global timesToWaterUD
GuiControl,TTRTools:,timesToWater,%value%
GuiControl,TTRTools:,timesToWaterUD,%value%
}
else
sendJS("alert('Not a number! Error!')")
}
if(setting == "replant"){
;Replant plants (boolean) - True = destroy plant and plant new, False = just water plant and move on
if(value != "0" && value != 0 && value != "false")
{
GuiControl,TTRTools:,replant,1
}
else
GuiControl,TTRTools:,replant,0
}
if(setting == "interval"){
;AFK Interval (minutes)
if(value is digit)
{
global timeAFK
global timeAFKUD
GuiControl,TTRTools:,timeAFK,%value%
GuiControl,TTRTools:,timeAFKUD,%value%
}
else
sendJS("alert('Not a number! Error!')")
}
if(setting == "repeat"){
;Repeat Trampoline bot (full auto)
OutputDebug repeat
if(value != "0" && value != 0 && value != "false")
{
GuiControl,TTRTools:,repeat,1
}
else
GuiControl,TTRTools:,repeat,0
}
}
Hello() {
MsgBox Hello from JS_AHK :)
}
Run(t) {
Run, %t%
}
GetAHK_EnvInfo(){
return "AutoHotkey v" . A_AhkVersion . " " . (A_IsUnicode?"Unicode":"ANSI") . " " . (A_PtrSize*8) . "-bit"
}
Multiply(a,b) {
;MsgBox % a " * " b " = " a*b
return a * b
}
MyButton1() {
wb := getDOM()
MsgBox % wb.Document.getElementById("MyTextBox").Value
}
MyButton2() {
wb := getDOM()
FormatTime, TimeString, %A_Now%, dddd MMMM d, yyyy HH:mm:ss
Random, x, %min%, %max%
data := "AHK Version " A_AhkVersion " - " (A_IsUnicode ? "Unicode" : "Ansi") " " (A_PtrSize == 4 ? "32" : "64") "bit`nCurrent time: " TimeString "`nRandom number: " x
wb.Document.getElementById("MyTextBox").value := data
}