-
Notifications
You must be signed in to change notification settings - Fork 0
/
myhotkey.ahk
1567 lines (1143 loc) · 36 KB
/
myhotkey.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
;;@todo improve singleton process and support window title jump.
#SingleInstance force
; Do not enable emacs-binding in no_emacs group for they have had emacs-binding
; GroupAdd no_emacs, ahk_class PuTTY
; GroupAdd no_emacs, ahk_class KiTTY
; GroupAdd no_emacs, ahk_class TSSHELLWND ; Remote Desktop
; GroupAdd no_emacs, ahk_class Emacs ; Emacs W32
; ; Plato Wu, 2009/4/28, try to not use firemace.
; ; GroupAdd no_emacs, ahk_class MozillaUIWindowClass ; Mozilla Firefox
; GroupAdd no_emacs, ahk_class {E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8} ; foobar
; ; rxvt use different windows class in diffrent machine like
; GroupAdd no_emacs, MINGW32
; GroupAdd no_emacs, DrScheme
; GroupAdd no_emacs, ARM - Multi-ICE Server ; I need C-r shortkey of it.
; GroupAdd no_emacs, ahk_class VNCMDI_Window ; UltraVNC
; GroupAdd no_emacs, ahk_class mintty
; GroupAdd no_emacs, ahk_class VNCviewer ;TightVNC
; GroupAdd no_emacs, ahk_class cygwin/xfree86 ; NX Client
; GroupAdd no_emacs, NX ; NX Client
; GroupAdd no_emacs, ahk_class VirtualConsoleClass ; cmder
; GroupAdd no_emacs, ahk_class TMobaXtermForm ; MobaXterm
; ;GroupAdd no_emacs, ahk_class cygwin/x ; Xming
DetectHiddenWindows, On
AllowMulteInstance=Totalcmd.exe|cygwin.exe
; Plato Wu,2009/05/29: C_x keys are inputed into password edit of QQ with
; no reason, I don't know why.
C_x_prefix = 0
; Plato Wu,2009/05/22: This sentence is prerequisite!
Hotkey, IfWinActive
; Plato Wu,2009/05/22: the $ prefix is needed so that the hotkey can "send itself"
; without activating itself (which would otherwise trigger a warning dialog
; about an infinite loop;
Hotkey, $h, h_hotkey
Hotkey, $u, u_hotkey
clipboard_index = 0
CoordMode Caret, Screen ; Affects the built-in variables A_CaretX and A_CaretY
; using screen coordinate. Caret is text insertion point
CoordMode Mouse, Screen ; Let MouseMove use screen coordinate
;;;;;;;;;;;;;;;;;;;;;;;; Merge from 320MPH
AutoTrim, Off
SetBatchLines, -1
MainWnd = Launchy & XKeymacs -- Rajat, Plato Wu
SetKeyDelay, 0
;___________________________________________
IniFile = %A_ScriptDir%\320MPH.ini
; Plato Wu,2009/05/20: detract UsedList from ini file to used list file
UsedListFile = %A_ScriptDir%\UsedList.txt
IfNotExist, %IniFile%
{
MsgBox,, 320MPH, 320MPH.ini not found. Program will now exit
ExitApp
}
;Reading Settings
IniRead, PathList, %IniFile%, Settings, PathList, %A_MyDocuments%|%A_ProgramFiles%
IniRead, TypeList, %IniFile%, Settings, TypeList, exe|lnk|ahk|url|mp3
IniRead, ExcludeList, %IniFile%, Settings, ExcludeList, about|history|readme|remove|uninstall|license
IniRead, AlwaysScan, %IniFile%, Settings, AlwaysScan, %UserProfile%\Recent|%A_StartMenuCommon%|%A_StartMenu%|%A_Desktop%
IniRead, MaxLastUsed, %IniFile%, Settings, MaxLastUsed, 50
IniRead, WaitTime, %IniFile%, Settings, WaitTime, 100
IniRead, ShowIcons, %IniFile%, Settings, ShowIcons, 1
IniRead, MinLen, %IniFile%, Settings, MinLen, 2
IniRead, ListFile, %IniFile%, Settings, ListFile, RunList.txt
IniRead, ShellIntegration, %IniFile%, Settings, ShellIntegration, 1
IniRead, GuiWMinus, %IniFile%, Settings, GuiWMinus, 20
IniRead, GuiHMinus, %IniFile%, Settings, GuiHMinus, 250
IniRead, Dict, %IniFile%, Settings, Dict, D:\Tools\GoldenDict\GoldenDict.exe
IniRead, DictClass, %IniFile%, Settings, DictClass, QWidget
IniRead, DictTitle, %IniFile%, Settings, DictTitle, GoldenDict
IniRead, StartMouseFlag, %IniFile%, Settings, MouseFlag, True
DllCall("SwapMouseButton", Int, StartMouseFlag)
MiddleMouseFlag = StartMouseFlag
; Plato Wu,2009/05/20: it seems LastUsedList is useless
;IniRead, UsedList, %IniFile%, Settings, UsedList, |
;LastUsedList = %UsedList%
; Plato Wu,2020/08/12: use IniFile for no_emacs
IniRead, NoEmacsList, %IniFile%, Settings, NoEmacsList
; Loop, Parse, NoEmacsList, |, %A_Space%%A_Tab% don't need Trim
Loop, Parse, NoEmacsList, |
{
; MsgBox, %A_LoopField%
GroupAdd, no_emacs, % Trim(A_LoopField)
}
GroupAdd, 320MPH, ahk_class AutoHotkeyGUI
GroupAdd, 320MPH_no_emacs, ahk_group 320MPH
GroupAdd, 320MPH_no_emacs, ahk_group no_emacs
GuiW := A_ScreenWidth - GuiWMinus
GuiH := A_ScreenHeight - GuiHMinus
AlwaysScan := ExpandVars(AlwaysScan)
PathList := ExpandVars(PathList)
StringRight, ExtChk, A_ScriptFullPath, 4
IfEqual, ExtChk, .exe
RParam = %1%
;IniRead, UsedList, %IniFile%, Settings, UsedList
FileRead, UsedList, %UsedListFile%
IfEqual, UsedList, ERROR
UsedList =
UsedList0 =
Loop, Parse, UsedList, |
{
IfNotExist, %A_LoopField%, Continue
UsedList0 = %UsedList0%|%A_LoopField%
}
UsedList = %UsedList0%
;___________________________________________
;create scanned result list on first run
IfExist, %A_ScriptDir%\%ListFile%
{
ItemList =
Loop, Read, %A_ScriptDir%\%ListFile%
{
IfEqual, A_LoopReadLine,, Continue
ItemList = %ItemList%|%A_LoopReadLine%
}
}
Else
Gosub, ButtonScan
;scan always updated list
Loop, Parse, AlwaysScan, |
{
Loop, %A_LoopField%\*.*, 0, 1
{
SplitPath, A_LoopFileFullPath, FName, FDir, FExt, FNameNoExt, FDrive
;only filetypes defined are added
IfNotInString, TypeList, %FExt%, Continue
;excluding items based on ExcludeList
Cont = 0
Loop, Parse, ExcludeList, |
{
IfInString, FName, %A_LoopField%
{
Cont = 1
Break
}
}
IfEqual, Cont, 1
Continue
;reaching here means that file is not to be excluded and
;has a desired extension
RecentList = %RecentList%|%A_LoopFileFullPath%
}
}
StringTrimLeft, RecentList, RecentList, 1
ItemList = %RecentList%%ItemList%
LVGuiW := GuiW - 12
LVGuiH := GuiH - 64
StatusY := GuiH - 25
;Plato Wu, 2009/5/8, Remarks for nice appearance for me and
; let it can be moved
;Gui, -Caption +Border
Gui, Add, Text, x6 y7 w40 h20, Search:
Gui, Add, Edit, x46 y5 w100 h20 vCurrText gGetText,
Gui, Add, Text, x160 y7 w40 h20, Params:
Gui, Add, Edit, x210 y5 w100 h20 vRParam, %RParam%
Gui, Add, ListView, x6 y35 w%LVGuiW% h%LVGuiH% vSelItem HScroll gSelection AltSubmit, Name|Ext|Folder
Gui, Add, Button, 0x8000 x326 y5 w40 h20 Default, &Open
Gui, Add, Button, 0x8000 x376 y5 w40 h20, &Scan
Gui, Add, Text, x6 y%StatusY% w120 h20 vResults,
Gui, Font, S10 CDefault Italic Bold, Verdana
Gui, Add, Text, x450 y%StatusY% w150 h20 Right, %MainWnd%
LV_ModifyCol(1, 100)
LV_ModifyCol(2, 60)
LV_ModifyCol(3, 250)
;Plato Wu, 2009/5/7, It runs background now
;Gui, Show, h%GuiH% w%GuiW%, %MainWnd%
LastText = fadsfSDFDFasdFdfsadfsadFDSFDf
;SetTimer, GetText, 200
Gosub, GetText
;Sleep, 200
Control, Choose, 1, SysListView321, %MainWnd%
; Plato Wu,2009/05/31: Flag for up/down in file browser mode
FileBrowseUpDown =
;;;;;;;;;;;;;;;;;;;;;;;;
;Plato Wu,2009/05/21: view-lookup-dict-mode
GroupAdd, dict, ahk_class %DictClass%
;#32770
lookup_mode = 0
lookup_hotkey = 0
alphabet="abcdefghijklmnopqrstuvwxyz"
;view_class =
view_title =
old_view_title =
return ; End of autoexecute section.
; Plato Wu,2009/12/08: Add IME control function
IME_ON(hWindow, IsON)
{
; WM_IME_CONTROL = 0x0283
; IMC_SETOPENSTATUS = 0x0006
bufCurrentDetectMode := A_DetectHiddenWindows
DetectHiddenWindows, On
; Plato Wu,2014/05/14: use latest method call for win7 64bit
; buf := DllCall("user32.dll\SendMessageA", "UInt", DllCall("imm32.dll\ImmGetDefaultIMEWnd", "Uint",hWindow), "UInt", 0x0283, "Int", 0x0006, "Int", IsON)
buf := DllCall("SendMessage", "UInt", DllCall("imm32.dll\ImmGetDefaultIMEWnd", "Uint",hWindow), "UInt", 0x0283, "Int", 0x0006, "Int", IsON)
DetectHiddenWindows, %bufCurrentDetectMode%
Return buf
}
#c::
Send ^c
Run Notepad
WinWait ahk_class Notepad ;
Send ^v
return
; replace delete key in file_manager group to use my trash script
; Plato Wu,2014/03/28: use FreeCommader XE, it support user defined del key
; Plato Wu,2009/04/21: _ can not be used in group name.
GroupAdd file_manager, ahk_class TTOTAL_CMD ; total commander
GroupAdd file_manager, ahk_class ExploreWClass ; explorer
GroupAdd file_manager, ahk_class Progman ;desktop
GroupAdd file_manager, ahk_class TxUNCOM ; Unreal Commander
; #IfWinActive ahk_group file_manager
; ^d::
; Delete::
; Send {AppsKey}M{Enter}
; MouseMove A_CaretX,A_CaretY
; MouseGetPos, , , , control
; ;ToolTip,Control %listitems%
; ; When Caret is in Edit of file_manager, Send Delete key still
; if InStr(control, "Edit") or InStr(control, "TMyPanel9") or InStr(control, "TMyPanel5")
; {
; Send {Click}{Delete}
; }
; return
; #z::
; WinGetTitle, Title, A
; MsgBox, The active window is "%Title%".
; ;WinGetClass, class, A
; ;MsgBox, The active window's class is "%class%".
; return
; Plato Wu,2009/05/31: ^p & ^n need special handle in 320MPH_no_emacs
#ifWinNotActive ahk_group 320MPH_no_emacs
^p:: Send {Up}
^n:: Send {Down}
#ifWinNotActive ahk_group no_emacs
^f:: Send {Right}
^b:: Send {Left}
^v:: Send {PgDn}
!v:: Send {PgUp}
^w::
Send ^x
ClipWait
if clipboard_index > 20
clipboard_index = 0
Array%clipboard_index% := clipboard
;element := Array%clipboard_index%
clipboard_index ++
return
!w::
Send ^c
ClipWait
if clipboard_index > 20
clipboard_index = 0
Array%clipboard_index% := clipboard
;;element := Array%clipboard_index%
clipboard_index ++
return
^y::
; Plato Wu,2009/12/31: add killed text into kill ring if it is not copyed by quick key.
if clipboard_index > 0
{
clipboard_index --
element := Array%clipboard_index%
clipboard_index ++
; MsgBox, %element%
; MsgBox, %clipboard%
IfNotInString, element, %clipboard%
{
; MsgBox, %element%
; MsgBox, %clipboard%
Array%clipboard_index% := clipboard
clipboard_index ++
}
}
Send ^v
return
!y::
If clipboard_index > 0
{
; discard previous paste result
Send ^z
clipboard_index -=2
; Plato Wu,2009/04/21: Since %Array%clipboard_index%% is illegal
element := Array%clipboard_index%
clipboard = %element%
Send ^v
}
return
^d:: Send {Delete}
^a:: Send {Home}
^e:: Send {End}
^g:: Send {Escape}
^k:: Send +{End}^x
^o:: Send {Return}{Left}
!<:: Send ^{Home}
!>:: Send ^{End}
^x:: C_x_prefix = 1
; Plato Wu,2012/12/10: there is 1 & 2 in QQ password and username and it is input initially and this script will cause send them again.
; 1::
; If C_x_prefix = 1
; {
; ; WinRestore, A
; ; WinMaximize, A
; WinMove, A,,0,0,A_ScreenWidth, A_ScreenHeight
; C_x_prefix = 0
; }Else
; {
; Send 1
; }
; return
; 2::
; If C_x_prefix = 1
; {
; ; WinGetPos,,, Width, Height, A
; ; MsgBox, %Width%,%Height%
; WinMove, A,,0,A_ScreenHeight/2,A_ScreenWidth, A_ScreenHeight/2
; C_x_prefix = 0
; }Else
; {
; Send 2
; }
; return
; Plato Wu,2009/05/22: use hotkey function instead double colon label which can not
; be disable by hotkey function
h_hotkey:
If C_x_prefix = 1
{
Send ^a
C_x_prefix = 0
}Else
{
GetKeyState, state, CapsLock, T
if state = D
Send H
else
Send h
}
return
u_hotkey:
If C_x_prefix = 1
{
Send ^z
C_x_prefix = 0
}Else
{
GetKeyState, state, CapsLock, T
if state = D
Send U
else
Send u
}
return
; Plato Wu,2021/05/20: little using in emacs edit mode, but useful for search in powershell
; ^r:: Send ^f!u!n
^s::
If C_x_prefix = 1
{
Send ^s
C_x_prefix = 0
}Else
{
Send ^f
if WinActive ahk_class Notepad
Send !d!n
}
return
;DllCall("SwapMouseButton", Int, False)
; Plato Wu,2014/04/18: use middle mouse button to swap mouse button
#LButton::
DllCall("SwapMouseButton", Int,( MiddleMouseFlag:=!MiddleMouseFlag))
Msgbox "Swap Mouse Button"
return
;Suspend or Resume hotkeys
^q::
Suspend
DllCall("SwapMouseButton", Int,( StartMouseFlag:=!StartMouseFlag ) )
return
;Reload script
^!r::Reload
;;;;;;;;;;;;;;;;;;;;;;;; Merge from 320MPH
#IfWinActive
;Plato Wu, 2009/5/7, Use Alt+Space to invoke GUI and hide GUI, just like launchy
; Plato Wu,2020/12/09: use Listary instead
; !Space::
; IfWinNotActive, %MainWnd%,
; {
; Gui, Show, h%GuiH% w%GuiW%, %MainWnd%
; ; Plato Wu,2009/05/20: make edit initial as insertion mode
; ControlFocus, Edit1, %MainWnd%
; ; Plato Wu,2010/03/01: it does not work with AHKL,use shift down/up instead.
; ; Plato Wu,2010/03/05: now I don't use AHKL
; ControlSend Edit1, +^a, %MainWnd%
; ; ControlSend Edit1, {Shift Down}{HOME}{Shift Up}, %MainWnd%
; ; Plato Wu,2009/06/30: Disable Chinese input method which can muss shift key state.
; ; Sleep, 1000
; ; ControlSend Edit1, ^+0, %MainWnd%
; ControlGet, hWindow, Hwnd
; ; Plato Wu,2009/12/08: Disable IME
; IME_ON(%hWindow%, 0)
; return
; }
;ToolTip
Gui, Submit, %MainWnd%
return
#IfWinActive ahk_group 320MPH
;Launchy & XKeymacs binding-- Rajat, Plato Wu
AutoComplete:
; Plato Wu,2009/05/30: Auto complete input by first item
IfInstring, CurrText, \
{
SelItem := LV_GetNext()
; MsgBox %SelItem%
LV_GetText(FName, SelItem, 1)
; ; LV_GetText(FExt, SelItem, 2)
LV_GetText(FPath, SelItem, 3)
; MsgBox, %FName%
FileBrowseUpDown = 1
ControlSetText, Edit1, %FPath%\%FName%, %MainWnd%
ControlSend, Edit1, {End}, %MainWnd%
}
return
; Plato Wu,2009/07/01: \
\::
Send,{Left}{Right}\
;Send,
;Send,\
return
; Plato Wu,2009/06/23: Delete and BackSpace should enable FileBrowseUpDown
~Delete::
FileBrowseUpDown = 1
return
~Backspace::
FileBrowseUpDown = 1
return
^p::
Up::
IfWinNotActive, %MainWnd%,
{
Send, {Up}
Return
}
ControlGetFocus, CurrCtrl, %MainWnd%
IfEqual, CurrCtrl, Edit1
{
ControlSend, SysListView321, {Up}, %MainWnd%
Goto, AutoComplete
}
Return
^n::
Down::
IfWinNotActive, %MainWnd%,
{
Send, {Down}
Return
}
ControlGetFocus, CurrCtrl, %MainWnd%
IfEqual, CurrCtrl, Edit1
{
ControlSend, SysListView321, {Down}, %MainWnd%
Goto, AutoComplete
}
Return
^Del::
IfWinNotActive, %MainWnd%,, Return
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText,, Return
SelItem := LV_GetNext()
LV_GetText(FName, SelItem, 1)
LV_GetText(FExt, SelItem, 2)
LV_GetText(FDir, SelItem, 3)
IfEqual, FExt,
Pth = %FDir%\%FName%
IfNotEqual, FExt,
Pth = %FDir%\%FName%.%FExt%
StringReplace, UsedList, UsedList, |%pth%,, A
;IniWrite, %UsedList%, %IniFile%, Settings, UsedList
FileAppend, %UsedList%, %UsedListFile%
LastText = x
Goto, GetText
Return
GetWindowsByStyle(p_style,p_delim="|")
{
WinGet, l_array, List
Loop, %l_array%
{
WinGet, l_tmp, Style, % "ahk_id " l_array%A_Index%
If (l_tmp & p_style)
{
WinGetTitle, l_tmp, % "ahk_id " l_array%A_Index%
IfEqual, l_tmp
Continue
l_out .= ( l_out="" ? "" : p_delim ) l_tmp
}
}
Return l_out
}
;RetriveAllWindows(WinTitle)
; Plato Wu,2010/01/27
RetriveAllWindows:
{
WS_VISIBLE := 0x10000000
;delim := "`r`n"
;MsgBox % GetWindowsByStyle(WS_VISIBLE,delim)
; ControlGet, hwnd, hwnd, , ToolbarWindow322, ahk_class Shell_TrayWnd
; Acc := COM_AccessibleObjectFromWindow(hwnd)
; Loop, % Acc.accChildCount
; {
; Title := Acc.accName(A_Index)
; If CurrText !=
; {
; ; StringLen, Len, CurrText
; ; StringLeft, LText, Title, %Len%
; ;Matching leftmost text
; ;;IfNotEqual, LText, %CurrText%
; IfNotInString, Title, %CurrText%
; Continue
; }
; IfWinNotExist, %Title%
; Continue
; Count ++
; WinGet, wid, id, Title
; ;; MsgBox, %wid%
; SendMessage, 0x7F, 2, 0,, ahk_id %wid%
; h_icon := ErrorLevel
; If ( ! h_icon )
; {
; SendMessage, 0x7F, 0, 0,, ahk_id %wid%
; h_icon := ErrorLevel
; If ( ! h_icon )
; {
; ; If Use_Large_Icons_Current =1
; ; h_icon := DllCall( "GetClassLong", "uint", wid, "int", -14 ) ; GCL_HICON is -14
; If ( ! h_icon )
; {
; h_icon := DllCall( "GetClassLong", "uint", wid, "int", -34 ) ; GCL_HICONSM is -34
; If ( ! h_icon )
; h_icon := DllCall( "LoadIcon", "uint", 0, "uint", 32512 ) ; IDI_APPLICATION is 32512
; }
; }
; }
; DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, h_icon)
; DllCall("DestroyIcon", Uint, h_icon)
; LV_Add("Icon" count, Title)
; ; MsgBox, %Title%
; }
; list .= WinExist(WinTitle:=Acc.accName(A_Index)) ? WinTitle "`n" : ""
; MsgBox, % SubStr( list, 1, -1 )
WinGet, UsedList0, List
; MsgBox, %CurrText%
; Count = 1
Loop, %UsedList0%
{
wid := UsedList0%A_Index%
WinGetTitle, Title, ahk_id %wid%
If CurrText !=
{
; StringLen, Len, CurrText
; StringLeft, LText, Title, %Len%
;Matching leftmost text
;;IfNotEqual, LText, %CurrText%
IfNotInString, Title, %CurrText%
Continue
}
If Title = ; skip windows with no title - e.g. popup windows
Continue
; WinGetClass, Win_Class, ahk_id %wid%
; If ( ! ( Win_Class ="#32770" ) )
; Continue
WinGet, Style, Style, ahk_id %wid%
If Style & WS_VISIBLE = 0
Continue
; WinGet, MinMax, MinMax, ahk_id %wid%
; MsgBox, %MinMax%
; if MinMax =
; Continue
;
; if MinMax = 0
; Continue
Count ++
; hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, A_LoopFileLongPath, UShortP, iIndex)
; SendMessage, 0x7F, 1, 0,, ahk_id %wid%
; MsgBox, %ErrorLevel%
; h_Icon := ErrorLevel
SendMessage, 0x7F, 2, 0,, ahk_id %wid%
h_icon := ErrorLevel
If ( ! h_icon )
{
SendMessage, 0x7F, 0, 0,, ahk_id %wid%
h_icon := ErrorLevel
If ( ! h_icon )
{
; If Use_Large_Icons_Current =1
; h_icon := DllCall( "GetClassLong", "uint", wid, "int", -14 ) ; GCL_HICON is -14
If ( ! h_icon )
{
h_icon := DllCall( "GetClassLong", "uint", wid, "int", -34 ) ; GCL_HICONSM is -34
If ( ! h_icon )
h_icon := DllCall( "LoadIcon", "uint", 0, "uint", 32512 ) ; IDI_APPLICATION is 32512
}
}
}
DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, h_icon)
DllCall("DestroyIcon", Uint, h_icon)
LV_Add("Icon" count, Title)
}
}
GetText:
ControlGetText, CurrText, Edit1, %MainWnd%
IfEqual, CurrText, %LastText%, Return
StringLen, Check, CurrText
IfGreater, Check, 0
IfLess, Check, %MinLen%
Return
LastText = %CurrText%
;from last used_____________________________
IfEqual, CurrText,
{
IfEqual, ShowIcons, 1
{
IL_Destroy(ImageListID1)
; Create an ImageList so that the ListView can display some icons:
ImageListID1 := IL_Create(5, 10)
; Attach the ImageLists to the ListView so that it can later display the icons:
LV_SetImageList(ImageListID1)
}
LV_Delete()
Count =
; RetriveAllWindows("")
; WinTitle =
Gosub, RetriveAllWindows
StringTrimLeft, UsedList0, UsedList, 1
Loop, Parse, UsedList0, |
{
;check for change in search querry
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText, %LastText%, Goto, GetText
SplitPath, A_LoopField, FName, FDir, FExt, FNameNoExt
Count ++
IfGreater, Count, %MaxLastUsed%, Break
IfEqual, ShowIcons, 1
{
hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, A_LoopField, UShortP, iIndex)
DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon)
DllCall("DestroyIcon", Uint, hIcon)
}
LV_Add("Icon" Count, FNameNoExt, FExt, FDir )
;select first item
IfEqual, A_Index, 1
ControlSend, SysListView321, {Down}, %MainWnd%
}
}
;from all items_____________________________
; Plato Wu,2009/05/30: Add file browser function
IfInstring, CurrText, \
{
; MsgBox, %CurrText%
; Plato Wu,2009/06/30: sleep until CurrText is clear.
sleep, 500
IfEqual, FileBrowseUpDown,
{
LV_Delete()
IL_Destroy(ImageListID1)
; Create an ImageList so that the ListView can display some icons:
ImageListID1 := IL_Create(10, 20)
; Attach the ImageLists to the ListView so that it can later display the icons
LV_SetImageList(ImageListID1)
Count =
Loop, %CurrText%*.*, 1, 0
{
; MsgBox %A_LoopFileAttrib%,%A_LoopFileName%,%A_LoopFileExt%
; IfNotInString, TypeList, %A_LoopFileExt%, Continue
IfEqual, A_LoopFileExt,
{
IfNotInString, A_LoopFileAttrib, D
Continue
}
SplitPath, A_LoopFileName,,,,FileName
hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, A_LoopFileLongPath, UShortP, iIndex)
DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon)
DllCall("DestroyIcon", Uint, hIcon)
Count ++
LV_Add("Icon" Count, FileName, A_LoopFileExt, A_LoopFileDir)
}
; ControlSetText, Edit1, %CurrText%%FName%, %MainWnd%
LV_GetText(FName, 1, 1)
; ; LV_GetText(FExt, SelItem, 2)
LV_GetText(FPath, 1, 3)
IfNotEqual, FName,
{
Length := StrLen(CurrText)
ControlSetText, Edit1, %FPath%\%FName%, %MainWnd%
ControlSend, Edit1, {Right %Length%}, %MainWnd%
ControlSend, Edit1, +{End}, %MainWnd%
; ControlSend, Edit1, {End}, %MainWnd%
}
}else{
FileBrowseUpDown =
}
}else IfNotEqual, CurrText,
{
FileBrowseUpDown =
; Plato Wu,2009/07/13: It seems this sentence is useless, for we actually
; use SearchList.
; IfInString, ItemList, %CurrText%
IfEqual, ShowIcons, 1
{
IL_Destroy(ImageListID1)
; Create an ImageList so that the ListView can display some icons:
ImageListID1 := IL_Create(20, 50)
; Attach the ImageLists to the ListView so that it can later display the icons:
LV_SetImageList(ImageListID1)
}
LV_Delete()
;___________________________________________
; Advanced Search
MatchPList1 =
MatchPList2 =
MatchPList3 =
Count =
; RetriveAllWindows(CurrText)
Gosub, RetriveAllWindows
;earliest in searh results are recently used items
; Plato Wu,2009/07/13: The last item in UsedList does not has | separator
SearchList = %UsedList%|%ItemList%
Loop, Parse, SearchList, |
{
;check for change in search querry
ControlGetText, CurrText, Edit1, %MainWnd%
IfNotEqual, CurrText, %LastText%, Goto, GetText
CurrItem = %A_LoopField%
;remove duplicate entry that exists both in usedlist and itemlist
CheckList = %MatchPList1%%MatchPList2%%MatchPList3%|
IfInString, CheckList, |%CurrItem%|, Continue
SplitPath, CurrItem, FName, FDir, FExt, FNameNoExt, FDrive
StringLen, Len, CurrText
StringLeft, LText, FName, %Len%
;Matching leftmost text
IfEqual, LText, %CurrText%
{
MatchPList1 = %MatchPList1%|%CurrItem%
Continue
}
;Matching file name only
;fuzzy search
MatchFound = Y
Loop, Parse, CurrText, %A_Space%
IfNotInString, FName, %A_LoopField%
MatchFound = N
IfEqual, MatchFound, Y
{
MatchPList2 = %MatchPList2%|%CurrItem%
Continue
}
;search everywhere
;fuzzy search
MatchFound = Y
Loop, Parse, CurrText, %A_Space%
IfNotInString, CurrItem, %A_LoopField%
MatchFound = N
IfEqual, MatchFound, Y
{
MatchPList3 = %MatchPList3%|%CurrItem%
Continue
}
}