-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathExample.ahk
83 lines (70 loc) · 1.71 KB
/
Example.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
#SingleInstance off
#NoTrayIcon
SendMode Input
#Include Lib\Webapp.ahk
__Webapp_AppStart:
;<< Header End >>
;Get our HTML DOM object
iWebCtrl := getDOM()
;Change App name on run-time
setAppName("My Webapp.ahk Application")
; cut auto run main thread.
Return
; Webapp.ahk-only Sensitive hotkeys
#IfWinActive, ahk_group __Webapp_windows
!Enter::
;!toggle
setFullscreen(!__Webapp_FullScreen)
Return
#IfWinActive
; 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()
setZoomLevel(100)
if InStr(NewURL,"index.html") {
disp_info()
}
}
disp_info() {
wb := getDOM()
Sleep, 10
x := wb.document.getElementById("ahk_info")
x.innerHTML := "<i>Webapp.ahk is currently running on " . GetAHK_EnvInfo() . ".</i>"
}
; Functions to be called from the html/js source
Hello() {
MsgBox Hello from JS_AHK :)
}
RunMyJSFunction() {
window := getWindow()
window.myFunction()
}
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
}