forked from TaranVH/2nd-keyboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlmost_All_Windows_Functions.ahk
1278 lines (1040 loc) · 37.3 KB
/
Almost_All_Windows_Functions.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
; global savedCLASS = "ahk_class Notepad++"
; global savedEXE = "notepad++.exe" ;BEFORE the #include is apparently the only place these can go.
#include C:\AHK\2nd-keyboard\point_to_gui.ahk
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
#WinActivateForce
; global savedCLASS = "ahk_class Notepad++"
; global savedEXE = "notepad++.exe"
; -------------------------------------------------------------------------
; If this is your first time using AutoHotkey, you must take this tutorial:
; https://autohotkey.com/docs/Tutorial.htm
; -------------------------------------------------------------------------
; Also, please note that some of the code in this script requires that the
; ACC LIBRARY be installed. I don't remember where I got it, or how to install it.
; Sooooo, you can just delete those functions that use it.
; -------------------------------------------------------------------------
Menu, Tray, Icon, shell32.dll, 16 ;this changes the icon into a little laptop thingy. just useful for making it distinct from the others.
GroupAdd, ExplorerGroup, ahk_class #32770 ;This is for all the Explorer-based "save" and "load" boxes, from any program!
;lololol I have to have tippy(), but i can't redefine an existing function, so I either have to put it in another .ahk script and #include it, or I could go the lazy route and just add a "2" to the end of ALL of them in this file, because I am a such a bad spaghetti coder that I don't even know what that means.
Tippy2(tipsHere, wait:=333)
{
ToolTip, %tipsHere%,,,8
SetTimer, notip2, %wait% ;--in 1/3 seconds by default, remove the tooltip
}
notip2:
ToolTip,,,,8
;removes the tooltip
return
;alt escape does ssomething.
;;;oh heck yes - a case changer.
;;;http://www.computoredge.com/AutoHotkey/Free_AutoHotkey_Scripts_and_Apps_for_Learning_and_Generating_Ideas.html#ChangeCase
;;;aslo i can give myself a ---damn it i forgot it AS i was wriiting it. —a thing to always paste as SIMPLE, unformatted test. YEAH.
;;;clipboard stuff.
;;https://ditto-cp.sourceforge.io/
;;https://cedeq.com/enterpad/en/autohotkey/useful-ahk-scripts/multiple-clipboards
;;https://jacksautohotkeyblog.wordpress.com/2016/06/09/autohotkey-solutions-for-windows-clipboard-limitations-autohotkey-clipboard-tips/
GetFromClipboard()
{
ClipSaved := ClipboardAll ;Save the clipboard
Clipboard = ;Empty the clipboard
SendInput, ^c
ClipWait, 2
if ErrorLevel
{
;; MsgBox % "Failed attempt to copy text to clipboard."
MsgBox,,,"Failed attempt to copy text to clipboard.",0.7
return
}
NewClipboard := Trim(Clipboard)
; StringReplace, NewClipboard, NewClipBoard, `r`n, `n, All ;comment this in to remove whitespace automaticaly
Clipboard := ClipSaved ;Restore the clipboard
ClipSaved = ;Free the memory in case the clipboard was very large.
return NewClipboard
}
/*
MsgBox, % GetAhkStats("lines")
MsgBox, % GetAhkStats("variables")
MsgBox, % GetAhkStats("hotkeys")
Stat1 := GetAhkStats("history")
MsgBox, %Stat1%
Return
a::a
b::b
c::c
d::d
GetAhkStats(xxSection="", xxUseWindow=99, xxDestroyAfter=1)
{
xxSectionN = Lines|Variables|Hotkeys|History
If xxSection=
xxSection = History
Loop, Parse, xxSectionN, |
IfInString, A_LoopField, %xxSection%
xxSection = %A_Index%
DetectHiddenWindows, On
SetTitleMatchMode, 2
Gui, %xxUseWindow%:Show, Hide
xxHidWin := WinExist(A_ScriptFullPath " - AutoHotkey v")
xxOldpar := DllCall("GetParent", "UInt", xxHidWin)
DllCall("SetParent", "UInt", xxHidWin, "UInt", (GuiGetHWND("", xxUseWindow)))
WinMenuSelectItem, ahk_id %xxHidWin%,, View, %xxSection%&
Loop {
Sleep, 50
ControlGetText, xxOut1, Edit1, ahk_id %xxHidWin%
If xxOut1<>
break
}
WinHide, ahk_id %xxHidWin%
DllCall("SetParent", "UInt", xxHidWin, "UInt", xxOldpar)
If (xxDestroyAfter)
Gui, %xxUseWindow%:Destroy
Return, xxOut1
}
GuiGetHWND(xxClassNN="", xxGUI=1)
{
If (xxGUI)
Gui, %xxGUI%:+LastFound
xxGui_hwnd := WinExist()
If xxClassNN=
Return, xxGui_hwnd
ControlGet, xxOutputVar, Hwnd,, %xxClassNN%, ahk_id %xxGui_hwnd%
Return, xxOutputVar
}
*/
;this is where filemover() used to be. I moved it to its own script, since using it would prevent all other scripts from running, until the file was completely moved.
search(){
if winactive("ahk_exe Adobe Premiere Pro.exe")
{
if IsFunc("effectsPanelType") {
Func := Func("effectsPanelType")
RetVal := Func.Call(directory,"")
}
;effectsPanelType("") ;set to macro key G1 on my logitech G15 keyboard.
;This just CLEARS the effects panel search bar so that you can type something in.
;previously was ^+0
}
else if winactive("ahk_exe notepad++.exe")
sendinput ^f
else if winactive("ahk_exe firefox.exe")
sendinput ^e
else if winactive("ahk_exe chrome.exe")
sendinput ^e
else if winactive("ahk_class CabinetWClass")
sendinput ^e
}
#IfWinActive
saveLocation2(){
f_text = 0
SetTitleMatchMode Slow
WinGet, f_window_id, ID, A
WinGetClass, f_class, ahk_id %f_window_id%
;;msgbox,,,%f_class%, 1
if f_class in ExploreWClass,CabinetWClass ; if the window class is an Explorer window of either kind.
{
; WinGetTitle, Title, ahk_class CabinetWClass
WinGetTitle, title, ahk_id %f_window_id% ;super lame way to do this, does not always work.
;msgbox, address is `n%title%
;sorry, I tried to NOT have to refer to these folder paths directly, but it always failed spectacularly:
FileDelete, C:\AHK\2nd-keyboard\Taran's_Windows_Mods\SavedExplorerAddress.txt
FileAppend, %title% , C:\AHK\2nd-keyboard\Taran's_Windows_Mods\SavedExplorerAddress.txt
SavedExplorerAddress = %title%
;checkForFile("Thumbnail","Template.psd")
msgbox, , , %title%`n`nwas saved as root, 0.3
}
else
msgbox,,, this is not an explorer window you chump,0.5
;for some reason, after this script runs, it sometimes activates the last active window. It doesn't make any sense...
}
;for further reading:
;https://autohotkey.com/board/topic/60985-get-paths-of-selected-items-in-an-explorer-window/
;end of savelocation2()
;in progress
checkForFile(subDirectory, filename)
{
FileRead, SavedExplorerAddress, C:\AHK\2nd-keyboard\Taran's_Windows_Mods\SavedExplorerAddress.txt
;msgbox, current directory is`n%directory%
directory = %SavedExplorerAddress%
msgbox, new directory is`n%directory%
;filetype := """" . filetype . """" ;this ADDS quotation marks around a string in case you need that.
StringReplace, directory,directory,", , All ;" ; this REMOVES the quotation marks around the a string if they are present.
finalDirectory = %directory% . %subDirectory%
;msgbox, directory is %directory%`n and filetype is %filetype%
Loop, Files,%finalDirectory%, F
{
If (A_LoopFileTimeModified>Rec)
{
IfNotInString, A_LoopFileFullPath, ~$
FPath=%A_LoopFileFullPath%
Rec=%A_LoopFileTimeModified%
}
}
MsgBox, 3,, Select YES to open the latest %filetype% at Fpath:`n`n%Fpath%
IfMsgBox, Yes
{
Run %Fpath%
}
}
;;;; SCRIPT TO ALWAYS OPEN THE MOST RECENTLY SAVED OR AUTOSAVED FILE OF A GIVEN FILETYPE, IN ANY GIVEN FOLDER (AND ALL SUBFOLDERS.);;;;
;;script partially obtained from https://autohotkey.com/board/topic/57475-open-most-recent-file-date-created-in-a-folder/
openlatestfile(directory, filetype)
{
if directory = 1
{
FileRead, SavedExplorerAddress, C:\AHK\2nd-keyboard\Taran's_Windows_Mods\SavedExplorerAddress.txt
;msgbox, current directory is`n%directory%
directory = %SavedExplorerAddress%
;msgbox, new directory is`n%directory%
}
;filetype := """" . filetype . """" ;this ADDS quotation marks around a string in case you need that.
StringReplace, directory,directory,", , All ;" ; this REMOVES the quotation marks around the a string if they are present.
;Keyshower(directory,"openlatestfile")
if IsFunc("Keyshower") {
Func := Func("Keyshower")
RetVal := Func.Call(directory,"openlatestfile")
}
;I need some method of excluding ~$ files, since those clutter everything up (MS Word .docx ...)
;msgbox, directory is %directory%`n and filetype is %filetype%
Loop, Files,%directory%\*%filetype%, FR
{
If (A_LoopFileTimeModified>Rec)
{
IfNotInString, A_LoopFileFullPath, ~$
FPath=%A_LoopFileFullPath%
Rec=%A_LoopFileTimeModified%
}
}
;try to get this to work with an ENTER press from thne stream deck...
MsgBox, 3,, Select YES to open the latest %filetype% at Fpath:`n`n%Fpath%
IfMsgBox, Yes
{
Run %Fpath%
}
; ; USING THE SCRIPT
; !n::
; examplePath = "Z:\Linus\6. Channel Super Fun\Flicking football"
; openlatestfile(examplePath, ".prproj") ;<--- notice how i INCLUDE the period in the parameters. IDK if it might be better to add the period later.
; return
}
; end of openlatestfile()
debug2:
tooltip, counter = %counter%`nnlines = %nlines%, , , 10
;tooltip, , , , 10
return
;;;;;;;;;;;;;;;;THOSE DIDNT WORK.;;;;;;;;;;;;;;;
;MOVED FROM PREMIERE SCRIPTS
;function to start, then activate any given application
openApp(theClass, theEXE, theTitle := ""){
;Keyshower(theEXE, "openApp") ;leads to a function that shows the keypresses onscreen
if IsFunc("Keyshower") {
Func := Func("Keyshower")
RetVal := Func.Call(theEXE, "openApp")
}
IfWinNotExist, %theClass%
Run, % theEXE
if not WinActive(theClass)
{
WinActivate %theClass%
;WinGetTitle, Title, A
WinRestore %theTitle%
}
}
;MOVED FROM PREMIERE SCRIPTS
;this should probably all be replaced with instantexplorer, since that will work to change any existing Save as dialouges or whatever.
runexplorer(foo)
{
send {SC0E8} ;the scan code of an unassigned key ;;sending even a single keystroke like this, which comes "from" the secondary keyboard, will prevent the taskbar icon from sometimes flashing pointlessly rather than opening.
sleep 5
Run, % foo
sleep 10
;Send,{LCtrl down}{NumpadAdd}{LCtrl up} ;windows shortcut to resize name feild to fit.
;alt v o down enter will sort by date modified, but it is stupid...
if IsFunc("Keyshower")
{
;you can ignore or delete this part. It's just for onscreen visualization. Not necessary.
Func := Func("Keyshower")
RetVal := Func.Call(foo, "runExplorer")
}
;I'm commenting this code out for now because it hasn't been working lately...
; if WinActive("ahk_exe explorer.exe")
; {
; tooltip, explorer is open already, now doing NAVRUN
; NavRun(foo)
; }
; Else
; {
; tooltip, else was triggered meaning we are not in explorer)
; Run, % foo
; }
; Return
}
;-------The below script origninally from: https://autohotkey.com/board/topic/102127-navigating-explorer-directories/
; ; Hotkeys 1 & 2
; 1::NavRun("C:\")
; 2::NavRun(A_MyDocuments)
; http://msdn.microsoft.com/en-us/library/bb774094
GetActiveExplorer() {
tooltip, getactiveexplorer code now
static objShell := ComObjCreate("Shell.Application")
WinHWND := WinActive("A") ; Active window
for Item in objShell.Windows
if (Item.HWND = WinHWND)
return Item ; Return active window object
return -1 ; No explorer windows match active window
}
NavRun(Path) {
if (-1 != objIE := GetActiveExplorer())
objIE.Navigate(Path)
else
Run, % Path
}
;--------The above script origninally from: https://autohotkey.com/board/topic/102127-navigating-explorer-directories/
; #ifwinactive
; F7::
; Send ^s
; sleep 200
; SoundBeep, 1100, 500
; Reload ;The only thing you need here is the Reload
; Return
#IfWinActive
;BEGIN savage-folder-navigation CODE!
;I got MOST of this code from https://autohotkey.com/docs/scripts/FavoriteFolders.htm
;and modified it to work with any given keypress, rather than middle mouse click as it had before.
;NEED to include this too: file locator modified Explorer window with shitty edit2 control
;Locate File '\\?\Z:\Linus\1. Linus Tech Tips\Pending\Maxine Settings Computer\Delivery\Maxine Settings Computer rc3.mov'
;ahk_class #32770
;ahk_exe Adobe Premiere Pro.exe
;
;;;NEEDED: must not get address by looking at title text, it is unreliable. if you search for a thing for example, it will open a new window. this may or may not be a bad thing... also i can have it clear the search - that WOULD be bad. must do more experiments with this one...
InstantExplorer(f_path,pleasePrepend := 0)
{
;this has been heavily modified from https://autohotkey.com/docs/scripts/FavoriteFolders.htm
send {SC0E8} ;scan code of an unassigned key. This is needed to prevent the item from merely FLASHING on the task bar, rather than opening the folder. Don't ask me why, but this works.
if pleasePrepend = 1 ;i forget what this is even for...
{
FileRead, SavedExplorerAddress, C:\AHK\2nd-keyboard\Taran's_Windows_Mods\SavedExplorerAddress.txt
;msgbox, current f_path is %f_path%
f_path = %SavedExplorerAddress%\%f_path% ;there is no need to use . to concatenate
;msgbox, new f_path is %f_path%
}
;NOTE TO FUTURE TARAN: for Keyshower, put code here to find the first / and remove the string before it. otherwise you can't see the final folder name
;Keyshower(f_path,"InstExplor")
if IsFunc("Keyshower") {
Func := Func("Keyshower")
RetVal := Func.Call(f_path,"InstExplor")
}
if !FileExist(f_path)
{
MsgBox,,, No such path exists.,0.7
GOTO, instantExplorerEnd
}
f_path := """" . f_path . """" ;this adds quotation marks around everything so that it works as a string, not a variable.
;msgbox, f_path is now finally %f_path%
;SoundBeep, 900, 400 ;this is dumb because you cant change the volume, or tell it NOT to wait while the sound plays...
; These first few variables are set here and used by f_OpenFavorite:
WinGet, f_window_id, ID, A
WinGetClass, f_class, ahk_id %f_window_id%
WinGetTitle, f_title, ahk_id %f_window_id% ;to be used later to see if this is the export dialouge window in Premiere...
if f_class in #32770,ExploreWClass,CabinetWClass ; if the window class is a save/load dialog, or an Explorer window of either kind.
ControlGetPos, f_Edit1Pos, f_Edit1PosY,,, Edit1, ahk_id %f_window_id%
;edit2
/*
if f_AlwaysShowMenu = n ; The menu should be shown only selectively.
{
if f_class in #32770,ExploreWClass,CabinetWClass ; Dialog or Explorer.
{
if f_Edit1Pos = ; The control doesn't exist, so don't display the menu
return
}
else if f_class <> ConsoleWindowClass
return ; Since it's some other window type, don't display menu.
}
; Otherwise, the menu should be presented for this type of window:
;Menu, Favorites, show
*/
; msgbox, A_ThisMenuItemPos %A_ThisMenuItemPos%
; msgbox, A_ThisMenuItem %A_ThisMenuItem%
; msgbox, A_ThisMenu %A_ThisMenu%
;;StringTrimLeft, f_path, f_path%A_ThisMenuItemPos%, 0
; msgbox, f_path: %f_path%`n f_class: %f_class%`n f_Edit1Pos: %f_Edit1Pos%
; f_OpenFavorite:
;msgbox, BEFORE:`n f_path: %f_path%`n f_class: %f_class%`n f_Edit1Pos: %f_Edit1Pos%
; Fetch the array element that corresponds to the selected menu item:
;;StringTrimLeft, f_path, f_path%A_ThisMenuItemPos%, 0
if f_path =
return
if f_class = #32770 ; It's a dialog.
{
;msgbox, f_title is %f_title%
; IF f_title is NOT "export settings," with the exe "premiere pro.exe"
;go to the end or do something else, since you are in Premiere's export media dialouge box... which has the same #23770 classNN for some reason...
;msgbox,,,test code E1,0.5
if f_title = Export Settings
{
msgbox,,,you are in Premiere's export window, but NOT in the "Save as" inside of THAT window. no bueno, 1
GOTO, instantExplorerEnd
;return ;no, I don't want to return because i still want to open an explorer window.
}
if WinActive("ahk_exe Adobe Premiere Pro.exe")
{
tooltip,you are inside of premieres save as thingy
if f_title = Save As or f_title = Save Project ;IDK if this OR is properly nested....
{
ControlFocus, Edit1, ahk_id %f_window_id% ;this is really important.... it doesn't work if you don't do this...
msgbox,,,you are here,0.5
tippy2("DIALOUGE WITH PREMIERE'S Edit1`n`nLE controlfocus of Edit1 for f_window_id was just engaged.", 2000)
; msgbox, is it in focus?
; MouseMove, f_Edit1Pos, f_Edit1PosY, 0
; sleep 10
; click
; sleep 10
; msgbox, how about now? x%f_Edit1Pos% y%f_Edit1PosY%
;msgbox, Edit1 has been clicked maybe
; Activate the window so that if the user is middle-clicking
; outside the dialog, subsequent clicks will also work:
WinActivate ahk_id %f_window_id%
; Retrieve any filename that might already be in the field so
; that it can be restored after the switch to the new folder:
ControlGetText, f_text, Edit1, ahk_id %f_window_id%
ControlSetText, Edit1, %f_path%, ahk_id %f_window_id%
ControlSend, Edit1, {Enter}, ahk_id %f_window_id%
Sleep, 100 ; It needs extra time on some dialogs or in some cases.
ControlSetText, Edit1, %f_text%, ahk_id %f_window_id%
;msgbox, AFTER:`n f_path: %f_path%`n f_class: %f_class%`n f_Edit1Pos: %f_Edit1Pos%
tooltip,
return
}
}
;if WinActive("ahk_exe Adobe Premiere Pro.exe") and f_title = Save Project
; Save As
;OR Save Project
; ahk_class #32770
; ahk_exe Adobe Premiere Pro.exe
if f_Edit1Pos <> ; And it has an Edit1 control.
{
ControlFocus, Edit1, ahk_id %f_window_id% ;this is really important.... it doesn't work if you don't do this...
tippy2("DIALOUGE WITH EDIT1`n`nwait really?`n`nLE controlfocus of edit1 for f_window_id was just engaged.", 1000)
; msgbox, is it in focus?
; MouseMove, f_Edit1Pos, f_Edit1PosY, 0
; sleep 10
; click
; sleep 10
; msgbox, how about now? x%f_Edit1Pos% y%f_Edit1PosY%
;msgbox, edit1 has been clicked maybe
; Activate the window so that if the user is middle-clicking
; outside the dialog, subsequent clicks will also work:
WinActivate ahk_id %f_window_id%
; Retrieve any filename that might already be in the field so
; that it can be restored after the switch to the new folder:
ControlGetText, f_text, Edit1, ahk_id %f_window_id%
ControlSetText, Edit1, %f_path%, ahk_id %f_window_id%
ControlSend, Edit1, {Enter}, ahk_id %f_window_id%
Sleep, 100 ; It needs extra time on some dialogs or in some cases.
;now RESTORE the filename in that text field. I don't like doing it this way...
ControlSetText, Edit1, %f_text%, ahk_id %f_window_id%
;msgbox, AFTER:`n f_path: %f_path%`n f_class: %f_class%`n f_Edit1Pos: %f_Edit1Pos%
ControlFocus, DirectUIHWND2, ahk_id %f_window_id% ;to try to get the focus back into the center area, so you can now type letters and have it go to a file or fodler, rather than try to SEARCH or try to change the FILE NAME by default.
return
}
; else fall through to the bottom of the subroutine to take standard action.
}
;for some reason, the following code just doesn't work well at all.
/*
else if f_class in ExploreWClass,CabinetWClass ; In Explorer, switch folders.
{
tooltip, f_class is %f_class% and f_window_ID is %f_window_id%
if f_Edit1Pos <> ; And it has an Edit1 control.
{
Tippy2("EXPLORER WITH EDIT1 only 2 lines of code here....", 1000)
ControlSetText, Edit1, %f_path%, ahk_id %f_window_id%
msgbox, ControlSetText happened. `nf_class is %f_class% and f_window_ID is %f_window_id%`nAND f_Edit1Pos is %f_Edit1Pos%
; Tekl reported the following: "If I want to change to Folder L:\folder
; then the addressbar shows http://www.L:\folder.com. To solve this,
; I added a {right} before {Enter}":
ControlSend, Edit1, {Right}{Enter}, ahk_id %f_window_id%
return
}
; else fall through to the bottom of the subroutine to take standard action.
}
*/
else if f_class = ConsoleWindowClass ; In a console window, CD to that directory
{
WinActivate, ahk_id %f_window_id% ; Because sometimes the mclick deactivates it.
SetKeyDelay, 0 ; This will be in effect only for the duration of this thread.
IfInString, f_path, : ; It contains a drive letter
{
StringLeft, f_path_drive, f_path, 1
Send %f_path_drive%:{enter}
}
Send, cd %f_path%{Enter}
return
}
ending2:
; Since the above didn't return, one of the following is true:
; 1) It's an unsupported window type but f_AlwaysShowMenu is y (yes).
; 2) It's a supported type but it lacks an Edit1 control to facilitate the custom
; action, so instead do the default action below.
Tippy2("end was reached.",333)
;SoundBeep, 800, 300 ;this is nice but the whole damn script WAITS for the sound to finish before it continues...
; Run, Explorer %f_path% ; Might work on more systems without double quotes.
;msgbox, f_path is %f_path%
; SplitPath, f_path, , OutDir, , ,
; var := InStr(FileExist(OutDir), "D")
; if (var = 0)
; msgbox, directory does not exist
; else if var = 1
Run, %f_path% ; I got rid of the "Explorer" part because it caused redundant windows to be opened, rather than just switching to the existing window
;else
; msgbox,,,Directory does not exist,1
instantExplorerEnd:
}
;end of instantexplorer()
;BEGIN INSTANT APPLICATION SWITCHER SCRIPTS;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#IfWinActive
windowSaver()
{
WinGet, lolexe, ProcessName, A
WinGetClass, lolclass, A ; "A" refers to the currently active window
global savedCLASS = "ahk_class "lolclass
global savedEXE = lolexe ;is this the way to do it? IDK.
;msgbox, %savedCLASS%
;msgbox, %savedEXE%
}
;SHIFT + macro key G14
global savedCLASS = "ahk_class Notepad++"
global savedEXE = "notepad++.exe"
switchToSavedApp(savedCLASS)
{
;msgbox,,, savedCLASS is %savedCLASS%,0.5
;msgbox,,, savedexe is %savedEXE%,0.5
if savedCLASS = ahk_class Notepad++
{
;msgbox,,, is notepad++,0.5
if WinActive("ahk_class Notepad++")
{
sleep 5
Send ^{tab}
}
}
;msgbox,,,got to here,0.5
windowSwitcher(savedCLASS, savedEXE)
}
back(){
;; if WinActive("ahk_class MozillaWindowClass")
;tooltip, baaaack
if WinActive("ahk_exe firefox.exe")
Send ^+{tab}
if WinActive("ahk_class Chrome_WidgetWin_1")
Send ^+{tab}
if WinActive("ahk_class Notepad++")
Send ^+{tab}
if WinActive("ahk_exe Adobe Premiere Pro.exe")
Send ^!+b ;ctrl alt shift B is my shortcut in premiere for "go back"(in bins)(the project panel)
if WinActive("ahk_exe explorer.exe")
Send !{left} ;alt left is the explorer shortcut to go "back" or "down" one folder level.
if WinActive("ahk_class OpusApp")
sendinput, {F2} ;"go to previous comment" in Word.
}
;macro key 16 on my logitech G15 keyboard. It will activate firefox,, and if firefox is already activated, it will go to the next window in firefox.
switchToFirefox(){
sendinput, {SC0E8} ;scan code of an unassigned key. Do I NEED this?
IfWinNotExist, ahk_class MozillaWindowClass
Run, firefox.exe
if WinActive("ahk_exe firefox.exe")
{
WinGetClass, class, A
if (class = "Mozillawindowclass1")
msgbox, this is a notification
}
if WinActive("ahk_exe firefox.exe")
Send ^{tab}
else
{
;WinRestore ahk_exe firefox.exe
;WinActivate ahk_exe firefox.exe ;was winactivatebottom before...
WinActivatebottom ahk_class MozillaWindowClass ;was winactivatebottom before...
;sometimes winactivate is not enough. the window is brought to the foreground, but not put into FOCUS.
;the below code should fix that.
WinGet, hWnd, ID, ahk_class MozillaWindowClass
DllCall("SetForegroundWindow", UInt, hWnd)
}
}
#IfWinActive
;Press SHIFT and macro key 16, and it'll switch between different WINDOWS of firefox.
switchToOtherFirefoxWindow(){
;sendinput, {SC0E8} ;scan code of an unassigned key
Process, Exist, firefox.exe
;msgbox errorLevel `n%errorLevel%
If errorLevel = 0
Run, firefox.exe
else
{
GroupAdd, taranfirefoxes, ahk_class MozillaWindowClass
if WinActive("ahk_class MozillaWindowClass")
GroupActivate, taranfirefoxes, r
else
WinActivate ahk_class MozillaWindowClass
}
}
; This is a script that will always go to The last explorer window you had open.
; If explorer is already active, it will go to the NEXT last Explorer window you had open.
; CTRL Numpad2 is pressed with a single button stoke from my logitech G15 keyboard -- Macro key 17.
switchToExplorer(){
IfWinNotExist, ahk_class CabinetWClass
Run, explorer.exe
GroupAdd, taranexplorers, ahk_class CabinetWClass
if WinActive("ahk_exe explorer.exe")
GroupActivate, taranexplorers, r
else
WinActivate ahk_class CabinetWClass ;you have to use WinActivatebottom if you didn't create a window group.
}
; ;trying to activate these windows in reverse order from the above. it does not work.
; ^+F2::
; IfWinNotExist, ahk_class CabinetWClass
; Run, explorer.exe
; GroupAdd, taranexplorers, ahk_class CabinetWClass
; if WinActive("ahk_exe explorer.exe")
; GroupActivate, taranexplorers ;but NOT most recent.
; else
; WinActivatebottom ahk_class CabinetWClass ;you have to use WinActivatebottom if you didn't create a window group.
; Return
;closes all explorer windows :/
;^!F2 -- for searchability
closeAllExplorers()
{
WinClose,ahk_group taranexplorers
}
switchToPremiere(){
IfWinNotExist, ahk_class Premiere Pro
{
;Run, Adobe Premiere Pro.exe
;Adobe Premiere Pro CC 2017
; Run, C:\Program Files\Adobe\Adobe Premiere Pro CC 2017\Adobe Premiere Pro.exe ;if you have more than one version instlaled, you'll have to specify exactly which one you want to open.
Run, Adobe Premiere Pro.exe
}
if WinActive("ahk_class Premiere Pro")
{
IfWinNotExist, ahk_exe notepad++.exe
{
Run, notepad++.exe
sleep 200
}
WinActivate ahk_exe notepad++.exe ;so I have this here as a workaround to a bug. Sometimes Premeire becomes unresponsive to keyboard input. (especially after timeline scrolling, especially with a playing video.) Switching to any other application and back will solve this problem. So I just hit the premiere button again, in those cases.g
sleep 10
WinActivate ahk_class Premiere Pro
}
else
WinActivate ahk_class Premiere Pro
}
switchToWord()
{
Process, Exist, WINWORD.EXE
;msgbox errorLevel `n%errorLevel%
If errorLevel = 0
Run, WINWORD.EXE
else
{
IfWinExist, Microsoft Office Word, OK ;checks to see if the annoying "do you want to continue searching from the beginning of the document" dialouge box is present.
sendinput, {escape}
else if WinActive("ahk_class OpusApp")
sendinput, {F3} ;set to "go to next comment" in Word.
else
WinActivate ahk_class OpusApp
}
}
switchWordWindow()
{
; Process, Exist, WINWORD.EXE
; ;msgbox errorLevel `n%errorLevel%
; If errorLevel = 0
; Run, WINWORD.EXE
; else
; {
GroupAdd, taranwords, ahk_class OpusApp
if WinActive("ahk_class OpusApp")
GroupActivate, taranwords, r
else
WinActivate ahk_class OpusApp
; }
}
switchToChrome()
{
IfWinNotExist, ahk_exe chrome.exe
Run, chrome.exe
if WinActive("ahk_exe chrome.exe")
Sendinput ^{tab}
else
WinActivate ahk_exe chrome.exe
}
switchToStreamDeck(){
IfWinNotExist, ahk_exe StreamDeck.exe
{
Run, C:\Program Files\Elgato\StreamDeck\StreamDeck.exe
}
else
{
WinActivate ahk_exe StreamDeck.exe
}
}
#IfWinActive
windowSwitcher(theClass, theEXE)
{
;msgbox,,, switching to `nsavedCLASS = %theClass% `nsavedEXE = %theEXE%, 0.5
IfWinNotExist, %theClass%
Run, % theEXE
if not WinActive(theClass)
WinActivate %theClass%
}
sortExplorerByName(){
IfWinActive, ahk_class CabinetWClass
{
;Send,{LCtrl down}{NumpadAdd}{LCtrl up} ;expand name field
send {alt}vo{enter} ;sort by name
;tippy2("sort Explorer by name")
}
}
sortExplorerByDate(){
IfWinActive, ahk_class CabinetWClass
{
;Send,{LCtrl down}{NumpadAdd}{LCtrl up} ;expand name field
send {alt}vo{down}{enter} ;sort by date modified, but it functions as a toggle...
;tippy2("sort Explorer by date")
}
}
;---------------------
ExplorerViewChange_Window(explorerHwnd)
{
;https://autohotkey.com/boards/viewtopic.php?t=28304
if (!explorerHwnd)
return
;msgbox,,, % explorerHwnd, 0.5
Windows := ComObjCreate("Shell.Application").Windows
for window in Windows
if (window.hWnd == explorerHwnd)
sFolder := window.Document
;sFolder.ShellView := 1
sFolder.CurrentViewMode := 4 ; Details
;tooltip % sFolder.CurrentViewMode
;sFolder.SORTCOLUMNS := PKEY_ItemNameDisplay, SORT_DESCENDING, bsssssss
}
;;;must look through that thread to find the direct "sort by name, sort by date" thingies.
ExplorerViewChange_List(explorerHwnd)
{
if (!explorerHwnd)
return
;msgbox,,, % explorerHwnd, 0.5
Windows := ComObjCreate("Shell.Application").Windows
for window in Windows
if (window.hWnd == explorerHwnd)
sFolder := window.Document
if (sFolder.CurrentViewMode == 8)
sFolder.CurrentViewMode := 6 ; Tiles
else if (sFolder.CurrentViewMode == 6)
sFolder.CurrentViewMode := 4 ; Details
else if (sFolder.CurrentViewMode == 4)
sFolder.CurrentViewMode := 3 ; List
else if (sFolder.CurrentViewMode == 3) {
sFolder.CurrentViewMode := 2 ; Small icons
sFolder.IconSize := 16 ; Actually make the icons small...
} else if (sFolder.CurrentViewMode == 2) {
sFolder.CurrentViewMode := 1 ; Icons
sFolder.IconSize := 48 ; Medium icon size
} else if (sFolder.CurrentViewMode == 1) {
if (sFolder.IconSize == 256)
sFolder.CurrentViewMode := 8 ; Go back to content view
else if (sFolder.IconSize == 48)
sFolder.IconSize := 96 ; Large icons
else
sFolder.IconSize := 256 ; Extra large icons
}
ObjRelease(Windows)
tooltip % sFolder.CurrentViewMode
}
ExplorerViewChange_ICONS(explorerHwnd)
{
if (!explorerHwnd)
{
tooltip, exiting.
sleep 100
return
}
;msgbox,,, % explorerHwnd, 0.5
Windows := ComObjCreate("Shell.Application").Windows
for window in Windows
if (window.hWnd == explorerHwnd)
sFolder := window.Document
if (sFolder.CurrentViewMode >= 2) {
sFolder.CurrentViewMode := 1 ; icons
sFolder.IconSize := 256 ; make the icons big...
;tooltip, large 1
} else if (sFolder.CurrentViewMode == 1) {
if (sFolder.IconSize == 48){
sFolder.IconSize := 256
;tooltip, large
}
else if (sFolder.IconSize == 256){
sFolder.IconSize := 96
;tooltip, you are now at medium icons
}
else if (sFolder.IconSize == 96) {
sFolder.IconSize := 48 ; smallish icons
;tooltip, you are now at smallish icons
}
else {
sFolder.CurrentViewMode := 1
sFolder.IconSize := 256
;tooltip, reset
}
}
;tooltip % sFolder.IconSize
;tooltip, %explorerHwnd%
;sleep 100
;tooltip, % sFolder.CurrentViewMode
}
; ExplorerViewChange_ICONS(explorerHwnd)
; {
; if (!explorerHwnd)
; {
; tooltip, exiting.
; sleep 100
; return
; }
; ;msgbox,,, % explorerHwnd, 0.5
; Windows := ComObjCreate("Shell.Application").Windows
; for window in Windows
; if (window.hWnd == explorerHwnd)
; sFolder := window.Document
; if (sFolder.CurrentViewMode >= 2) {
; sFolder.CurrentViewMode := 1 ; Small icons
; sFolder.IconSize := 48 ; Actually make the icons small...
; } else if (sFolder.CurrentViewMode == 1) {
; if (sFolder.IconSize == 256){
; sFolder.CurrentViewMode := 2 ; Go back to small icons