-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgtk.wsh.js
70 lines (61 loc) · 2.34 KB
/
gtk.wsh.js
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
/*
* gtk.wsh.js
*
* Windows Scripting Host - Javascript (Microsoft JScript) (wsh-js) GTK GUI Example
* 2020-02-09
* Go Namhyeon <abuse@catswords.net>
*
* Requirements
* * https://www.gtk-server.org/ (GTK-Server)
* * https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer (GTK-for-Windows-Runtime-Environment-Installer)
* * https://www.dlldosyaindir.com/dllindir/libffi-6-bit32.rar (libffi-6.dll)
*
* Notes
* * GTK-Server is not supported GTK3 in Windows, so you have to use GTK2
*
*/
function CreateObject(objName) {
return new ActiveXObject(objName);
}
function CHR(ord) {
return String.fromCharCode(ord);
}
function GTK(st) {
gtkserver.StdIn.WriteLine(st);
return gtkserver.StdOut.ReadLine();
}
var process = CreateObject("Wscript.Shell");
var gtkserver = process.Exec("gtk-server -stdin");
function main() {
var tmp, win, table, button, entry, text, radio1, radio2, even;
GTK("gtk_init NULL NULL");
win = GTK("gtk_window_new 0");
GTK("gtk_window_set_title " + win + " " + CHR(34) + "WSH Javascript demo program using STDIN" + CHR(34));
GTK("gtk_widget_set_usize " + win + " 450 400");
table = GTK("gtk_table_new 50 50 1");
GTK("gtk_container_add " + win + " " + table );
button = GTK("gtk_button_new_with_label Exit");
GTK("gtk_table_attach_defaults " + table + " " + button + " 41 49 45 49");
entry = GTK("gtk_entry_new");
GTK("gtk_table_attach_defaults " + table + " " + entry + " 1 40 45 49");
text = GTK("gtk_text_new NULL NULL");
GTK("gtk_table_attach_defaults " + table + " " + text + " 1 49 8 44");
radio1 = GTK("gtk_radio_button_new_with_label_from_widget NULL Yes");
GTK("gtk_table_attach_defaults " + table + " " + radio1 + " 1 10 1 4");
radio2 = GTK("gtk_radio_button_new_with_label_from_widget " + radio1 + " No");
GTK("gtk_table_attach_defaults " + table + " " + radio2 + " 1 10 4 7");
GTK("gtk_widget_show_all " + win );
GTK("gtk_widget_grab_focus " + entry );
while(!(even == button)) {
even = GTK("gtk_server_callback wait");
if(even == entry) {
tmp = GTK("gtk_entry_get_text " + entry );
if(tmp.length > 1)
GTK("gtk_text_insert " + text + " NULL NULL NULL " + CHR(34) + tmp + CHR(10) + CHR(34) + " -1");
// Empty entry field
GTK("gtk_editable_delete_text " + entry + " 0 -1")
}
}
GTK("gtk_server_exit");
}
main();