-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbenizara190317a.ahk
1785 lines (1715 loc) · 34 KB
/
benizara190317a.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
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;-----------------------------------------------------------------------
; 名称:benizara / 紅皿
; 機能:Yet another NICOLA Emulaton Software
; キーボード配列エミュレーションソフト
; ver.0.1.3.1 .... 2019/3/17
; 作者:Ken'ichiro Ayaki
;-----------------------------------------------------------------------
#InstallKeybdHook
#MaxhotkeysPerInterval 200
#KeyHistory
SetWorkingDir, %A_ScriptDir%
idxLogs := 0
aLogCnt := 0
loop, 64
{
_idx := A_Index - 1
aLog%_idx% := "_"
}
full_command_line := DllCall("GetCommandLine", "str")
if (RegExMatch(full_command_line, " /create(?!\S)"))
{
thisCmd = schtasks.exe /create /tn benizara /tr `"%A_ScriptFullPath%`" /sc onlogon /rl highest /F
Run *Runas %thisCmd%
ExitApp
}
if (RegExMatch(full_command_line, " /delete(?!\S)"))
{
thisCmd = schtasks.exe /delete /tn \benizara /F
Run *Runas %thisCmd%
ExitApp
}
if (RegExMatch(full_command_line, " /admin(?!\S)"))
{
Run *Runas %A_ScriptFullPath%
ExitApp
}
g_Romaji = A
g_Oya = N
g_Koyubi = N
g_Modifier = 0
g_LayoutFile =.\NICOLA配列.bnz
g_Continue = 1
g_Threshold = 150 ;
g_Overlap = 50
g_ZeroDelay = 1 ; 零遅延モード
g_ZeroDelayOut =
g_Offset = 20
g_OyaR = 0
g_OyaL = 0
vLayoutFile := g_LayoutFile
g_Tau = 0
Gosub,ReadLayout
g_allTheLayout := vAllTheLayout
g_LayoutFile := vLayoutFile
g_SendTick =
Menu, Tray, Add, 紅皿設定,Settings
Menu, Tray, Add, ログ,Logs
Menu, Tray, Icon
SetBatchLines, -1
fPf := Pf_Init()
g_OyaRTick := Pf_Count() ;A_TickCount
g_OyaLTick := Pf_Count() ;A_TickCount
g_MojiTick := Pf_Count() ;A_TickCount
VarSetCapacity(lpKeyState,256,0)
SetTimer Interrupt10,10
vIntKeyUp = 0
vIntKeyDn = 0
/*
Hotkey,Space,gSpace
Hotkey,Space up,gSpaceUp
Hotkey,Space,off
Hotkey,Space up,off
Hotkey,*sc079,gOyaR
Hotkey,*sc079 up,gOyaRUp
kOyaR := "sc079" ; 単独打鍵
Hotkey,*sc07B,gOyaL
Hotkey,*sc07B up,gOyaLUp
kOyaL := "sc07B" ; 単独打鍵
fKeySingle = 0 ; 単独打鍵無しモード
*/
GoSub,Init
return
#include IME.ahk
#include ReadLayout6.ahk
#include Settings7.ahk
#include PfCount.ahk
#include Logs1.ahk
;-----------------------------------------------------------------------
; 機能:モディファイアキー
;-----------------------------------------------------------------------
LCtrl::
kName = LCtrl
MojiCode = 0
;g_Modifier := g_Modifier | 1
Goto, keydown
LCtrl up::
kName = LCtrl
MojiCode = 0
;g_Modifier := g_Modifier & 254 ; 0xFE
Goto, keyup
RCtrl::
kName = RCtrl
MojiCode = 0
;g_Modifier := g_Modifier | 2
Goto, keydown
RCtrl up::
kName = RCtrl
MojiCode = 0
;g_Modifier := g_Modifier & 253 ; 0xFD
Goto, keyup
LShift::
kName = LShift
MojiCode = 0
;g_Koyubi = K
Goto, keydown
LShift up::
kName = LShift
MojiCode = 0
;g_Koyubi = N
Goto, keyup
RShift::
kName = RShift
MojiCode = 0
;g_Koyubi = K
Goto, keydown
RShift up::
kName = RShift
MojiCode = 0
;g_Koyubi = N
Goto, keyup
;WindowsキーとAltキーをホットキー登録すると、WindowsキーやAltキーの単体押しが効かなくなるのでコメントアウトする。
;代わりにInterrupt10 でA_Priorkeyを見て、Windowsキーを監視する。
;但し、WindowsキーやAltキーを離したことを感知できないことに留意。
;ver.0.1.3 にて、GetKeyState でWindowsキーとAltキーとを監視
;LAlt::
kName = LAlt
MojiCode = 0
g_Modifier = Alt
Goto, keydown
;LAlt up::
kName = LAlt
MojiCode = 0
g_Modifier =
Goto, keyup
;RAlt::
kName = RAlt
MojiCode = 0
g_Modifier = Alt
Goto, keydown
;RAlt up::
kName = RAlt
MojiCode = 0
g_Modifier =
Goto, keyup
;LWin::
kName = LWin
MojiCode = 0
g_Modifier = Win
Goto, keydown
;LWin up::
kName = LWin
MojiCode = 0
g_Modifier =
Goto, keyup
;RWin::
kName = RWin
MojiCode = 0
g_Modifier = Win
Goto, keydown
;RWin up::
kName = RWin
MojiCode = 0
g_Modifier =
Goto, keyup
;*sc079:: ; 変換
gOyaR:
Critical
gosub,Interrupt10
RegLogs("R down")
if(g_KeyRepeat == 1 && g_KeyInPtn == "R")
{
g_OyaR = 1
g_OyaRTick := Pf_Count() ;A_TickCount
g_MRInterval := g_OyaRTick - g_MojiTick ; 文字キー押しから右親指キー押しまでの期間
g_Oya = R
Gosub, SendOnHoldO ; 保留キーの打鍵
g_OyaOnHold := g_Oya
g_SendTick := g_OyaRTick + g_Threshold
g_KeyInPtn := g_Oya
}
if g_OyaR <> 1 ; キーリピートの抑止
{
g_OyaR = 1
g_OyaRTick := Pf_Count() ;A_TickCount
g_MRInterval := g_OyaRTick - g_MojiTick ; 文字キー押しから右親指キー押しまでの期間
g_Oya = R
if g_KeyInPtn = ;初期状態
{
g_OyaOnHold := g_Oya
g_SendTick := g_OyaRTick + g_Threshold
g_KeyInPtn := g_KeyInPtn . g_Oya
}
else if g_KeyInPtn = M ;Mオン状態
{
g_OyaOnHold := g_Oya
g_SendTick := g_OyaRTick + g_MRInterval
g_KeyInPtn := g_KeyInPtn . g_Oya
}
else if g_KeyInPtn = L ;Oオン状態
{
Gosub, SendOnHoldO ; 保留キーの打鍵
g_OyaOnHold := g_Oya
g_SendTick := g_OyaRTick + g_Threshold
g_KeyInPtn := g_KeyInPtn . g_Oya
}
else if g_KeyInPtn = ML ; M-Oオン状態
{
Gosub, SendOnHoldMO ; 保留キーの打鍵
g_OyaOnHold := g_Oya
g_SendTick := g_OyaRTick + g_Threshold
g_KeyInPtn := g_KeyInPtn . g_Oya
}
else if g_KeyInPtn = LM ; O-Mオン状態
{
; 処理B 3キー判定
g_LMInterval := g_MojiTick - g_OyaLTick ; 左親指キー押しから文字キー押しまでの期間
g_MRInterval := g_OyaRTick - g_MojiTick ; 文字キー押しから右親指キー押しまでの期間
if g_MRInterval > %g_LMInterval%
{
Gosub, SendOnHoldMO ; 保留キーの打鍵
g_OyaOnHold := g_Oya
g_SendTick := g_OyaRTick + g_Threshold
g_KeyInPtn := g_KeyInPtn . g_Oya
}
else
{
if g_Continue = 0
{
Gosub, SendOnHoldO ; 保留キーの打鍵
}
g_OyaOnHold := g_Oya
g_SendTick := g_OyaRTick + g_MRInterval
g_KeyInPtn := g_KeyInPtn . g_Oya
}
}
else if g_KeyInPtn in RMr,LMl ; O-M-Oオフ状態
{
if g_Continue = 0
{
Gosub, SendOnHoldO ; 保留キーの打鍵
}
g_OyaOnHold := g_Oya
g_SendTick := g_OyaRTick + g_MRInterval
g_KeyInPtn := g_KeyInPtn . g_Oya
}
}
return
;*sc079 up::
gOyaRUp:
Critical
gosub,Interrupt10
if g_OyaR = 1 ; 右親指シフトキーの単独シフト
{
RegLogs("R up")
g_OyaR = 0
g_OyarTick := Pf_Count() ;A_TickCount
g_MrInterval := g_OyarTick - g_MojiTick ; 文字キー押しから右親指キー解除までの期間
g_RrInterval := g_OyarTick - g_OyaRTick ; 右親指キー押しから右親指キー解除までの期間
if g_OyaL = 1
g_Oya = L
else
g_Oya = N
if g_KeyInPtn = R ; Oオン状態
{
Gosub, SendOnHoldO ; 保留親指キーの打鍵
}
else if g_KeyInPtn = MR ; M-Oオン状態
{
if g_RrInterval > %g_Threshold%
{
; タイムアウト状態:親指シフト文字の出力
Gosub, SendOnHoldMO ; 保留キーの打鍵
} else {
; 処理F
vOverlap := 100*g_RrInterval/g_MrInterval
if vOverlap >= %g_Overlap%
{
if g_RrInterval <= %g_Tau%
{
Gosub, SendOnHoldM ; 保留キーの単独打鍵
Gosub, SendOnHoldO ; 保留キーの単独打鍵
} else {
Gosub, SendOnHoldMO ; 保留キーの同時打鍵
}
} else {
Gosub, SendOnHoldMO ; 保留キーの同時打鍵
}
}
}
else if g_KeyInPtn = RM ; O-Mオン状態
{
if g_MrInterval > %g_Threshold%
{
; タイムアウト状態:親指シフト文字の出力
Gosub, SendOnHoldMO ; 保留キーの打鍵
} else {
; 処理D
vOverlap := 100*g_MrInterval/g_RrInterval
if vOverlap >= %g_Overlap%
{
if g_MrInterval <= %g_Tau%
{
Gosub, SendOnHoldO ; 保留キーの単独打鍵
} else {
;g_MrTimeout := g_MrInterval*(100-g_Overlap)/g_Overlap
g_MrTimeout := g_MrInterval/2
g_SendTick := g_OyarTick + g_MrTimeout
g_KeyInPtn = RMr
}
} else {
;g_MrTimeout := g_MrInterval*(100-g_Overlap)/g_Overlap
g_MrTimeout := g_MrInterval/2
g_SendTick := g_OyarTick + g_MrTimeout
g_KeyInPtn = RMr
}
}
}
else if g_KeyInPtn in M,RMr,LMl ; O-M-Oオフ状態
{
; 何もしない
}
}
return
;*sc07B:: ; 無変換
gOyaL:
Critical
gosub,Interrupt10
RegLogs("L down")
if(g_KeyRepeat == 1 && g_KeyInPtn == "L")
{
g_OyaL = 1
g_OyaLTick := Pf_Count() ;A_TickCount
g_MLInterval := g_OyaLTick - g_MojiTick ; 文字キー押しから左親指キー押しまでの期間
g_Oya = L
Gosub, SendOnHoldO ; 保留キーの打鍵
g_OyaOnHold := g_Oya
g_SendTick := g_OyaLTick + g_Threshold
g_KeyInPtn := g_Oya
}
if g_OyaL <> 1 ; キーリピートの抑止
{
g_OyaL = 1
g_OyaLTick := Pf_Count() ;A_TickCount
g_MLInterval := g_OyaLTick - g_MojiTick ; 文字キー押しから左親指キー押しまでの期間
g_Oya = L
if g_KeyInPtn = ; 初期状態
{
g_OyaOnHold := g_Oya
g_SendTick := g_OyaLTick + g_Threshold
g_KeyInPtn := g_Oya
}
else if g_KeyInPtn = M ; Mオン状態
{
g_OyaOnHold := g_Oya
g_SendTick := g_OyaLTick + g_MLInterval
g_KeyInPtn := g_KeyInPtn . g_Oya
}
else if g_KeyInPtn = R ; Oオン状態
{
Gosub, SendOnHoldO ; 保留キーの打鍵
g_OyaOnHold := g_Oya
g_SendTick := g_OyaLTick + g_Threshold
g_KeyInPtn := g_KeyInPtn . g_Oya
}
else if g_KeyInPtn = MR ; M-Oオン状態
{
Gosub, SendOnHoldMO ; 保留キーの打鍵
g_OyaOnHold := g_Oya
g_SendTick := g_OyaLTick + g_Threshold
g_KeyInPtn := g_KeyInPtn . g_Oya
}
else if g_KeyInPtn = RM ; O-Mオン状態
{
; 処理B 3キー判定
g_RMInterval := g_MojiTick - g_OyaRTick ; 右親指キー押しから文字キー押しまでの期間
g_MLInterval := g_OyaLTick - g_MojiTick ; 文字キー押しから左親指キー押しまでの期間
if g_MRInterval > %g_LMInterval%
{
Gosub, SendOnHoldMO ; 保留キーの打鍵
g_OyaOnHold := g_Oya
g_SendTick := g_OyaLTick + g_Threshold
g_KeyInPtn := g_KeyInPtn . g_Oya
} else {
if g_Continue = 0
{
Gosub, SendOnHoldO ; 保留キーの打鍵
}
g_OyaOnHold := g_Oya
g_SendTick := g_OyaLTick + g_MLInterval
g_KeyInPtn := g_KeyInPtn . g_Oya
}
}
else if g_KeyInPtn in RMr,LMl ; O-M-Oオフ状態
{
if g_Continue = 0
{
Gosub, SendOnHoldO ; 保留キーの打鍵
}
g_OyaOnHold := g_Oya
g_SendTick := g_OyaLTick + g_MLInterval
g_KeyInPtn := g_KeyInPtn . g_Oya
}
}
return
;*sc07B up::
gOyaLUp:
Critical
gosub,Interrupt10
if g_OyaL <> 0 ; 右親指シフトキーの単独シフト
{
RegLogs("L up")
g_OyaL = 0
g_OyalTick := Pf_Count() ;A_TickCount
g_MlInterval := g_OyalTick - g_MojiTick ; 文字キー押しから左親指キー解除までの期間
g_LlInterval := g_OyalTick - g_OyaLTick ; 右親指キー押しから右親指キー解除までの期間
if g_OyaR = 1
g_Oya = R
else
g_Oya = N
if g_KeyInPtn = L ; Oオン状態
{
Gosub, SendOnHoldO ; 保留親指キーの打鍵
}
else if g_KeyInPtn = ML ;M-Oオン状態
{
if g_LlInterval > %g_Threshold%
{
; タイムアウト
Gosub, SendOnHoldMO ; 保留キーの打鍵
} else {
; 処理F
vOverlap := 100*g_LlInterval/g_MlInterval
if vOverlap <= %g_Overlap%
{
if g_LlInterval <= %g_Tau%
{
Gosub, SendOnHoldM ; 保留キーの単独打鍵
Gosub, SendOnHoldO ; 保留キーの単独打鍵
} else {
Gosub, SendOnHoldMO ; 保留キーの同時打鍵
}
} else {
Gosub, SendOnHoldMO ; 保留キーの同時打鍵
}
}
}
else if g_KeyInPtn = LM ;O-Mオン状態
{
if g_MlInterval > %g_Threshold%
{
; タイムアウト
Gosub, SendOnHoldMO ; 保留キーの打鍵
} else {
; 処理D
vOverlap := 100*g_MlInterval/g_LlInterval
if vOverlap >= %g_Overlap%
{
if g_MlInterval <= %g_Tau%
{
Gosub, SendOnHoldO ; 保留キーの単独打鍵
g_KeyInPtn = M
} else {
;g_MlTimeout := g_MlInterval*(100-g_Overlap)/g_Overlap
g_MlTimeout := g_MlInterval/2
g_SendTick := g_OyaUpTick + g_MlTimeout
g_KeyInPtn = LMl
}
} else {
;g_MlTimeout := g_MlInterval*(100-g_Overlap)/g_Overlap
g_MlTimeout := g_MlInterval/2
g_SendTick := g_OyaUpTick + g_MlTimeout
g_KeyInPtn = LMl
}
}
}
else if g_KeyInPtn in M, RMr,LMl
{
; 何もしない
}
}
return
;Space::
gSpace:
kName = Space
MojiCode = 0
Goto, keydown
;Space up::
gSpaceUp:
kName = Space
MojiCode = 0
Goto, keyup
minimum(val0, val1) {
if val0 > %val1%
{
return val1
}
else
{
return val0
}
}
;----------------------------------------------------------------------
; 通常のキーダウン時にSendする引数の文字列を設定する
; 引数 :aStr:対応するキー入力
; 戻り値:Sendの引数
;----------------------------------------------------------------------
MnDown(aStr) {
vOut =
if aStr<>
vOut = {Blind}{%aStr% down}
return vOut
}
;----------------------------------------------------------------------
; 通常のキーアップ時にSendする引数の文字列を設定する
; 引数 :aStr:対応するキー入力
; 戻り値:Sendの引数
;----------------------------------------------------------------------
MnUp(aStr) {
vOut =
if aStr<>
vOut = {Blind}{%aStr% up}
return vOut
}
;--------------------------------------------------------------------y-
; キー出力
;----------------------------------------------------------------------
SubSend(vOut)
{
global aLog,idxLogs, aLogCnt, g_KeyInPtn
if vOut<>
{
SetKeyDelay -1
Send %vOut%
RegLogs(" " . substr(g_KeyInPtn . " ",1,3) . vOut)
}
return
}
;--------------------------------------------------------------------y-
; ログ保存
;----------------------------------------------------------------------
RegLogs(thisLog)
{
global aLog,idxLogs, aLogCnt
static tickLast
tickCount := Pf_Count() ;A_TickCount
;SetFormat Integer,D
_timeSinceLastLog := tickCount - tickLast
_tmp := SubStr(" ",1,6-StrLen(_timeSinceLastLog)) . _timeSinceLastLog
aLog%idxLogs% := _tmp . " " . thisLog
idxLogs := idxLogs + 1
idxLogs := idxLogs & 63
if(aLogCnt < 64)
{
aLogCnt := aLogCnt + 1
} else {
aLogCnt := 64
}
tickLast := tickCount
}
;----------------------------------------------------------------------
; 保留キーの出力:セットされた文字のセットされた親指の出力
;----------------------------------------------------------------------
SendOnHoldMO:
vOut := kdn%g_RomajiOnHold%%g_OyaOnHold%%g_KoyubiOnHold%%g_MojiOnHold%
kup_save%g_MojiOnHold% := kup%g_RomajiOnHold%%g_OyaOnHold%%g_KoyubiOnHold%%g_MojiOnHold%
if g_ZeroDelay = 1
{
if vOut <> %g_ZeroDelayOut%
{
_save := g_KeyInPtn
vOut1 := "{Blind}{Backspace down}{Backspace up}"
SubSend(vOut1)
SubSend(vOut)
}
g_ZeroDelayOut =
} else {
SubSend(vOut)
}
g_MojiOnHold =
g_OyaOnHold = N
g_KoyubiOnHold = N
g_SendTick =
g_KeyInPtn =
return
;----------------------------------------------------------------------
; 保留キーの出力:セットされた文字の出力
;----------------------------------------------------------------------
SendOnHoldM:
vOut := kdn%g_RomajiOnHold%N%g_KoyubiOnHold%%g_MojiOnHold%
kup_save%g_MojiOnHold% := kup%g_RomajiOnHold%N%g_KoyubiOnHold%%g_MojiOnHold%
if g_ZeroDelay = 1
{
if vOut <> %g_ZeroDelayOut%
{
_save := g_KeyInPtn
vOut1 := "{Blind}{Backspace down}{Backspace up}"
SubSend(vOut1)
SubSend(vOut)
}
g_ZeroDelayOut =
} else {
SubSend(vOut)
}
g_MojiOnHold =
g_KoyubiOnHold = N
g_SendTick =
if g_KeyInPtn in MR
{
g_keyInPtn = R
}
else if g_KeyInPtn in ML
{
g_keyInPtn = L
}
else if g_KeyInPtn in M
{
g_keyInPtn =
}
return
;----------------------------------------------------------------------
; 保留された親指キーの出力
;----------------------------------------------------------------------
SendOnHoldO:
if g_OyaOnHold = R
{
if g_KeySingle = 有効
{
vOut = {Blind}{%kOyaR%}{Blind}{%kOyaR% up}
SubSend(vOut)
}
if g_KeyInPtn in RM,RMr
{
g_keyInPtn = M
}
else if g_KeyInPtn in R
{
g_keyInPtn =
}
}
else if g_OyaOnHold = L
{
if g_KeySingle = 有効
{
vOut = {Blind}{%kOyaL%}{Blind}{%kOyaL% up}
SubSend(vOut)
}
if g_KeyInPtn in LM,LMl
{
g_keyInPtn = M
}
else if g_KeyInPtn in L
{
g_keyInPtn =
}
}
g_OyaOnHold = N
return
;----------------------------------------------------------------------
; キー押下
;----------------------------------------------------------------------
keydown:
Critical
RegLogs(kName . " down")
gosub,Interrupt10
if g_MojiOnHold<>
{
if g_KeyInPtn in M
{
Gosub, SendOnHoldM
}
else if g_KeyInPtn in ML,MR
{
; 処理A 3キー判定
if g_KeyInPtn in MR
{
g_OMInterval := g_MojiTick - g_OyaRTick
g_MOInterval := g_MRInterval
}
else if g_KeyInPtn in ML
{
g_OMInterval := g_MojiTick - g_OyaLTick
g_MOInterval := g_MLInterval
}
if g_OMInterval <= %g_MOInterval% ; 文字キーaから親指キーsまでの時間は、親指キーsから文字キーbまでの時間よりも長い
{
Gosub, SendOnHoldM ; 保留キーの単独打鍵
} else {
Gosub, SendOnHoldMO ; 保留キーの同時打鍵
}
}
else if g_KeyInPtn in RM,LM
{
Gosub, SendOnHoldMO
}
else if g_KeyInPtn in RMr,LMl
{
Gosub, SendOnHoldO
Gosub, SendOnHoldM
}
}
if(MojiCode = 0) ; 文字キー以外(space,tab,Enter)
{
g_ModifierTick := Pf_Count() ;A_TickCount
vOut := MnDown(kName)
SubSend(vOut)
g_KeyInPtn =
return
}
g_MojiTick := Pf_Count() ;A_TickCount
SetKeyDelay -1
if(g_Modifier != 0) ; 修飾キー
{
vOut := mdnANN%MojiCode%
SubSend(vOut)
g_MojiOnHold =
g_OyaOnHold = N
g_KoyubiOnHold = N
g_SendTick =
g_KeyInPtn =
return
}
Gosub,ChkIME
if g_Oya = N
{
; 当該キーを単独打鍵として保留
g_MojiOnHold := MojiCode
g_RomajiOnHold := g_Romaji
g_OyaOnHold := g_Oya
g_KoyubiOnHold := g_Koyubi
g_SendTick := g_MojiTick + g_Threshold
g_KeyInPtn = M
}
else
{
if g_Oya = R
{
g_OMInterval := g_MojiTick - g_OyaRTick
}
else if g_Oya = L
{
g_OMInterval := g_MojiTick - g_OyaLTick
}
g_MojiOnHold := MojiCode
g_RomajiOnHold := g_Romaji
g_OyaOnHold := g_Oya
g_KoyubiOnHold := g_Koyubi
if g_Continue = 0 ; 連続モードではない
{
g_SendTick := g_MojiTick + g_OMInterval
g_KeyInPtn := g_Oya . "M"
g_Oya = N ; 親指シフトが押されていない状態に遷移
} else {
g_SendTick := g_MojiTick + g_Threshold
g_KeyInPtn := g_Oya . "M"
}
}
if g_MojiOnHold<> ; 当該キーの保留
{
; 左右親指シフト面と非シフト面の文字キーが同一ならば、保留しない
_cn := key%g_RomajiOnHold%N%g_KoyubiOnHold%%g_MojiOnHold%
_cr := key%g_RomajiOnHold%R%g_KoyubiOnHold%%g_MojiOnHold%
if _cn = %_cr%
{
_cl := key%g_RomajiOnHold%L%g_KoyubiOnHold%%g_MojiOnHold%
if _cn = %_cl%
{
vOut := kdn%g_RomajiOnHold%%g_OyaOnHold%%g_KoyubiOnHold%%g_MojiOnHold%
SubSend(vOut)
g_MojiOnHold =
g_OyaOnHold = N
g_KoyubiOnHold = N
g_SendTick =
g_KeyInPtn =
}
}
}
if g_MojiOnHold<> ; 保留キー有り
{
if g_ZeroDelay = 1
{
; 保留キーがあれば先行出力(零遅延モード)
vOut := kdn%g_RomajiOnHold%%g_OyaOnHold%%g_KoyubiOnHold%%g_MojiOnHold%
kup_save%g_MojiOnHold% := kup%g_RomajiOnHold%%g_OyaOnHold%%g_KoyubiOnHold%%g_MojiOnHold%
g_ZeroDelayOut := vOut
SubSend(vOut)
}
else
{
g_ZeroDelayOut =
}
}
return
;----------------------------------------------------------------------
; キーアップ(押下終了)
;----------------------------------------------------------------------
keyup:
Critical
RegLogs(kName . " up")
gosub,Interrupt10
g_MojiUpTick := Pf_Count() ;A_TickCount
if MojiCode = %g_MojiOnHold% ; 保留キーがアップされた
{
if g_KeyInPtn in M ; Mオン状態
{
Gosub, SendOnHoldM
}
if g_KeyInPtn in MR,ML ; M-Oオン状態
{
; 処理C
g_MmInterval := g_MojiUpTick - g_MojiTick
if g_KeyInPtn in MR
{
g_OmInterval := g_MojiUpTick - g_OyaRTick
} else {
g_OmInterval := g_MojiUpTick - g_OyaLTick
}
vOverlap := 100*g_OmInterval/g_MmInterval
if vOverlap <= %g_Overlap%
{
if g_OmInterval < %g_Tau%
{
Gosub, SendOnHoldM
} else {
Gosub, SendOnHoldMO
}
} else {
Gosub, SendOnHoldMO
}
}
if g_KeyInPtn in RM,LM ; O-Mオン状態
{
if g_Continue = 0 ; 連続モードではない
{
; 処理E
g_MmInterval := g_MojiUpTick - g_MojiTick
if g_KeyInPtn in RM
{
g_OmInterval := g_MojiUpTick - g_OyaRTick
} else {
g_OmInterval := g_MojiUpTick - g_OyaLTick
}
vOverlap := 100*(g_MmInterval)/g_OmInterval
if vOverlap <= %g_Overlap%
{
if g_MmInterval <= %g_Tau%
{
Gosub, SendOnHoldO
Gosub, SendOnHoldM
} else {
Gosub, SendOnHoldMO
}
} else {
Gosub, SendOnHoldMO
}
} else {
Gosub, SendOnHoldMO
}
}
else if g_KeyInPtn in RMr,LMl ;O-M-Oオフ状態
{
Gosub, SendOnHoldMO
}
}
if(MojiCode = 0) ; 文字キー以外(Space,Tab,Insert,...)
{
vOut := MnUp(kName)
SubSend(vOut)
return
}
if(g_Modifier != 0) ; 修飾キー
{
vOut := mupANN%MojiCode%
SubSend(vOut)
g_MojiOnHold =
g_OyaOnHold = N
g_KoyubiOnHold = N
g_SendTick =
return
}
vOut := kup_save%MojiCode%
SubSend(vOut)
kup_save%MojiCode% =
return
;----------------------------------------------------------------------
; 10[mSEC]ごとの割込処理
;----------------------------------------------------------------------
Interrupt10:
if g_SendTick <>
{
_TickCount := Pf_Count() ;A_TickCount
if _TickCount >%g_SendTick% ; タイムアウト
{
if g_KeyInPtn in M ; Mオン状態
{
Gosub, SendOnHoldM
}
else if g_KeyInPtn in L,R ; Oオン状態
{
if g_Continue = 0 ; 連続モードてはない
{
Gosub, SendOnHoldO
}
}
else if g_KeyInPtn in ML,MR,RM,LM ; M-Oオン状態、O-Mオン状態
{
Gosub, SendOnHoldMO ; 保留キーの同時打鍵
}
else if g_KeyInPtn in RMr,LMl ; O-M-Oオフ状態
{
if g_Continue = 0 ; 連続モードてはない
{
Gosub, SendOnHoldO ; 保留親指キーの単独打鍵
}
Gosub, SendOnHoldM ; 保留文字キーの単独打鍵
}
}
}
g_Koyubi := ShiftState()
stWin := ModifierState(4,stWin, 91, 92)
stCtrl := ModifierState(8,stCtrl, 162, 163)
stAlt := ModifierState(16,stAlt, 164, 165)
stApp := ModifierState(32,stApp, 93, 93)
return
;-----------------------------------------------------------------------
; モディファイアキーの状態取得
;-----------------------------------------------------------------------
ModifierState(bMod, stLast, vkey0, vkey1) {
global g_Modifier
global g_MojiOnHold, g_RomajiOnHold, g_OyaOnHold
global g_KoyubiOnHold, g_SendTick, g_KeyInPtn
stCurr := DllCall("GetKeyState", "UInt", vkey0) & 128
stCurr :=(DllCall("GetKeyState", "UInt", vkey1) & 128) | stCurr
if(stCurr = 128 && stLast = 0) ; keydown
{