-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ahk
205 lines (163 loc) · 5.28 KB
/
test.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
#NoEnv
SetBatchLines, -1
#SingleInstance, Force
CoordMode, Mouse, Screen
#Include KWARK.ahk
ckval := 0
global A_SelfPID := DllCall("GetCurrentProcessId")
Gosub, TestWindow2
Return
TestWindow2:
demo := new KWARK()
dynavar1 := 0
dynavar2 := "text"
timeReader := Func("ClockVar")
script_ram := Func("ScriptRam")
cluePage := Func("Clue_Form")
dynaVar3 := [ "Revolver" , "Dagger" , "Lead Pipe" , "Candlestick" , "Wrench", "Kindness", "Ford F150", "Cheese Whiz" ]
Who_dunnit := [ "Mrs Peacock" , "Colonel Mustard" , "Reverend Green", "Professor Plum" , "Miss Scarlet", "Mrs White" , "Ms Frizzle", "Pilsbury Dough Boy"]
Where_at := ["Bathroom","Study","Dining Room","Game Room","Garage","Bedroom","Living Room","Kitchen","Courtyard","Cum Dungeon","Gamer Cave"]
Fields := ["Who" , "Where", "Weapon"]
dv3Viewr := Func("ArrayV").Bind(demo, "dv3Viewr", dynaVar3)
itWas_Who := ""
itWas_Where := ""
itWas_Weapon := ""
global itWas_Who, itWas_Where, itWas_Weapon
demo.AddDynaVar("dynavar1" , "dynavar2", "dynavar3" , "timeReader", "script_ram")
demo.AddBoundFunc("dv3Viewr")
demo.LoadTemplate("Views/base.html", "KWARK")
demo.LoadView("Views/tabview")
demo.LoadView("Views/testView","v-pills-dynavar",{id:"testdynamic",Title:"TestWindow", Variable:"<button class='btn btn-primary' data-label='TestDVars' class='test test2' onclick=""neutron.Button(event)"">Click Me!</button>", Variable2:"<span class='badge badge-secondary' id='dynavar1'>" . dynavar1 . "</span>", Variable3:"<span id='dynavar2'>" . dynavar2 . "</span>"})
demo.Show("w840 h680")
Return
TestBreak:
ckval += 1
tbreak_ms := 5000
MsgBox % ckval . ": Hit ok when ready"
Sleep, % tbreak_ms
Return
TestWindow1:
demo2 := new NeutronWindowX()
demo2.Show("w840 h680")
demo2.PollingStop()
Return
MemTT:
TT(ScriptRam(), "ScriptRam")
Return
NeutronClose:
KWARK_Close:
ExitApp
return
ReloadScript:
Reload
Return
TestDVars:
dynavar1 += 1
dynavar2 .= "!"
Return
ScriptRam() {
Return % GetProcessMemoryUsage(A_SelfPID) " MB"
}
Clue_Form(neutron){
global
; MsgBox % CF
newFormHtml := "<form onsubmit='ahk.Submit(event)'>"
For k , field in Fields {
newFormHtml .= "`n<label class='my-1 mr-2' for='clue" . Field . "'>" . Field . "?</label><select class='custom-select my-1 mr-sm-2' id='clue" . Field . "'><option selected>Choose...</option>"
if (k == 1) {
For list_k ,list_v in Who_dunnit {
newFormHtml .= "<option value='" . list_v . "'>" . list_v . "</option>"
}
} Else If (k == 2) {
For list_k ,list_v in Where_at {
newFormHtml .= "<option value='" . list_v . "'>" . list_v . "</option>"
}
} Else If (k == 3) {
For list_k ,list_v in dynaVar3 {
newFormHtml .= "<option value='" . list_v . "'>" . list_v . "</option>"
}
}
newFormHtml .= "</select>"
}
newFormHtml .= "<button type='submit' class='btn btn-primary my-1'>Submit</button></form>"
demo.LoadHTML(newFormHtml, "cluePage")
; Return % newFormHtml
}
ClockVar(prefix := "") {
return % prefix . A_Hour . ":" . A_Min . ":" . A_Sec . ":" . A_MSec
}
ArrayV(neutron, table, array){
sectionhtml := ""
For index, content in array {
sectionhtml .= "<tr><td>" . index . "</td><td>" . content . "</td></tr>"
}
return sectionhtml
}
ArrayViewer(neutron, array, value) {
array := %array%
array.Push(value)
}
Submitted(neutron, event)
{
; Some events have a default action that needs to be prevented. A form will
; redirect the page by default, but we want to handle the form data ourself.
event.preventDefault()
; Dismiss the GUI
neutron.hide()
; Use the GetFormData helper to get an associative array of the form data
formData := neutron.GetFormData(event.target)
MsgBox, % "Hello " formData.firstName " " formData.lastName "!"
; Re-show the GUI
neutron.Show()
}
Submit(neutron, event)
{
event.preventDefault()
formData := neutron.GetFormData(event.target)
out := "User Data::`n"
for name, value in formData
out .= name ": " value "`n"
out .= "`n"
; MsgBox % out
itWas_Who := formData.clueWho == "Choose..." ? "" : formData.clueWho
itWas_Where := formData.clueWhere == "Choose..." ? "" : formData.clueWhere
itWas_Weapon := formData.clueWeapon == "Choose..." ? "" : formData.clueWeapon
}
:*:..accuse::
msg := ""
If (!itWas_Who) {
msg := "I don't think it was anybody..."
} Else {
msg := "I think it was " . itWas_Who . ", in the " . itWas_Where . " with the " . itWas_Weapon . "!"
}
Send, % msg
Return
GetProcessMemoryUsage(ProcessID)
{
static PMC_EX, size := NumPut(VarSetCapacity(PMC_EX, 8 + A_PtrSize * 9, 0), PMC_EX, "uint")
if (hProcess := DllCall("OpenProcess", "uint", 0x1000, "int", 0, "uint", ProcessID)) {
if !(DllCall("GetProcessMemoryInfo", "ptr", hProcess, "ptr", &PMC_EX, "uint", size))
if !(DllCall("psapi\GetProcessMemoryInfo", "ptr", hProcess, "ptr", &PMC_EX, "uint", size))
return (ErrorLevel := 2) & 0, DllCall("CloseHandle", "ptr", hProcess)
DllCall("CloseHandle", "ptr", hProcess)
return Round(NumGet(PMC_EX, 8 + A_PtrSize * 8, "uptr") / 1024**2, 2)
}
return (ErrorLevel := 1) & 0
}
TT(Text := "" , Title := "" , Timeout := 5000){
if (FancyAssToolTipZ) {
FancyAssToolTipZ.A(Text , Title , Timeout)
} Else {
NK_TT( ( !Title ? : Title . ": " ) . Text , Timeout)
}
}
NK_TT(msg:="", timeout:=3000){
ToolTip
ToolTip % msg
SetTimer, NK_TT-Kill, %timeout%
return
NK_TT-Kill:
SetTimer, NK_TT-Kill, Off
ToolTip
return
}