Skip to content

Commit

Permalink
New features
Browse files Browse the repository at this point in the history
1. Added support for network folders
2. Added timeout confirmation
  • Loading branch information
skygate2012 committed Feb 26, 2024
1 parent f865924 commit 85c3716
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions ReplaceBrowseForFolder.ahk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Requires AutoHotkey v1.1.33+
;@Ahk2Exe-SetMainIcon ReplaceBrowseForFolder.ico
;@Ahk2Exe-SetVersion 1.2
;@Ahk2Exe-Base Unicode 32*
;@Ahk2Exe-PostExec "MPRESS.exe" "%A_WorkFileName%" -q -x, 0,, 1
;@Ahk2Exe-IgnoreBegin
Expand Down Expand Up @@ -93,35 +94,37 @@ SetPathForBrowseForFolder(TargetPath, DialogHwnd:=0x0) {
}
ControlGet, hctl, Hwnd,, SysTreeView321, % "ahk_id" DialogHwnd
RTV := new RemoteTreeview(hctl)
PathTree_Length := PathTree.Length()
For Index, Level in PathTree
{
hItem := RTV.GetHandleByText(Level)
If !hItem {
FurthestPath := ""
For Index, Level in PathTree
FurthestPath .= Level "\"
Throw Exception("Walk failed at: `n" FurthestPath, "RemoteTreeview.GetHandleByText")
Return
}
If (Index = PathTree_Length) {
RTV.SetSelection(hItem, 1)
} Else {
RTV.SetSelection(hItem, 0)
RTV.Expand(hItem)
Loop
hChild := RTV.GetChild(hItem)
Until hChild
T_Start := A_TickCount
Loop {
hItem := RTV.GetHandleByText(Level)
If hItem {
Break
} Else If (A_TickCount - T_Start >= 60000) {
Msgbox, 0x1004, , % "Been waiting for a minute. Abort?"
IfMsgBox, Yes
Return
Else
T_Start := A_TickCount
} Else If !WinExist("ahk_id" DialogHwnd) {
Return
}
}
RTV.SetSelection(hItem, 0)
RTV.Expand(hItem)
}
Loop
Controlsend, , {Enter}, % "ahk_id " DialogHwnd
Until !WinExist("ahk_id" DialogHwnd)
}

GetExplorerPathTree(FolderPath) {
Shell := ComObjCreate("Shell.Application")
Folder := Shell.NameSpace(FolderPath)
PathTree := []
Loop
PathTree.InsertAt(1, Folder.Title)
PathTree.InsertAt(1, Folder.Self.Name)
Until !(Folder := Folder.ParentFolder)
Return PathTree
}
Expand Down

0 comments on commit 85c3716

Please sign in to comment.