Instantly share code, notes, and snippets.
Created
January 30, 2017 20:31
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save TaranVH/5a7522d3c5bb5ef489ab0bbc21ce689f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;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. | |
;~~~~BEGINNING OF 3RD KEYBOARD (just a USB numpad) USING INTERCEPTOR~~~~~~~~ | |
#if (getKeyState("F22", "P")) | |
;and if <premiere> is running <--add that later | |
F22:: | |
FileRead, SavedExplorerAddress, C:\Users\TaranWORK\Documents\GitHub\2nd-keyboard\Taran's Windows Mods\SavedExplorerAddress.txt | |
return | |
;Z:\Linus\1. Linus Tech Tips\Pending\Luke Personal Rig Update | |
NumpadDot::InstantExplorer(SavedExplorerAddress . "\" . "delivery" . "\" ) | |
numpad0::InstantExplorer(SavedExplorerAddress . "\" . "thumbnail" . "\" ) | |
numpad1::InstantExplorer(SavedExplorerAddress . "\" . "music" . "\" ) | |
numpad2::InstantExplorer(SavedExplorerAddress . "\" . "graphics" . "\" ) | |
numpad3::InstantExplorer(SavedExplorerAddress . "\" . "Extra videos" . "\" ) | |
numpad4::InstantExplorer(SavedExplorerAddress . "\" . "music" . "\" ) | |
numpad5::InstantExplorer(SavedExplorerAddress . "\" . "L-Roll" . "\" ) | |
numpad6::InstantExplorer(SavedExplorerAddress . "\" . "all footage" . "\" ) | |
numpad7::InstantExplorer(SavedExplorerAddress) ;MAIN, ROOT FOLDER | |
numpad8::InstantExplorer(SavedExplorerAddress . "\" . "scripts" . "\" ) | |
numpad9::InstantExplorer(SavedExplorerAddress . "\" . "scripts" . "\" ) ; should open latest script | |
NumpadDiv::InstantExplorer(SavedExplorerAddress . "\" . "project" . "\" ) | |
NumpadMult::tooltip, mult - open latest project i guess | |
NumpadAdd:: | |
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. | |
Return | |
^numpadadd::WinClose,ahk_group taranexplorers | |
;NumpadSub::tooltip, subtract - check autosave maybe | |
;SC00E::tooltip, backspace | |
^numpad7:: | |
;msgbox, this will copy the currently highlighted text and replace the contents of C:\Users\TaranWORK\Documents\GitHub\2nd-keyboard\Taran's Windows Mods\SavedExplorerAddress.txt with it. | |
sendinput, ^a | |
sleep 20 | |
SendInput, {Shift Down}{Shift Up}{Ctrl Down}{c Down} | |
sleep 20 | |
SendInput, {c up}{Ctrl up} | |
sleep 20 | |
FileDelete, C:\Users\TaranWORK\Documents\GitHub\2nd-keyboard\Taran's Windows Mods\SavedExplorerAddress.txt | |
FileAppend, %clipboard% , C:\Users\TaranWORK\Documents\GitHub\2nd-keyboard\Taran's Windows Mods\SavedExplorerAddress.txt | |
msgbox, , , it worked, 1 | |
Return | |
numpadsub::^w | |
F4:: | |
Send {alt down} | |
sleep 10 | |
Send {F4} | |
sleep 10 | |
Send {alt up} | |
Return | |
#if | |
;~~~~~~~~~END OF 3RD KEYBOARD (just a USB numpad) USING INTERCEPTOR~~~~~~~~~~ | |
InstantExplorer(f_path) | |
{ | |
f_path := """" . f_path . """" ;this adds quotation marks around everything so that it works as a string, not a variable. | |
;msgbox, f_path is %f_path% | |
SoundBeep, 900, 400 | |
; 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% | |
if f_class in #32770,ExploreWClass,CabinetWClass ; Dialog or Explorer. | |
ControlGetPos, f_Edit1Pos, f_Edit1PosY,,, Edit1, ahk_id %f_window_id% | |
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. | |
{ | |
if f_Edit1Pos <> ; And it has an Edit1 control. | |
{ | |
; ControlClick, ClassNN Edit1 | |
; ControlFocus, ClassNN Edit1 | |
; ControlClick, Edit1 | |
; ControlFocus, Edit1, A | |
ControlFocus, Edit1, ahk_id %f_window_id% ;this is really important.... it doesn't work if you don't do this... | |
; 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% | |
return | |
} | |
; else fall through to the bottom of the subroutine to take standard action. | |
} | |
else if f_class in ExploreWClass,CabinetWClass ; In Explorer, switch folders. | |
{ | |
if f_Edit1Pos <> ; And it has an Edit1 control. | |
{ | |
ControlSetText, Edit1, %f_path%, ahk_id %f_window_id% | |
; 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 | |
} | |
; 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. | |
;msgbox, nothing else worked | |
; Run, Explorer %f_path% ; Might work on more systems without double quotes. | |
Run, %f_path% ; Might work on more systems without double quotes. | |
} | |
;end of instant explorer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment