forked from TaranVH/2nd-keyboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Almost_All_Windows_Functions.ahk
2628 lines (2137 loc) · 79.8 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.
; just scroll to the top of this page and follow the instructions.)
;https://autohotkey.com/boards/viewtopic.php?f=6&t=26947&p=139114#p139114
;alternatively, you can just delete the 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%,,,9
SetTimer, notip2, %wait% ;--in 1/3 seconds by default, remove the tooltip
}
notip2:
ToolTip,,,,9
;removes the tooltip
return
tooltip, yello
;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/
;; I'm seeing some excellent sounding scripts in here which i might wish to take for myself:
; https://github.com/func-github/AHK-Windows-Enhancement
; oh just kidding, they are in the TO DO section... they don't actually exist...
;this is (was?) my multiple clipboard function.
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
}
;this is the new way I'm gonna do multiple clipboards:
; code is from:
; https://autohotkey.com/board/topic/32265-multiple-clipboards/
; ; Hotkeys
; ^Numpad1::Copy(1)
; ^Numpad4::Paste(1)
Copy(clipboardID)
{
global ; All variables are global by default
local oldClipboard := ClipboardAll ; Save the (real) clipboard
Clipboard = ; Erase the clipboard first, or else ClipWait does nothing
Send ^c
ClipWait, 2, 1 ; Wait 1s until the clipboard contains any kind of data
if ErrorLevel
{
Clipboard := oldClipboard ; Restore old (real) clipboard
return
}
ClipboardData%clipboardID% := ClipboardAll
Clipboard := oldClipboard ; Restore old (real) clipboard
}
Cut(clipboardID)
{
global ; All variables are global by default
local oldClipboard := ClipboardAll ; Save the (real) clipboard
Clipboard = ; Erase the clipboard first, or else ClipWait does nothing
Send ^x
ClipWait, 2, 1 ; Wait 1s until the clipboard contains any kind of data
if ErrorLevel
{
Clipboard := oldClipboard ; Restore old (real) clipboard
return
}
ClipboardData%clipboardID% := ClipboardAll
Clipboard := oldClipboard ; Restore old (real) clipboard
}
Paste(clipboardID)
{
global
local oldClipboard := ClipboardAll ; Save the (real) clipboard
Clipboard := ClipboardData%clipboardID%
Send ^v
Clipboard := oldClipboard ; Restore old (real) clipboard
oldClipboard =
}
RemoveDashes()
{
SetKeyDelay, 0
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)
NewClipboard := StrReplace(NewClipboard, "-", A_Space)
NewClipboard := StrReplace(NewClipboard, "_", A_Space)
;;NewClipboard := SubStr(NewClipboard, 1, -13)
; use that if you want to remove the junk at the end. Go from:
; hit glass bottle hit bounce solid wood MyGJ8w4u.wav
; to
; hit glass bottle hit bounce solid wood
; and the .wav is automatically put back, fortunately.
;note to self, add this kinda thing to the AHK dopcumentation
; https://www.autohotkey.com/docs/commands/SubStr.htm
; StringReplace, NewClipboard, NewClipBoard, "-", A_Space, All
; StringReplace, NewClipboard, NewClipBoard, "_", A_Space, All
sleep 2
SendInput {Raw}%NewClipboard% ;this does it
Clipboard := ClipSaved ;Restore the clipboard
ClipSaved = ;Free the memory in case the clipboard was very large.
;return NewClipboard
return
}
checkFullness()
{
; DriveSpaceFree, OutputVar, Z:\
DriveSpaceFree, OutputVar, \\10.20.0.27\Users
If (OutputVar < 1000000)
{
msgbox, Whonnock has only %OutputVar% Megabytes remaining
}
}
/*
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. lolol.
;=============
;Macro Key G1, probably.
search(){
;sleep 13
keywait, %A_PriorKey% ;waits for the key that called this function to be RELEASED.
; the time to wait is supposed to be 5ms, but WHO KNOWS what iCue might actaully do.
if winactive("ahk_exe Adobe Premiere Pro.exe")
{
if IsFunc("effectsPanelType") {
Func := Func("effectsPanelType")
RetVal := Func.Call(directory,"")
;;I'm doing it in this weird way just in case the function is not available -- this means it won't screw anything up.
}
;effectsPanelType("") ;set to macro key G1 on my logitech G15 keyboard.
;This just CLEARS the effects panel search bar and selects it so that you can type something in yourself. Or maybe it merely highlights what it already there -- whatever.
}
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
}
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;This friggin beautiful code is from this thread:
;https://autohotkey.com/board/topic/121208-windows-explorer-get-folder-path/?p=687189
;another version of this function exists in filemover.ahk , but i think it's not used at all, lol.
Explorer_GetSelection(hwnd="") {
WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
WinGetClass class, ahk_id %hwnd%
if (process = "explorer.exe")
if (class ~= "Progman|WorkerW") {
;;if you're on the desktop
ControlGet, files, List, Selected Col1, SysListView321, ahk_class %class%
Loop, Parse, files, `n, `r
ToReturn .= A_Desktop "\" A_LoopField "`n"
} else if (class ~= "(Cabinet|Explore)WClass") {
for window in ComObjCreate("Shell.Application").Windows
if (window.hwnd==hwnd)
sel := window.Document.SelectedItems
for item in sel
ToReturn .= item.path "`n"
}
return Trim(ToReturn,"`n")
}
; ; ;How to call the above function
; ; F12::
; ; pathAndName := Explorer_GetSelection()
; ; ;SplitPath, pathAndName, fn
; ; SplitPath, pathAndName, nameOnly ,thePath
; ; MsgBox % "FileName :`t" nameOnly "`nPath :`t" thePath "`nFullName :`t" pathAndName
; ; clipboard = % thePath
; ; SoundBeep, 500, 200
; ; return
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;This one does not require you to select an item in the folder in order to work! Unfortunately, it does NOT work on Save As dialogs for whatever reason.
;; code was gotten from here https://autohotkey.com/board/topic/121208-windows-explorer-get-folder-path/?p=687189
;; and here https://www.autohotkey.com/boards/viewtopic.php?p=28751#p28751
Explorer_GetPath(hwnd="") {
WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
WinGetClass class, ahk_id %hwnd%
if (process = "explorer.exe")
if (class ~= "Progman|WorkerW") {
;;if you're on the desktop
ControlGet, files, List, Selected Col1, SysListView321, ahk_class %class%
Loop, Parse, files, `n, `r
ToReturn .= A_Desktop "\" A_LoopField "`n"
} else if (class ~= "(Cabinet|Explore)WClass") {
for window in ComObjCreate("Shell.Application").Windows
if (window.hwnd==hwnd)
lePath := window.Document.Folder.Self.Path
}
return lePath
}
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#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 ;;,#32770 ; 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. ;;update -- this is now mercifully obsolete!
thePath := Explorer_GetPath()
title = % thePath
;msgbox, the address is `n`n%title%
;;; OLD METHOD. The trouble with this is that by deleting the file, github constantly thinks there's a new .txt file and wants to upload it, no matter how many times I say to ignore the file. Because technically it's a new .txt file. IDK how it even knows that. File metadata??
; ;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")
;;;;/OLD METHOD
;;;NEW METHOD IS BELOW:
; Info:
; https://www.autohotkey.com/boards/viewtopic.php?t=62917
; https://www.autohotkey.com/boards/viewtopic.php?t=61853
file := FileOpen("C:\AHK\2nd-keyboard\Taran's_Windows_Mods\SavedExplorerAddress.txt", "w")
file.write(title)
file.close()
SavedExplorerAddress = %title%
;;;/NEW METHOD
msgbox, , , %title%`n`nwas saved as root!, 0.3
}
else
msgbox,,, this is PROBABLY 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()
openlatestFLAT(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")
}
;msgbox, directory is %directory%`n and filetype is %filetype%
Loop, Files,%directory%\*%filetype%, F
{
If (A_LoopFileTimeModified>Rec)
{
IfNotInString, A_LoopFileFullPath, ~$
FPath=%A_LoopFileFullPath%
Rec=%A_LoopFileTimeModified%
}
}
;msgbox, %Fpath%
Run %Fpath%
;run, firefox.exe %Fpath% ;;if you use this, it'll open up tons of firefox tabs, each one with a different word from the title. kind of interesting, but not at all what i want, lol.
;unfortunately, since I don't already know the tab NAME, (which is required for JEE_FirefoxFocusTabByName) I can't make it so that it'll merely switch to that tab if it's already open. Instead, it'll always open a new tab with this URL. Unfortunate, but fixing it is beyond my capabilities for now.
; ; 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 openlatestFLAT()
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 dialogs or whatever.
runexplorer(foo)
{
keywait, %A_PriorHotKey% ;to avoid stuck modifiers as usual
send {SC0E7} ;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 originally 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 originally 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.
;<<<<< i don't remember what the text below is talking about
;NEED to include this too: file locater 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
; >>>>>>>> idk what that was.
InstantExplorer(f_path,pleasePrepend := 0)
{
;this has been heavily modified from https://autohotkey.com/docs/scripts/FavoriteFolders.htm
;I feel ambivilant about this line. It'll be more stable, but it'll be a bit sloooowerrrr!
keywait, %A_priorhotkey% ;should there be a timeout clause? this still works even when launched with no hotkey, hmm.
sendinput, {blind}{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. Also, this is helpful for debugging.
;msgbox, hello
if pleasePrepend = 1 ;this is for the changeable per-project folder shortcuts
{
FileRead, SavedExplorerAddress, C:\AHK\2nd-keyboard\Taran's_Windows_Mods\SavedExplorerAddress.txt
;msgbox, current f_path is %f_path%
if f_path =
{
; if f_path is BLANK, then we don't want to add a \ onto the end just by itself, as that will be done later!
;msgbox, I did not add a blank f_path.
f_path = %SavedExplorerAddress%
}
else
f_path = %SavedExplorerAddress%\%f_path% ;there is no need to use . to concatenate
;msgbox, new f_path is %f_path%
;SUPER IMPORTANT NOTE - you must have explorer show the entire path in the title bar, or this doesn't work. I do need a better way to get that information. Something DLL based or whatever.
}
;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 FULL final folder name because it gets cropped off
;Keyshower(f_path,"InstExplor")
if IsFunc("Keyshower") {
Func := Func("Keyshower")
RetVal := Func.Call(f_path,"InstExplor")
}
;;;NO LONGER IMPORTANT: YOU NEED TO GO INTO WINDOWS' FOLDER OPTIONS > VIEW > AND CHECK "DISPLAY THE FULL PATH IN THE TITLE BAR" OR THIS WON'T WORK.
;;;UPDATE: THE INSTRUCTION ABOVE ARE OBSOLETE NOW, I'VE FIGURED OUT A BETTER WAY TO DO GET THAT INFO! (It uses the windows API stuff that i have access to through AHK)
instantExplorerTryAgain:
if !FileExist(f_path)
{
;MsgBox,,, %f_path%`nNo such path exists`, but we will go down in folders until it does.,1.0
if InStr(f_path, "\"){
FoundPos := InStr(f_path, "\", , StartingPos := 0, Occurrence := 1)
;msgbox % FoundPos
Length := StrLen(f_path)
;StringLeft, OutputVar, InputVar, Count
trimThis := Length - FoundPos
;msgbox % trimThis
NewString := SubStr(f_path, 1, FoundPos-1)
;msgbox, NewString is %NewString%
f_path := NewString
GOTO, instantExplorerTryAgain
;oh my god this code is so sloppy, it's great. And this is like, one of my best ever functions. I'm not even kidding. I use it like 20x an hour.
}
else
{
MsgBox,,, %f_path%`n`nNo such path exists.,1.0
GOTO, instantExplorerEnd
}
}
f_path = %f_path%\ ;;THIS ADDS A \ AT THE VERY END OF THE FILE PATH, FOR THE SAKE OF OLD-STYLE SAVE AS DIALOUGE BOXES WHICH REQUIRE THEM IN ORDER TO UPDATE THE FOLDER PATH WHEN IT IS INSERTED INTO Edit1.
;msgbox, f_path is currently %f_path% ;just debugging as usual
f_path := """" . f_path . """" ;this adds quotation marks around everything so that it works as a string, not a variable.
;but also, the old style still dopesn't like the quotation marks, and I'm not sure how to detect it since i know almost nothing about it. ho hum. But it does have ClassNN: SysListView321 which MAYBE i could use with this code https://autohotkey.com/board/topic/9362-detect-opensave-dialog/ but i dont know. saving this for later.
;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 = EVERYTHING ; It's Everything search. I want to put the fodler name in quotes in the main field, because that's how you search a subdirectory.
{
ControlGetPos, f_Edit1Pos, f_Edit1PosY,,, Edit1, ahk_id %f_window_id%
;msgbox, this is Everything search`nf_Edit1Pos = %f_Edit1Pos%
if f_Edit1Pos <> ; we know it should have an Edit1 control.
{
ControlFocus, Edit1, ahk_id %f_window_id%
WinActivate ahk_id %f_window_id%
f_path := f_path . " " ;this adds a space to the end, so i can type the actual thing to search for afterwards.
ControlSetText, Edit1, %f_path%, ahk_id %f_window_id%
;(it adds a space to the end too.)
sleep 2
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.
send, {end} ;to get to the end of the search box. best place to search for the actual thing i want to find.
return
}
GOTO, instantExplorerEnd
}
if f_class = #32770 ; It's a dialog.
{
if WinActive("ahk_exe waifu2x-caffe.exe")
{
tooltip, you are inside of Waifu2x
GOTO, ending2
;this will open an explorer window rather than trying to change waifu2x's input path as it otherwise would.
}
if WinActive("ahk_exe Adobe Premiere Pro.exe")
{
tooltip, you are inside of premiere
if (f_title = "Export Settings") or if (f_title = "Link Media")
{
msgbox,,,you are in Premiere's export window or link media 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 InStr(f_title, "Link Media to") ;Note that you must have "use media browser to locate files" UNCHECKED because it is GARBAGE.
{
tooltip, you are inside Premieres relinker.
; This requires custom code, because the EditX boxes are different:
; last path = Edit1
; filename = Edit2
; address bar = Edit3
ControlFocus, Edit2, ahk_id %f_window_id%
tooltip, you are inside the link media thingy
sleep 1
WinActivate ahk_id %f_window_id%
sleep 1
ControlGetText, f_text, Edit2, ahk_id %f_window_id%
sleep 1
ControlSetText, Edit2, %f_path%, ahk_id %f_window_id%
ControlSend, Edit2, +{Enter}, ahk_id %f_window_id%
Sleep, 100 ; It needs extra time on some dialogs or in some cases.
ControlSetText, Edit2, %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 (f_title = "Save As") or if (f_title = "Save Project")
{
;;;ControlGetPos, f_Edit1Pos, f_Edit1PosY,,, Edit1, ahk_id %f_window_id%
;ControlFocus, Edit2, ahk_id %f_window_id% ;we know that Edit2 is the address bar in this case. So there's no need to use Edit1 and then swap back in the filename.
ControlFocus, Edit1, ahk_id %f_window_id%
;msgbox,,,you are hereee,0.5
tooltip, you are here
sleep 1
;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%
sleep 1
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
tooltip, do you make it this far
tooltip, the answer is no. the RETURN ends it properly
GOTO, instantExplorerEnd
;But i have the GOTO just in case, hahahaha
}
}
; stuff beyond here is NOT in premiere
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%
sleep 2
ControlSetText, Edit1, %f_path%, ahk_id %f_window_id%
sleep 3
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%
sleep 2
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:
tooltip,
}
;end of instantexplorer()
; future development
;