-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo-stdin.vbs
66 lines (53 loc) · 2.23 KB
/
demo-stdin.vbs
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
'------------------------------------------------------------------------
'
' VB script demo to use the GTK-server using STDIN
'
' Peter van Eerten June 3 2004.
' Revised for GTK-server 1.2 at October 10, 2004
' Revised for GTK-server 1.3 at December 5, 2004
'------------------------------------------------------------------------
Option Explicit
Function GTK(st)
'Open the pipe and write
gtkserver.StdIn.WriteLine st
'Get GTK-server response
GTK = gtkserver.StdOut.ReadLine
End Function
'------------------------------------------------------------------------
'Declare variables
DIM process, gtkserver
DIM tmp, win, table, button, entry, text, radio1, radio2, even
'Define GTK-server process
SET process = CreateObject("Wscript.Shell")
'Execute GTK-server
SET gtkserver = process.Exec("gtk-server -stdin")
'Define GUI
GTK("gtk_init NULL NULL")
win = GTK("gtk_window_new 0")
GTK("gtk_window_set_title " & win & " " & CHR(34) & "Visual Basic Script 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 )
DO
even = GTK("gtk_server_callback wait")
IF even = entry THEN
tmp = GTK("gtk_entry_get_text " & entry )
IF LEN(tmp) > 1 THEN GTK("gtk_text_insert " & text & " NULL NULL NULL " & CHR(34) & tmp & CHR(10) & CHR(34) & " -1")
REM Empty entry field
GTK("gtk_editable_delete_text " & entry & " 0 -1")
END IF
LOOP UNTIL even = button
GTK("gtk_server_exit")
' End