-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMAIN.ahk
1916 lines (1540 loc) · 57.4 KB
/
MAIN.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
#SingleInstance
A_HotkeyInterval := 2000 ; This is the default value (milliseconds).
A_MaxHotkeysPerInterval := 200
SetCapsLockState("AlwaysOff")
; SetWorkingDir(A_ScriptDir)
CoordMode("Mouse", "Screen")
; init_pixel_find()
ScriptStartModTime := FileGetTime( A_ScriptFullPath)
SetTimer(CheckScriptUpdate,100,0x7FFFFFFF) ; 100 ms, highest priority
SetTimer(WatchCursor,100) ;这个设置了获取鼠标信息的频率,数值越小边缘热区越灵敏
InstallKeybdHook
InstallMouseHook
; 函数最好直接放在第一个本体,后面的细节再慢慢添加。
; 多个文件看得清楚,功能相当于复制到这里。 vscode 装了 ahkv2-lsp 插件以后,在文件名上点击 F12 可以直接跳转过去。
#Include "%A_ScriptDir%\Modifiers.ahk"
#Include "%A_ScriptDir%\Basic_Remap.ahk"
#Include "%A_ScriptDir%\HotStrings.ahk"
#Include "%A_ScriptDir%\Mouse.ahk"
; vscode 拆分两列用菜单进行选择就行了: alt+v; 编辑器布局 L ;双列 T; 而传统软件 Obsidian 需要 alt + shift + ijkl 切换, n/m 新建分列。
; 切换直接用 ctrl +1/2 就能切换
; C:\Users\c1560\scoop\apps\autohotkey\1.1.33.09\v2.0-beta.7
A_TrayMenu.Add() ; 创建分隔线.
A_TrayMenu.Add("虚拟桌面1 Ctrl+Win+←→", MenuHandler1) ; 创建新菜单项.
A_TrayMenu.Add("虚拟桌面2", MenuHandler2)
A_TrayMenu.Add("虚拟桌面3", MenuHandler3)
A_TrayMenu.Add("Pomodoro Timer", MenuHandler4)
A_TrayMenu.Add("End Pomodoro", MenuHandler5)
I_Icon := A_ScriptDir . "\open-book.png"
if FileExist(I_Icon)
TraySetIcon(I_Icon)
cn(mode := "两次切换Ctrl+Shift", smart_half:=0){
switch mode{
; 通过两次 ctrl+shift 切换,利用中文输入法的默认状态变成中文。(假设平时只使用 shift,并且默认状态是 chn)
case "两次切换Ctrl+Shift":
Func_flip_IME_state("^+")
Sleep 30
Func_flip_IME_state("^+")
;1 2 两种中文输入法
case "set win hotkey": Send("!+{2}")
case "强制通过 postmessage 切换输入法": PostMessage 0x0050, 0, 0x8040804,, "A"
; 0x4040404 是繁体中文!,简体中文的编号是什么 0x8040804
;下面切换的方法都不太靠谱
case "TrackingByMyself": Function_Set_Language_by_tracking(2)
case "flip_toogle": Func_flip_IME_state()
case "讯飞输入法的特殊逻辑Ctrl+. space": Send("^.^{Space 2}") ; 利用 全角半角切换一定是中文内这个特性进行切换。
case "讯飞输入法的特殊逻辑Ctrl+. shift": Send("^.{Shift 2}") ; 利用 全角半角切换一定是中文内这个特性进行切换。
}
clear_mouse_flag_altered()
if( smart_half == 1)
Other_things_when_toggling_IME() ; vscode 之中使用半角中文.
}
; 只是 set language 的快捷入口,不要做派发!
en(mode := "两次切换Ctrl+Shift"){
switch mode{
; 通过两次 ctrl+shift 切换,利用中文输入法的默认状态变成中文。(假设平时只使用 shift,并且默认状态是 chn)
case "两次切换Ctrl+Shift":
Func_flip_IME_state("^+")
Sleep 30
Func_flip_IME_state("^+")
Func_flip_IME_state("Shift")
case "set win hotkey": Send("!+{3}") ; win11 快捷键丢失的 bug 更严重了,甚至不是重启后丢失?? 设置丢失只是看不见,但还能用
case "强制通过 postmessage 切换输入法": PostMessage 0x0050, 0, 0x4090409,, "A" ; 0x0050 is WM_INPUTLANGCHANGEREQUEST.
;下面切换的方法都不太靠谱
case "TrackingByMyself": Function_Set_Language_by_tracking(1)
case "flip_toogle": Func_flip_IME_state()
case "讯飞输入法的特殊逻辑Ctrl+. space": Send("^.^{Space 1}") ; 利用 全角半角切换一定是中文内这个特性进行切换。
case "讯飞输入法的特殊逻辑Ctrl+. shift": Send("^.{Shift 1}") ; 利用 全角半角切换一定是中文内这个特性进行切换。
}
clear_mouse_flag_altered()
Sleep(100)
; Other_things_when_toggling_IME()
}
; switch IME
Func_flip_IME_state(mode:="Shift"){
switch mode
{
case "Shift": Send("{Shift down}{Shift Up}")
case "ctrl+space": Send("^{Space}")
case "tilde": Send("{sc029}") ; ctrl+shift , alt+shift, grave 这三个是一组
case "^": Send("{Ctrl Down}{Ctrl Up}") ; ctrl,ctrl+space,shift 这三个是一组
case "shift": Send("{Shift Down}{Shift up}")
case "^+" : Send("{Ctrl Down}{Shift Down}{Shift up}{Ctrl Up}") ; 正常是 ctrl + shift,但其实你可以先按shift再按control,这样就没有操作界面了。 没有 GUI 界面反应会快一点。 ; 或者说。使用 alt 加shift切换语言。 shift + ctrl works in onenote, meanwhile ctrl + shift won't work. I guess it's OSD lagging the windows.
case "^space": Send("^{Space}")
}
; ToolTip("wait to release")
; KeyWait("Shift")
; KeyWait("Alt")
; KeyWait("Ctrl")
ToolTip()
}
!+8::cn("set win hotkey")
!+9::en("set win hotkey")
; Obsidian 切换搜索时候进入中文(必须要清楚或者等待之前的快捷键松开。
~^p::TagAlongEN()
~^!l::TagAlongCN()
TagAlongCN()
{
KeyWait "ctrl"
KeyWait "alt"
KeyWait "shift"
cn()
}
TagAlongEN()
{
KeyWait "ctrl"
KeyWait "alt"
KeyWait "shift"
en()
}
checkCurrentKeyboardLayout() {
ThreadId := DllCall("User32.dll\GetWindowThreadProcessId", "Ptr", WinExist("A"), "Ptr", 0, "UInt")
hCurrentKBLayout := DllCall("User32.dll\GetKeyboardLayout", "UInt", ThreadId, "Ptr")
msgbox(hCurrentKBLayout)
return
}
MenuHandler1(ItemName, ItemPos, MyMenu) {
Send("^#{left}")
Send("^#{left}")
}
MenuHandler2(ItemName, ItemPos, MyMenu) {
Send("^#{left}")
Send("^#{Right}")
}
MenuHandler3(ItemName, ItemPos, MyMenu) {
Send("^#{Right}")
Send("^#{Right}")
}
; 主要功能
; 输入αωκλ 希腊字符、上下标、特殊符号。 ; The hotstring and and formula typing Greek letters example is in the readme on the website. (superscripts and undersccripts)
; keywait 等待然后一起返回 更方便一个快捷键重复使用多次。 第二个参数,字符串以逗号隔开,自行确保很选相对应。
; 不等待模式: immediateMode 从 1 到 n
updateSharedRepeat( NeedToBeDisplay := "", immediateMode_length := 0){
global repeatTime
if( A_PriorHotkey != A_ThisHotKey or A_TimeSincePriorHotKey > 1000)
repeatTime := 0 ;list 从0 到 maxindex()
if( immediateMode_length > 0){
len := immediateMode_length
if( A_PriorHotkey == A_ThisHotKey )
repeatTime += 1 ;immediateMode_length 从 1 到 inf 手动归零。
if (repeatTime >= len)
repeatTime -= len ;归零。
return repeatTime
}
ToolTip( repeatTime ,,999,8 )
result_key := Trim(A_ThisHotKey, "$")
result_key := Trim(result_key, "~")
result_key := Trim(result_key, "#")
result_key := Trim(result_key, "!")
; 如果还有别的修饰键就不行了。
Array := StrSplit(result_key , " ", ">$~+^< &", 3) ; a & b 会返回三个值,两个空格之间的符号也算上了,手动跳过。
first_key := Array[1]
latter_key := Array[Array.Length]
options := StrSplit(NeedToBeDisplay , ",") ;",," 不能同时有两个 delimiter
len := options.length
flag := 1
while (flag ){
display := ""
if (repeatTime >= len)
repeatTime -= len
if (NeedToBeDisplay =="")
display := "repeatTime= " repeatTime "latter_key " latter_key
else{
For Index, Value in options{
; Send(Value)
if( Index == repeatTime + 1)
display .= repeatTime . " "
else
display .= " "
display .= Value "`n"
}
}
ToolTip(display,,999,8 )
KeyWait(latter_key) ;等待松开然后再按下
flag1 := KeyWait(latter_key , "T.75D") ; 超时返回 0 这里不能用 A_ThisHotkey,这里还在等待,但下一个 key 已经把全局变量替换掉了。
flag2 := GetKeyState(first_key,"p") ; 松开时 = 0
flag := flag1
if( flag == 1){
repeatTime += 1
}
sleep(50)
}
SetTimer () => ToolTip(,,,8), -1750
SoundBeep()
return repeatTime
}
Other_things_when_toggling_IME(){
name := WinGetProcessName("A")
; Sleep(1000)
; tooltip, %name%
; ;----------------------------------------------
; 希望默认英文的环境 Code.exe ← VSCODE, Obsidian.exe OneCommander.exe
if( name == "Code.exe" or name == "OneCommander.exe")
{
; Send("^.") ;bug!? ctrl + 句号 在讯飞输入法竟然能从英文切换到中文!!
Send("^{sc034}") ;还是存在?!?! 原来是因为shift 还没有松手……
}
; msedge.exe WeChat.exe 。但是 onenote 和 系统设置区分不开、的 ahk——exe 都是这个 ApplicationFrameHost.exe ,区分不开
else if( name == "msedge.exe" or name == "Obsidian.exe" or name == "ApplicationFrameHost.exe" or name == "WeChat.exe" )
{
;not change
}
;soundbeep,1000,100
; send,{ctrl up}{shift up}{alt up}
; Func_Heads_up_using_scrollLock(num)
; Func_Mouse_Indicator(num)
; func_head_up_sound_ime() 不切换
}
Function_Set_Language_by_tracking(target_state) {
global Current_IME_State
return_IME_state_from_pixel()
if ( target_state != Current_IME_State or true) ; 加一点“智能”,只有想要切换的语言和当前语言不同的时候,才切换语言。 9 ≠ 1 and 9 ≠ 2 ,
{
Current_IME_State := 3 - Current_IME_State ;" jump between 1,2"
Func_flip_IME_state()
}
}
; 根据周围字符判断语言环境,有点影响使用,需要复制文本,最终放弃
; 测试: IsAlpha("按", "Locale") IsAlpha("ddddddd", "Locale") IsAlpha(" ", "Locale") IsAlpha("111", "Locale")
; 四个结果是 1 1 0 0, 也就是说不分中文英文,是文字返回1,数组、空格返回0.
; ~LButton::
; {
; global MpositionX, MpositionY
; global LastX, LastY
; global flag_idle_space
; LastX := MpositionX
; LastY := MpositionY
; global moveFar
; global threshold_idle
; MouseGetPos(&MpositionX, &MpositionY, &id, &control)
; ; ToolTip( MpositionX MpositionY )
; ; guess := GetAcharactor_and_return_language_clipboard()
; ; ToolTip(guess)
; if ( Abs(MpositionY - LastY) > 500 or Abs(MpositionX - LastX) > 500 ){
; moveFar := 1
; ; threshold_idle := 别耦合了,想不出来,直接做一个 keywait 等待就完事了。
; }
; else
; moveFar := 0
; if (A_Cursor = "IBeam" and moveFar == 1) ;Unknown ; cursor is on link
; {
; en()
; ; change_this_program_perfer() ;根据程序名称判断。
; }
; ; SetTimer(RemoveToolTip,-1000) ; ; guess := GetAcharactor_and_return_language_clipboard() ; 直接根据 ascii 码判断。有点影响使用。放弃
; ; ToolTip(guess)
; }
if_temp_toggle_IME_is_ture_then_change_it_back()
{
global temporal_change_IME
if( temporal_change_IME == 1)
{
en()
temporal_change_IME := 0
}
}
global XwhereMwas := 0
global YwhereMwas := 0
global M_altered_wait_click:=0
global Ts:= A_TickCount
global height_PDF := 1300
global threshold_idle:= 6000
global Current_IME_State :=1
global TimeIdleKeyboardArray:= []
global flag_mouse_wheel_change:=0
global W := A_ScreenWidth - 1 ; 1920 如果屏幕是竖过来的,这个值 AHK 会帮你改变。(但是第一段只执行一次,可能需要重载。)
global H := A_ScreenHeight - 1 ; 1080
global index_Time := 0
global maxValue_Time := 10
global repeatTime := 0
global using_shift_to_help_typing_in_Chinese:=1
global n_mouse_move_momentum:=0
global StartTime:= 0
global idle_time_number:=0
global Stop_Sitting_counter:=0
global Stop_Sitting_Lastime_triggered:= A_TickCount
global Press_Start_time
global now_language :=0
global repeat_key:=0
global exclude_apps_string := []
global MpositionX :=0
global MpositionY :=0
WatchCursor()
{
global Current_IME_State
global flag_mouse_wheel_change
global TimeIdleKeyboardArray
global index_Time
global maxValue_Time
global threshold_idle
global flag_idle_space
global moveFar
global M_altered_wait_click
global XwhereMwas
global YwhereMwas
MouseGetPos(&xpos, &ypos, &id, &control)
W := A_ScreenWidth
; ToolTip(A_TimeIdlePhysical)
global XwhereMwas := xpos
global YwhereMwas := ypos
;------------------------ Pomodoro --------------
; AutoMaticPomodoro()
; ;------------------------移动距离足够大以后,改变键盘的逻辑---------------
; if( Abs( XwhereMwas - xpos) + Abs(YwhereMwas - ypos) > 100 and (A_TimeIdleKeyboard >200))
; {
; M_altered_wait_click := 1
; CoordMode("ToolTip" , "Screen")
; ToolTip(" " ,0 , 9200,9 )
; ; SetTimer ()=> ToolTip(,0,9999,9 ) ,-1000
; ; if_temp_toggle_IME_is_ture_then_change_it_back()
; }
; ;------------------------移动距离足够大以后,改变键盘的逻辑---------------
; if( Abs( XwhereMwas - xpos) > 700 and !GetKeyState("LButton")) ;相对移动甚至不需要区分副屏幕。
; {
; }
; ----------------------- 闲置足够长时间就清除 modifer---------------------
; t := Mod(A_TimeIdleKeyboard, threshold_idle) ; 鼠标切换的话 keyboard idle 时间不更新. ; 取余是最简单的,不用记录之前是哪个程序,和现在比较. 取余一定要用 后面的 100 ms,而不是开始的 100 ms,不然总是重置 IME.
; if( t > 300 ){
; ; change_this_program_perfer()
; global modifier
; modifier := ""
; ; showIMEstateRIME()
; }
; if( A_TimeIdleKeyboard > 1600 )
; {
; M_altered_wait_click := 0
; ToolTip( ,0 , ypos+ 200,9 )
; }
; if( t > threshold_idle - 100 ){ 时间过长修改输入就太影响输入思路了,鼠标、换程序时修改最好。
; en()
; }
; if( A_TimeIdleKeyboard > threshold_idle - 100 ){
; flag_idle_space := 1
; }
; else {
; flag_idle_space := 0
; }
; ----------------------- 闲置足够长时间就清除 modifer-------------------
; ToolTip(A_ScreenHeight ypos xpo )
if( GetKeyState("Ctrl","P"))
if( (xpos = 0 )) ;and ypos = A_ScreenHeight -1 往左拖动(同时按住 ctrl)触发删除,这样鼠标可以直接拖动文字复制、移动、删除。
{
Send("{LButton Up}")
Send("{BackSpace}")
Sleep(2000)
}
; 大部分程序都不会汇报 caret 的位置,所以不可能知道键盘输入点在哪。 追踪鼠标更加合理。
; ToolTip, X%A_CaretX% Y%A_CaretY%, A_CaretX, A_CaretY - 20
; 但是数组从 0 开始。对于 1920*1080 的电脑来说, 左上角 0,0 ;右上角 1919,0 ;左下角 0,1079; 右下角1919 1079。
;若要重设边缘热区的范围请,把下一行的 ; 号去掉,就会在鼠标位置显示鼠标的坐标,根据坐标修改以下数值
; ToolTip,x:%xpos% y:%ypos% :%% `t Hei = %Hei% Wei =%Wei%
; -----------------------
; tooltip, %A_ScreenWidth%
; 根据鼠标在 screen 的位置修改鼠标滚轮的功能。 ; 副屏幕坐标是负的,整个屏幕的基准不是 0;副屏幕左上角是 -1440,661
; if(GetKeyState("LButton")){ ;没有按下鼠标才触发。
if(GetKeyState("``")){ ;没有__`__才触发。 但是这个规则没有用?和上条不一样?
; if(GetKeyState("SC029")){ ;没有__`__才触发。 但是这个规则没有用?和上条不一样?
return
}
; 滚轮控制音量 else if ↓↓↓ ypos < H * 0.25 or
if( xpos = 0 and ( ypos > H * 0.75 ) or ( xpos = -1440 and ypos < 900)){ ;屏幕左上角, 左下角,副屏幕。
flag_mouse_wheel_change :=3
ToolTip("滚轮控制音量" xpos , A_ScreenWidth,,15)
ToolTip()
}
; 左上角 ;切换上一个任务 alt+Tab
; else if(xpos = 0 and ypos = 0){
; Sleep( 1000)
; ;if still here
; MouseGetPos(&xpos, &ypos, &id, &control)
; if(xpos < 50 and ypos < 50){
; Send("!{Tab}")
; Sleep( 1000)
; }
; }
; ; 右上角 F11 或者切换任务 已经设置了『全面屏手势』,就不用这个了。
; else if(xpos + 1 = A_ScreenWidth and ypos = 0){
; Sleep( 1000)
; ;if still here
; MouseGetPos(&xpos, &ypos, &id, &control)
; if( Abs( A_ScreenWidth - xpos) < 50 and ypos < 50){
; Send("#{Tab}") ;切换任务 任务管理器
; ; Send("{F11}")
; Sleep( 1000)
; }
; }
; ;屏幕右边直接控制翻页 条件较小的一定要放右边!!
else if( xpos = A_ScreenWidth - 1 ){
flag_mouse_wheel_change := 4
ToolTip("PG", A_ScreenWidth,,15)
}
else { ;重置状态 ,必须要
if( flag_mouse_wheel_change != 0){
flag_mouse_wheel_change :=0
ToolTip(,,,15)
}
}
; ----------------------------------放弃---------------------------------
; 浏览器标签,上方,快速切换。 稍微往下,第二行,第三行,屏幕左侧 75% 调音量,右侧控制翻页,功能都有。
; if ( (xpos > 250 and xpos < W-250 )) {
; ; 屏幕中央,去除两侧,避免 bug
; if ( ypos < 50 ){
; flag_mouse_wheel_change :=1
; ToolTip("屏幕左上方 1 滚轮控制翻页 `n 右键打开 ↑任务菜单全部任务↑ " ,A_ScreenHeight,,15)
; }
; else if( ypos > 50 and ypos < 100){
; flag_mouse_wheel_change :=2
; ToolTip("屏幕左上方 2 滚轮控制22 左右", A_ScreenWidth,,15)
; }
; else if( ypos > 100 and ypos < 150){
; flag_mouse_wheel_change := 4
; ToolTip("屏幕左上方 3 滚轮控制上下", A_ScreenWidth,,15)
; }
; else if( flag_mouse_wheel_change != 0){
; flag_mouse_wheel_change :=0
; ToolTip(,,,15)
; }
; }
;
; else if(xpos <-50 and ypos = 603) {
; flag_mouse_wheel_change :=1
; ToolTip("屏幕左上方 1 滚轮控制翻页 `n 右键打开 ↑任务菜单全部任务↑ ", A_ScreenWidth,,15)
; }
; mousinc 这个鼠标手势软件有很多功能,https://zhuanlan.zhihu.com/p/400590907 绿色,
; 手写识别,carnac 按键回显,边缘滚动,有意思的音响效果,甚至 altsnap 移动窗口(只不过是 alt + 鼠标滚轮,而我这个鼠标没有滚轮。)、 ditto 的画中画都有!
; ----------------------------------放弃---------------------------------
;---------------------------------------------------------
; else if(xpos = 0 and ypos = H){
; tooltip, 屏幕左下角 如果还在这里 still here `n 那么触发。。。左下角 0 1079 W L
; Sleep, 1000
; MouseGetPos, xpos, ypos, id, control
; if(xpos < 50 and ypos > H -50){
; ;WinMinimizeAll
; Sleep, 1500
; ;WinMinimizeAllUndo
; }
;
; if( flag_mouse_wheel_change != 0)
; flag_mouse_wheel_change :=0
;
; }
}
AutoMaticPomodoro()
{
if( A_TimeIdlePhysical < 60000 ) ;1 minutes = 60*1000 ms 函数里面自动过滤掉太远的输入,只需要进入的时候过滤一下。
{
My_automatic_Pomodoro_Stop_Sitting_function_couting_up()
}
else if( A_TimeIdlePhysical > 300000)
{
Pomodoro_Kill() ; 太长的空闲,重置计数器。
global Stop_Sitting_block_once
Stop_Sitting_block_once := 1
ToolTip("Clear",0,0)
}
}
; ~Tab::
; ~LButton::showIMEstateRIME() 陈饭FDSFshUIFFDSFhsDhui
; LCtrl::
; ; ~Shift::
; LAlt::
; {
; if_temp_toggle_IME_is_ture_then_change_it_back()
; global temporal_change_IME
; temporal_change_IME :=0
; ; showIMEstateRIME(1000)
; Send("{A_ThisHotkey}")
; }
; RIME 和手心输入法切换的时候屏幕上有提示,非常方便。我只需要触发它就行了。
showIMEstateRIME(time := 100)
{
Sleep(time)
Send("{LShift 2}")
}
;0 is normal ; 位置修改功能
WheelUp::
{
global flag_mouse_wheel_change
switch flag_mouse_wheel_change
{
case 1: Send("+{tab}")
case 2: Send("{Left}")
case 3: Send("{Volume_Up}")
case 4: Send("{PgUp}")
default: Send("{WheelUp}")
}
}
WheelDown::
{
global flag_mouse_wheel_change
switch flag_mouse_wheel_change
{
case 1: Send("^{tab}")
case 2: Send("{Right}")
case 3: Send("{Volume_Down 3}")
case 4: Send("{PgDn}")
default: Send("{WheelDown}")
}
}
#HotIf flag_mouse_wheel_change=4
; 全面屏手势,鼠标在屏幕右侧时,唤出任务菜单。(按住显示,松手选择)
RButton::
{
Send("#{Tab}")
KeyWait("RButton")
Click()
}
#HotIf
delete_a_word(){
Send("^{backspace}")
}
adds_two_space_before_and_after(){
Send("^{left}")
Send("{space}")
Send("^{right}")
Send("{space}")
}
func_delete_traling_newline_and_enter(){
Send("{end}{delete}{space}{down}{end}")
}
;注意空格就可以连接字符串!
showtip( string,t:=500){
ToolTip(string)
SetTimer () => ToolTip( ), -300000
; SetTimer(RemoveToolTip,-%t%)
}
delete_one_line(){
Send("{Home}{Shift down}{End}{Shift up}")
Sleep(10)
Send("{BackSpace}") ;删除一行,而不是删除所有文字,功能挺顺手的。
return
}
delete_from_here_to_end_of_the_line(){
Send("{Shift down}{End}{Shift up}")
Sleep(10)
Send("{BackSpace}") ;删除一行,而不是删除所有文字,功能挺顺手的。
return
}
; Delete & a::delete_a_word()
; Delete::Send("{Delete}")
;wordpress 文字修改,这个是添加软回车,wordpress 需要一整块的文字,
func_wordpress_change_to_soft_enter(){
Send("{End}")
Sleep(50)
Send("{delete}")
Sleep(50)
Send("{Shift down}{Enter}{Shift up}{End}")
return
}
func_superscript_text(){
Send("{Shift down}{Left}{Shift up}")
Send("{Ctrl down}{Shift down}{=}{Shift up}{Ctrl up}")
Send("{Left}")
return
}
func_underscript_text(){
Send("{Shift down}{Left}{Shift up}")
Send("{Ctrl down}{=}{Ctrl up}")
Send("{Left}")
return
}
; ~ki
~k::
{
; check_io_pressed_in_the_same_time()
; if( GetKeyState("j") and GetKeyState("i") and GetKeyState("o")dededeededeeedede
if( GetKeyState("i")){
Send("{bs 2}")
Sleep(200)
cn()
}
}
; ~ed
~d::
{
; check_ew_pressed_in_the_same_time()
if( GetKeyState("e") and GetKeyState("d") ){
Send("{bs 2}")
Sleep(200)
en()
}
}
;这个功能需要一个 exe,很小,是封装的微软“讲述人”功能: https://elifulkerson.com/projects/commandline-text-to-speech.php
voice_text_to_speach( lan := "en"){
; BackUpClip := ClipboardAll
Send("^{c}")
; Send("{Media_Play_Pause}")
Sleep(50) ; 必须有,确保 clipboard 数据更新。
; say PowerShell "C:\Users\Administrator\OneDrive\代码\voice.exe /n 'Microsoft David Desktop' 'output'" , ,Hide
; ↑↑
; 若要在单引号字符串中包含单引号,请使用第二个连续单引号。
; 若要使双引号显示在字符串中,请将整个字符串括在单引号中。 详情见 https://docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7.2
textRaw := A_Clipboard
; 里面的单引号会出 bug, 指令里面有单引号,还是 shell 不许参数有引号? 那我直接做一个替换也许就可以了。
textraw := StrReplace(textraw, "'", "''")
textraw := StrReplace(textraw, "’", "''")
textraw := StrReplace(textraw, "‘", "''")
; ToolTip(A_NowUTC "`n" textraw)
switch lan
{
; 用 voice.exe --list 查看可用的语音源。
; PS C:\Users\Administrator\OneDrive\代码\AHK> ./voice.exe --list
; "Microsoft Huihui Desktop" - Adult,Female,zh-CN ;中英都可以念,但是英文有点卡。
; "Microsoft Zira Desktop" - Adult,Female,en-US ; 英文流畅但是完全念不了中文
; "Microsoft David Desktop" - Adult,Male,en-US
case "en": command := A_ScriptDir . "\voice.exe /n 'Microsoft Zira Desktop' '" . textRaw . "'"
case "cn": command := A_ScriptDir . "\voice.exe /n 'Microsoft Huihui Desktop' '" . textRaw . "'"
}
try
ExitCode :=RunWait("PowerShell `" " command "`"", , "Min")
catch
MsgBox(ExitCode)
; MsgBox(ExitCode)
; Send("{Media_Play_Pause}")
; Clipboard := BackUpClip
;test
; such as Tchaikovsky's Symphony No. 6, are not placed in quotes, but if the work also has a title, the title is placed in quotes. (Tchaikovsky's Symphony No. 6, "Pathetique.")
}
CheckScriptUpdate() { ;自动更新功能,来自于例子:https://www.it1352.com/1954002.html
global ScriptStartModTime
curModTime := FileGetTime(A_ScriptFullPath)
If (curModTime != ScriptStartModTime) {
SetTimer(CheckScriptUpdate,0)
Loop
{
reload
Sleep(300) ; ms
msgResult := MsgBox("Reload failed.", A_ScriptName, 2) ; 0x2 = Abort/Retry/Ignore
if (msgResult = "Abort")
ExitApp()
if (msgResult = "Ignore")
break
} ; loops reload on "Retry"
}
}
maximizeORrestore(){
global Title
if( A_PriorHotkey != A_ThisHotKey)
{
Title := WinGetTitle("A")
ToolTip("new window`n" Title)
}
else
ToolTip("old window`n" Title)
; get MinMax state for the given title and save it to variable MX
MX := WinGetMinMax(Title)
; -1: The window is minimized (WinRestore can unminimize it).
; 1: The window is maximized (WinRestore can unmaximize it).
; 0: The window is neither minimized nor maximized.
; if it is maximized, minimize it
if (MX!=1)
WinMaximize(Title)
; if it is minimized, maximize it
else
; WinMaximize, %Title%
WinRestore(Title)
; else
; WinMinimize, A
; Tooltip
return
}
minimizeORrestore(){
if WinExist("ahk_id " lastWindow)
{
WinState := WinGetMinMax("ahk_id " lastWindow)
if (WinState = -1)
WinActivate()
else
WinMinimize()
}
else
{
lastWindow:= WinExist("A")
WinMinimize("ahk_id " lastWindow)
}
return
}
take_notes( program){
; freeze_clipboard()
the_clipboard:= A_Clipboard
Send("^{c}")
Sleep(100)
switch_to_a_program( program )
Sleep(200)
Send("{Enter}")
Send("^{v}")
Sleep(100)
Send("!{Tab}")
A_Clipboard := the_clipboard
}
;这是一个单独的模式,不能输入,某些功能需要管理员权限,来重新实现键盘逻辑。
Func_Heads_up_using_scrollLock(num){
if(num = 1){
SetScrollLockState("Off")
}
else {
SetScrollLockState("On")
}
return
}
; 不允许模拟 ctrl + alt + del,Send,^!{Del}。 但是你可以发送 win+x,t 来唤出任务管理器
; onenote 2016 shortkeys , 新旧 OneNote 都有 bug,放弃了.
Lshift & WheelDown::Send("{WheelRight}")
Lshift & WheelUp::Send("{WheelLeft}")
; pomodoro
F3 & p::
{
repeatTime:= updateSharedRepeat(" pomodoro 开始,关闭时钟 并清空自动时钟")
switch repeatTime
{
case 0: PomodoroStart()
case 1: Pomodoro_Kill()
}
return
}
MenuHandler4(ItemName, ItemPos, MyMenu) {
PomodoroStart()
}
MenuHandler5(ItemName, ItemPos, MyMenu) {
Pomodoro_Kill()
global blockPomodoro:= 1
}
PomodoroStart()
{
global StartTime
StartTime := A_TickCount
SetTimer(pomodoro_tips,1000) ; 每秒更新
; t := "1000*60*25" = 1500000
SetTimer(endPomodoro,-1500200) ;负数是倒计时关闭。 正数是周期提示。 25分钟是 1,500,000 ms
}
Pomodoro_Kill()
{
SetTimer(pomodoro_tips,0) ; 删除 Pomodoro 时钟
global Stop_Sitting_counter ;把另一个自动的重置
Stop_Sitting_counter :=0
}
pomodoro_tips()
{
global StartTime
ElapsedTime := A_TickCount - StartTime
sec := Floor(ElapsedTime/1000)
minute := Floor(sec / 60)
CoordMode("ToolTip" , "Screen")
ToolTip(minute ":" sec, 9990 , 0, 16)
}
endPomodoro()
{
SetTimer(pomodoro_tips,0)
Send("{Media_Play_Pause}") ;pause_play_beep:
SoundBeep(1204, 300)
;write to file
FileObj := FileOpen("Pomodoro.txt", "a")
strings := "🍅 completed Year Week:" . A_YWeek . "day " . A_DD
FileObj.WriteLine(strings)
Send("^#{c}") ; windows color filter
; MsgBox("🍅 end. Rest 5 Min")
SetTimer () => MsgBox(" Back to Work"), -300000
SetTimer () => Send("^#{c}") , -300000
return
}
; zxcv 是几个最好用的快捷键了。我放进去了,窗口最小化、关闭、浏览器搜索所选文字,还有。。
; !x::WinRestore("A")
; !z::WinMinimize("A")
; #z::Send("!{Esc}") ; Sends a window to the bottom of stack; that is, beneath all other windows. The effect is similar to pressing Alt+Esc.
Send_with_delay( retype_text ){
ToolTip( StrLen(retype_text) )
loop(StrLen(retype_text))
{
char := SubStr(retype_text, A_Index , 1)
Send( char )
Sleep 10
}
}
; 还不如我自己主动占用掉它:输入法根本不会考虑到这个问题,键位不能改,所以不如自己抢先占用掉最好用的快捷键。
; vscode 如何改 hotkey ctrl k/s 如果实在输入法和软件冲突,倒不如改软件的快捷键,
; 非常常见的问题,这多个组合键之间本来就不应该触发别的功能。 例如你要使用格式刷,它的快捷键是 ctrl + shift + C/V。 但是ctrl加shift会触发更换语言的快捷键。
Clip(Text)
{
SoundBeep()
Send(Text)
}
ClipL(Text)
{
Send(Text)
Send("{Left}")
}
;^LAlt 欠考虑了,不能用这个。 例如 ctrl + alt + h ,会提前触发本组合。
;^RAlt:: 欠考虑了,不能用这个。
; ^Shift::return 欠考虑了,不能用这个。
F8 & N::take_notes("OneNote")
F8 & O::take_notes("Obsidian")
F9 & u::Send("^{u}")
F9 & r::Send("^{r}")
F9 & q::Send("^{q}")