Hi, I'm new to using AHK and am not the most experienced with it, but I was wondering if there is a way, similar to how the command prompt works, to create a GUI in AHK which can display the working directory and navigate your PC. For example in cmd, the default working directory is C:\Users\User, and you can use tab to autocomplete the different folders/files in that directory, use dir to list all the files and folders in it, as well as cd to navigate deeper into the folder and further back out. From looking through the documentations I have seen ways of renaming files, opening files and the like which I was thinking of implementing but I was wondering if there is a way to navigate explorer, as well as find all the subfolders or files in that directory.
Thanks
loki
File Explorer GUI in AHK
-
- Posts: 1
- Joined: 17 Jun 2021, 22:52
Re: File Explorer GUI in AHK
FileSelectFile for files and FileSelectFolder for folders [but I really prefer this one instead as it provides more selecting options for folders].
Example on how to use SelectFolderEx()
Or alternatively you can use this custom File/Folder explorer, and also you can find provided examples there in case you wanted to try this last one.
Example on how to use SelectFolderEx()
Code: Select all
Msgbox % "You have selected this location: '" SelectFolderEx(StartingFolder := "", Prompt := "Please a folder", OwnerHwnd := 0, OkBtnLabel := "Yeah!") "'"
; ==================================================================================================================================
; Shows a dialog to select a folder.
; Depending on the OS version the function will use either the built-in FileSelectFolder command (XP and previous)
; or the Common Item Dialog (Vista and later).
; Parameter:
; StartingFolder - the full path of a folder which will be preselected.
; Prompt - a text used as window title (Common Item Dialog) or as text displayed withing the dialog.
; ---------------- Common Item Dialog only:
; OwnerHwnd - HWND of the Gui which owns the dialog. If you pass a valid HWND the dialog will become modal.
; BtnLabel - a text to be used as caption for the apply button.
; Return values:
; On success the function returns the full path of selected folder; otherwise it returns an empty string.
; MSDN:
; Common Item Dialog -> msdn.microsoft.com/en-us/library/bb776913%28v=vs.85%29.aspx
; IFileDialog -> msdn.microsoft.com/en-us/library/bb775966%28v=vs.85%29.aspx
; IShellItem -> msdn.microsoft.com/en-us/library/bb761140%28v=vs.85%29.aspx
; ==================================================================================================================================
SelectFolderEx(StartingFolder := "", Prompt := "", OwnerHwnd := 0, OkBtnLabel := "") {
Static OsVersion := DllCall("GetVersion", "UChar")
, IID_IShellItem := 0
, InitIID := VarSetCapacity(IID_IShellItem, 16, 0)
& DllCall("Ole32.dll\IIDFromString", "WStr", "{43826d1e-e718-42ee-bc55-a1e261c37bfe}", "Ptr", &IID_IShellItem)
, Show := A_PtrSize * 3
, SetOptions := A_PtrSize * 9
, SetFolder := A_PtrSize * 12
, SetTitle := A_PtrSize * 17
, SetOkButtonLabel := A_PtrSize * 18
, GetResult := A_PtrSize * 20
SelectedFolder := ""
If (OsVersion < 6) { ; IFileDialog requires Win Vista+, so revert to FileSelectFolder
FileSelectFolder, SelectedFolder, *%StartingFolder%, 3, %Prompt%
Return SelectedFolder
}
OwnerHwnd := DllCall("IsWindow", "Ptr", OwnerHwnd, "UInt") ? OwnerHwnd : 0
If !(FileDialog := ComObjCreate("{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}", "{42f85136-db7e-439c-85f1-e4075d135fc8}"))
Return ""
VTBL := NumGet(FileDialog + 0, "UPtr")
; FOS_CREATEPROMPT | FOS_NOCHANGEDIR | FOS_PICKFOLDERS
DllCall(NumGet(VTBL + SetOptions, "UPtr"), "Ptr", FileDialog, "UInt", 0x00002028, "UInt")
If (StartingFolder <> "")
If !DllCall("Shell32.dll\SHCreateItemFromParsingName", "WStr", StartingFolder, "Ptr", 0, "Ptr", &IID_IShellItem, "PtrP", FolderItem)
DllCall(NumGet(VTBL + SetFolder, "UPtr"), "Ptr", FileDialog, "Ptr", FolderItem, "UInt")
If (Prompt <> "")
DllCall(NumGet(VTBL + SetTitle, "UPtr"), "Ptr", FileDialog, "WStr", Prompt, "UInt")
If (OkBtnLabel <> "")
DllCall(NumGet(VTBL + SetOkButtonLabel, "UPtr"), "Ptr", FileDialog, "WStr", OkBtnLabel, "UInt")
If !DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", OwnerHwnd, "UInt") {
If !DllCall(NumGet(VTBL + GetResult, "UPtr"), "Ptr", FileDialog, "PtrP", ShellItem, "UInt") {
GetDisplayName := NumGet(NumGet(ShellItem + 0, "UPtr"), A_PtrSize * 5, "UPtr")
If !DllCall(GetDisplayName, "Ptr", ShellItem, "UInt", 0x80028000, "PtrP", StrPtr) ; SIGDN_DESKTOPABSOLUTEPARSING
SelectedFolder := StrGet(StrPtr, "UTF-16"), DllCall("Ole32.dll\CoTaskMemFree", "Ptr", StrPtr)
ObjRelease(ShellItem)
} }
If (FolderItem)
ObjRelease(FolderItem)
ObjRelease(FileDialog)
Return SelectedFolder
}
Re: File Explorer GUI in AHK
u can embed an explorer
https://www.autohotkey.com/boards/viewtopic.php?f=81&t=82613
but the GUI navigation ull have to figure out urself
https://www.autohotkey.com/boards/viewtopic.php?f=81&t=82613
but the GUI navigation ull have to figure out urself
Who is online
Users browsing this forum: Google [Bot], Ineedhelplz, Spawnova and 234 guests