-
Notifications
You must be signed in to change notification settings - Fork 2
/
menu.spf
192 lines (154 loc) · 3.73 KB
/
menu.spf
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
\ Ôàéë: menu.spf
\ Àâòîð: VoidVolker
\ Äàòà: 27/08/2015 10:48
\ Âåðñèÿ: 1.4
0
CELL -- -menuXT
CELL -- -menuX
CELL -- -menuY
CELL -- -cancel
CONSTANT /menu
: MenuShow { m \ h -- } \ ( menu -- )
m @ EXECUTE TO h
0 \ TrackPopupMenuEx òðåáóåò õýíäë îêíà, êîòîðîå áóäåò ïîëó÷àòü îïîâåùåíèÿ î ñîáûòèÿõ ìåíþ — äëÿ ýòîãî êàêèì-òî îáðàçîì èñïîëüçóåòñÿ èêîíêà ííêðîíà (ýòîò êóñîê êîäà ñ äðåìó÷èõ âðåìåí)
WITH TrayIcon Z" static" 0 0 Window >R ENDWITH
R@ R> SetForegroundWindow DROP
m -menuY @ m -menuX @
256 h TrackPopupMenuEx \ 0|xt
h DestroyMenu DROP
?DUP IF
EXECUTE
ELSE
m -cancel @ ?DUP IF
EXECUTE
THEN
THEN
;
: MenuShowAtCursor \ ( menu -- )
>R CalcMenuYX R@ -menuX !
R@ -menuY !
R> MenuShow
;
: MenuXY! \ ( x y menu -- )
SWAP OVER -menuX ! -menuY !
;
: Menu:
CREATE
HERE \ menu
0 , 0 , 0 , 0 ,
:NONAME
POSTPONE POPUPMENU
;
\ Õàêè ôëàãîâ - ìîæíî ñäåëàòü ïóíêò ìåíþ çàáëîêèðîâàííûì, ñ ãàëî÷êîé, íîâûé ñòîëáåö èëè íîðìàëüíûì
: ItemGrey 1 ['] MENUITEM 81 + DUP @ ROT OR SWAP ! ;
: ItemDisable 2 ['] MENUITEM 81 + DUP @ ROT OR SWAP ! ;
: ItemCheck 8 ['] MENUITEM 81 + DUP @ ROT OR SWAP ! ;
: ItemCol 32 ['] MENUITEM 81 + DUP @ ROT OR SWAP ! ;
: ItemBreak 64 ['] MENUITEM 81 + DUP @ ROT OR SWAP ! ;
: ItemNormal 0 ['] MENUITEM 81 + ! ;
\ Òîæå ñàìîå äëÿ ïîäìåíþ
: SubGrey 1 ['] END-POPUP 21 + DUP @ ROT OR SWAP ! ;
: SubDisable 2 ['] END-POPUP 21 + DUP @ ROT OR SWAP ! ;
: SubCheck 8 ['] END-POPUP 21 + DUP @ ROT OR SWAP ! ;
: SubCol 32 ['] END-POPUP 21 + DUP @ ROT OR SWAP ! ;
: SubBreak 64 ['] END-POPUP 21 + DUP @ ROT OR SWAP ! ;
: SubNormal 16 ['] END-POPUP 21 + ! ;
\ Ïîñëå ñîçäàíèÿ ïóíêòà ìåíþ ñëåäóþùèå ïóíêòû ìåíþ áóäóò íîðìàëüíûìè
: ;Menu
POSTPONE END-MENU
[COMPILE] ; SWAP !
; IMMEDIATE
: Item:
eval-string, \ 0 PARSE [COMPILE] SLITERAL
[COMPILE] [NONAME
; IMMEDIATE
: Item \ ( a u -- )
[COMPILE] [NONAME
; IMMEDIATE
: ;Item \ ( xt -- )
[COMPILE] NONAME]
POSTPONE MENUITEM
POSTPONE ItemNormal
; IMMEDIATE
: SubMenu(
POSTPONE POPUP
; IMMEDIATE
: )SubMenu \ ( a u -- )
POSTPONE END-POPUP
; IMMEDIATE
: )SubMenu: \ ( -- ) ( "string" -> )
eval-string, \ 0 PARSE [COMPILE] SLITERAL
POSTPONE END-POPUP
POSTPONE SubNormal
; IMMEDIATE
: ----
POSTPONE MENUSEPARATOR
; IMMEDIATE
: Cancel
[COMPILE] [NONAME
; IMMEDIATE
: ;Cancel
DUP >R
[COMPILE] NONAME] POSTPONE DROP
OVER R> SWAP -cancel !
; IMMEDIATE
\EOF
\ Ïðèìåð:
<%
Menu: MyMenu1 \ Ãîðèçîíòàëüíîå ìåíþ. Äëÿ âåðòèêàëüíîãî - ïðîñòî íå íàäî èñïîëüçîâàòü ItemCol è SubCol
Item: "Item 1"
." Item 1 run" CR
;Item
\ Äåëàåì ñëåäóþùèé ïóíêò ìåíþ ñïðàâà:
ItemCol
\ È äîáàâëåì åìó ãàëî÷êó:
ItemCheck
Item: "Item 2"
." Item 2 run" CR
;Item
SubMenu(
Item: "Item 3"
." Item 3 run" CR
;Item
\ Äîáàâëÿåì ðàçäåëèòåëü - ãîðèçîíòàëüíóþ ÷åðòó
----
Item: "Item 4"
." Item 4 run" CR
;Item
\ Òàê æå ñìåùàåì è ïîäìåíþ âïðàâî:
SubCol )SubMenu: "Submenu"
Cancel
." Íè÷åãî íå áûëî âûáðàíî" CR
;Cancel
;Menu
Menu: MyMenu2
FT-CUR FT>DD.MM.YYYY/hh:mm:ss Item
S" rundll32 shell32,Control_RunDLL timedate.cpl" START-APP
;Item
S" COMSPEC" ENV Item
S" COMSPEC" ENV START-APP
;Item
;Menu
%>
#( Show_my_menu
\ NoActive
SingleInstance
WatchHotKey: "{F3}"
Action:
MyMenu1 MenuShowAtCursor
)#
#( Show_my_menu
\ NoActive
SingleInstance
WatchHotKey: "{F4}"
Action:
MyMenu1 MenuShow
)#
#( Show_my_menu
\ NoActive
SingleInstance
WatchHotKey: "{F5}"
Action:
100 100 MyMenu1 MenuXY!
MyMenu1 MenuShow
)#