-
Notifications
You must be signed in to change notification settings - Fork 18
/
open_shell_here.ahk
38 lines (31 loc) · 1.14 KB
/
open_shell_here.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
; ctrl+shift+p: open powershell at current folder location in file explorer
; run script as admin (reload if not as admin)
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%" ; Requires v1.0.92.01+
ExitApp
}
#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
#IfWinActive ahk_class CabinetWClass
^+p::
pwshHere()
return
#IfWinActive
pwshHere(){
If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass") {
If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass") {
WinHWND := WinActive()
For win in ComObjCreate("Shell.Application").Windows
If (win.HWND = WinHWND) {
dir := SubStr(win.LocationURL, 9) ; remove "file:///"
dir := RegExReplace(dir, "%20", " ")
Break
}
}
Run, pwsh, % dir ? dir : A_Desktop
}
}