Code: Select all
#IfWinActive ahk_class CabinetWClass
#b::
ClipSaved := ClipboardAll
Send !d
Sleep 10
Send ^c
Run C:\Windows\System32\bash.exe, Max
Sleep 100
send cd %clipboard% {enter}
Clipboard := ClipSaved
ClipSaved =
return
#IfWinActive
Code: Select all
#IfWinActive ahk_class CabinetWClass
#b::
ClipSaved := ClipboardAll
Send !d
Sleep 10
Send ^c
Run C:\Windows\System32\bash.exe, Max
Sleep 100
send cd %clipboard% {enter}
Clipboard := ClipSaved
ClipSaved =
return
#IfWinActive
Here's something that works without using the clipboard:caracalgrey wrote:Does anyone know how I can make this code work or have a better way of doing this?
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input
#If ((expWnd := WinExist("ahk_class CabinetWClass ahk_id " . WinExist("A"))))
#b::
{
if ((path := getExplorerWindowPath(expWnd)))
Run C:\Windows\System32\bash.exe, %path%, Max
}
#If
return
getExplorerWindowPath(hwnd)
{
static IID_IShellFolder, STRRET, path, SIGDN_FILESYSPATH := 0x80058000
if (!VarSetCapacity(IID_IShellFolder))
VarSetCapacity(IID_IShellFolder, 16), DllCall("ole32\CLSIDFromString", "WStr", "{000214E6-0000-0000-C000-000000000046}", "Ptr", &IID_IShellFolder)
,VarSetCapacity(STRRET, 272), VarSetCapacity(path, 262 * (!!A_IsUnicode + 1))
shellWindows := ComObjCreate("Shell.Application").Windows
for window in shellWindows {
if (window.hwnd == hwnd) {
try {
isp := ComObjQuery(window, "{6d5140c1-7436-11ce-8034-00aa006009fa}")
tlb := ComObjQuery(isp, "{4C96BE40-915C-11CF-99D3-00AA004AE837}", "{000214E2-0000-0000-C000-000000000046}")
if (DllCall(NumGet(NumGet(tlb+0)+15*A_PtrSize), "Ptr", tlb, "Ptr*", isv) < 0)
throw
ifv := ComObjQuery(isv, "{cde725b0-ccc9-4519-917e-325d72fab4ce}")
if (DllCall(NumGet(NumGet(ifv+0)+5*A_PtrSize), "Ptr", ifv, "Ptr", &IID_IShellFolder, "Ptr*", isf) < 0)
throw
if (DllCall(NumGet(NumGet(isf+0)+11*A_PtrSize), "Ptr", isf, "Ptr", 0, "UInt", SIGDN_FILESYSPATH, "Ptr", &STRRET) < 0)
throw
if (DllCall("shlwapi\StrRetToBuf", "Ptr", &STRRET, "Ptr", 0, "Str", path, "UInt", 260))
throw
return path
} catch {
return 0
} finally {
for _, obj in [isf, ifv, isv, tlb, isp]
if (obj)
ObjRelease(obj)
}
}
}
return 0
}
Users browsing this forum: No registered users and 318 guests