-
Notifications
You must be signed in to change notification settings - Fork 136
/
main.aardio
328 lines (276 loc) · 9.96 KB
/
main.aardio
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
//RUNAS//
import process.admin;
import fonts.fontAwesome;
import win.ui;
/*DSG{{*/
mainForm = win.form(cls="AARDIO_WUBI_FORM";text="WubiLex ( 五笔助手 )";right=1040;bottom=642;bgcolor=16777215;border="none")
mainForm.add(
caption={cls="bkplus";text="WubiLex 11.7";left=35;top=12;right=153;bottom=30;color=15780518;dl=1;dt=1;font=LOGFONT(h=-16);z=5};
custom={cls="custom";left=0;top=40;right=1040;bottom=643;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;z=1};
logo={cls="bkplus";text='\uF0AD';left=6;top=9;right=35;bottom=34;color=15780518;dl=1;dt=1;font=LOGFONT(h=-18;name='FontAwesome');z=4};
stripHelp={cls="plus";text="帮助";left=557;top=5;right=651;bottom=40;align="left";color=16777215;dl=1;dt=1;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-19;name='FontAwesome');padding={left=12;top=3}};iconText='\uF06A';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=38};x=0.5;y=0.2;z=8};
stripHotkey={cls="plus";text="热键";left=355;top=5;right=449;bottom=40;align="left";color=16777215;dl=1;dt=1;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-19;name='FontAwesome');padding={left=12;top=3}};iconText='\uF11C ';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=38};x=0.5;y=0.2;z=9};
stripLex={cls="plus";text="词库";left=152;top=5;right=246;bottom=40;align="left";color=16777215;dl=1;dt=1;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-19;name='FontAwesome');padding={left=12;top=3}};iconText='\uF00A';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=38};x=0.5;y=0.2;z=3};
stripSetting={cls="plus";text="设置";left=456;top=5;right=550;bottom=40;align="left";color=16777215;dl=1;dt=1;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-19;name='FontAwesome');padding={left=12;top=3}};iconText='\uF0AD';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=38};x=0.5;y=0.2;z=7};
stripSpelling={cls="plus";text="反查";left=253;top=5;right=347;bottom=40;align="left";color=16777215;dl=1;dt=1;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-19;name='FontAwesome');padding={left=12;top=3}};iconText='\uF002';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=38};x=0.5;y=0.2;z=6};
titleBar={cls="bkplus";left=0;top=0;right=1042;bottom=41;bgcolor=14977280;dl=1;dr=1;dt=1;z=2}
)
/*}}*/
import win.ui.atom;
var atom,hwnd = mainForm.atom("6A99BEF6-4024-4537-9C43-7FE5BADCF5E3.wubi");
if(!atom){
win.showForeground(hwnd);
win.quitMessage();
return;
}
import fsys.update.simpleMain;
if( fsys.update.simpleMain(
"WubiLex ( 五笔助手 )",
"http://wubi.aardio.com/update/",
..io.appData("/aardio/std/wubi/app/update"),
function(version,description,status){})){
return 0;
}
import win.ui.simpleWindow;
win.ui.simpleWindow( mainForm );
import win.dlg.message;
import win.ui.tabs;
var tbs = win.ui.tabs(
mainForm.stripLex,
mainForm.stripSpelling,
mainForm.stripHotkey,
mainForm.stripSetting,
mainForm.stripHelp
);
tbs.skin({
foreground={
active=0xFFFFFFFF;
default=0x00FFFFFF;
hover=0x38FFFFFF
};
color={
default=0xFFFFFFFF;
};
checked={
foreground={default=0xFFFFFFFF;};
color={default=0xFF42A875;};
}
})
tbs.loadForm(1,"\dlg\dict\dict.aardio" );
tbs.loadForm(2,"\dlg\spelling.aardio" );
tbs.loadForm(3,"\dlg\hotkey.aardio" ); tbs.preloadForm(3,false)
tbs.loadForm(4,"\dlg\setting.aardio" );
tbs.loadForm(5,"\dlg\help\help.aardio" );
tbs.selIndex = 1;
import win.util.tray;
mainForm.onMinimize = function(lParam){
mainForm.tray = win.util.tray(mainForm)
mainForm.modifyStyleEx(0x40000/*_WS_EX_APPWINDOW*/,0x80/*_WS_EX_TOOLWINDOW*/)
mainForm.show(false);
import process;
process.emptyWorkingSet();
return true;
}
mainForm.onClose = function(hwnd,message,wParam,lParam){
if(!_STUDIO_INVOKED){
mainForm.onMinimize();
return true;
}
}
mainForm.onDestroy = function(){
if(mainForm.tray){
mainForm.tray.delete()
}
}
import config;
import process;
import win.ui.menu;
import key;
mainForm.wndproc = {
[0xACCF/*_WM_TRAYMESSAGE*/ ] = function(hwnd,message,wParam,lParam){
if( lParam = 0x205/*_WM_RBUTTONUP*/ ){
win.setForeground(mainForm.hwnd)
mainForm.popmenu = win.ui.popmenu(mainForm);//创建弹出菜单
mainForm.popmenu.add('设置输入法',function(id){
tbs.selIndex = 4;
mainForm.show();
});
mainForm.popmenu.add('设置超级热键',function(id){
tbs.selIndex = 3;
mainForm.show();
});
mainForm.popmenu.add();
mainForm.popmenu.add('管理码表',function(id){
tbs.selIndex = 1;
tbs.selForm.showLex();
mainForm.show();
});
mainForm.popmenu.add('管理短语',function(id){
tbs.selIndex = 1;
tbs.selForm.showPhrase();
mainForm.show();
});
mainForm.popmenu.add();
var hotkey = "";
if(config.hotkey.spelling[[1]] && config.hotkey.spelling[[2]] ){
var mod = config.hotkey.spelling[[1]];
var keys = {}
if( mod & 2/*_MOD_CONTROL*/ ){
table.push(keys,"Ctrl");
}
if( mod & 1/*_MOD_ALT*/ ){
table.push(keys,"Alt");
}
if( mod & 4/*_MOD_SHIFT*/ ){
table.push(keys,"Shift");
}
table.push(keys,key.getName(config.hotkey.spelling[[2]]));
hotkey = '\t' + string.join(keys," + ");
}
mainForm.popmenu.add('字根反查' + hotkey,function(id){
tbs.selIndex = 2;
mainForm.show();
publish("spellingFocus")
});
mainForm.popmenu.add('└── 字根键位图',function(id){
publish("showEtymon");
mainForm.show();
});
mainForm.popmenu.add();
import tsfInput;
var imStatus = tsfInput.getStatus();
var wubiVersion = ""
if(..globalSystemWubiVersionText){
wubiVersion = " ( 码表:" + ..globalSystemWubiVersionText + " )"
}
var id = mainForm.popmenu.add('启用微软五笔'+wubiVersion,function(id){
tsfInput.enableWubi(!imStatus.wubi);
});
mainForm.popmenu.check(id,imStatus.wubi,0/*_MF_BYCOMMAND*/);
mainForm.popmenu.add('└── 系统设置 / 五笔',function(id){
import process.control;
process.control("ms-settings:regionlanguage-chsime-wubi");
});
var id = mainForm.popmenu.add('启用英文键盘',function(id){
tsfInput.enableUsKeyboard(!imStatus.en);
});
mainForm.popmenu.add();
mainForm.popmenu.check(id,imStatus.en,0/*_MF_BYCOMMAND*/);
var id = mainForm.popmenu.add('启用微软拼音',function(id){
tsfInput.enablePinyin(!imStatus.pinyin);
});
mainForm.popmenu.check(id,imStatus.pinyin,0/*_MF_BYCOMMAND*/);
import ui.doublePinyinMenu;
mainForm.popmenu.add('└── 双拼方案',ui.doublePinyinMenu(mainForm));
mainForm.popmenu.add();//分隔线
mainForm.popmenu.add('打开系统输入法设置',function(id){
import process.control;
process.control("ms-settings:keyboard")
});
var menuDefTip = ..win.ui.popmenu(..mainForm);
var id = menuDefTip.add("所有应用使用同一输入法",function(){
..tsfInput.setLocal(!..tsfInput.getLocal());
})
menuDefTip.check(id,!..tsfInput.getLocal(),0/*_MF_BYCOMMAND*/);
var inputMethodOverride = ..tsfInput.getInputMethodOverride();
var tips = ..sys.input.getEnabledLayoutOrTips();
if(..table.next(tips)){
for(tip,tipType in tips){
if(tipType==2/*_LOTP_KEYBOARDLAYOUT*/){
var desc = ..sys.input.getDescription(tip);
if(#desc){
var id = menuDefTip.add(desc,function(){
if(tip!=inputMethodOverride) ..sys.input.setDefault(tip);
else ..sys.input.setDefault("");
})
menuDefTip.check(id,tip==inputMethodOverride,0/*_MF_BYCOMMAND*/);
}
}
}
for(tip,tipType in tips){
if(tipType==1/*_LOTP_INPUTPROCESSOR*/){
var desc = ..sys.input.getDescription(tip);
if(#desc){
var id = menuDefTip.add(desc,function(){
if(tip!=inputMethodOverride) ..sys.input.setDefault(tip);
else ..sys.input.setDefault("");
})
menuDefTip.check(id,tip==inputMethodOverride,0/*_MF_BYCOMMAND*/);
}
}
}
}
mainForm.popmenu.add('设置默认输入法',menuDefTip);
mainForm.popmenu.add();
mainForm.popmenu.add('打开屏幕键盘',function(id){
import process.wow64;
process.wow64.execute("osk")
});
var id = mainForm.popmenu.add('反转鼠标左右按键',function(id){
::User32.SwapMouseButton(!::User32.GetSystemMetrics(23));
});
mainForm.popmenu.check(id,::User32.GetSystemMetrics(23),0/*_MF_BYCOMMAND*/);
mainForm.popmenu.add();
mainForm.popmenu.add('官方网站',function(id){
process.openUrl("http://wubi.aardio.com")
});
mainForm.popmenu.add();
mainForm.popmenu.add('退出',function(id){
win.quitMessage();
});
var pt = ::POINT();
::User32.GetCursorPos(pt);
mainForm.popmenu.popup(pt.x,pt.y,true)
}
elseif( lParam = 0x202/*_WM_LBUTTONUP*/ ) {
mainForm.show();
win.setForeground(mainForm.hwnd);
if(tbs.selIndex = 2){
publish("spellingFocus")
}
}
}
}
subscribe("spellingHotkeyChange",function(...){
if(#config.hotkey.spelling){
if(mainForm.hkSpellingId){
mainForm.unreghotkey(mainForm.hkSpellingId)
mainForm.hkSpellingId = null;
}
mainForm.hkSpellingId = mainForm.reghotkey( function(id,mod,vk){
var hwndForeground = win.getForeground()
if(hwndForeground == mainForm.hwnd){
mainForm.onMinimize();
}
else {
tbs.selIndex = 2;
mainForm.show();
win.setForeground(mainForm.hwnd);
publish("spellingFocus");
}
},config.hotkey.spelling[1],config.hotkey.spelling[2])
}
} )
publish("spellingHotkeyChange");
subscribe("showEtymon",function(...){
tbs.selIndex = 5;
tbs.selForm.showEtymon();
} )
mainForm.tabs = tbs;
if(_ARGV.tray){
mainForm.modifyStyleEx(0x40000/*_WS_EX_APPWINDOW*/,0x80/*_WS_EX_TOOLWINDOW*/)
mainForm.setTimeout(
function(){
mainForm.tray = win.util.tray(mainForm)
},3000
);
}
else {
mainForm.show();
}
import win.ui.accelerator;
win.ui.accelerator({
{ ctrl = true; vkey = 'W'#; oncommand = function(id,event){
mainForm.hitMin() } }
},mainForm);
return win.loopMessage();