Skip to content

Commit 85c3716

Browse files
committed
New features
1. Added support for network folders 2. Added timeout confirmation
1 parent f865924 commit 85c3716

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

ReplaceBrowseForFolder.ahk

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#Requires AutoHotkey v1.1.33+
22
;@Ahk2Exe-SetMainIcon ReplaceBrowseForFolder.ico
3+
;@Ahk2Exe-SetVersion 1.2
34
;@Ahk2Exe-Base Unicode 32*
45
;@Ahk2Exe-PostExec "MPRESS.exe" "%A_WorkFileName%" -q -x, 0,, 1
56
;@Ahk2Exe-IgnoreBegin
@@ -93,35 +94,37 @@ SetPathForBrowseForFolder(TargetPath, DialogHwnd:=0x0) {
9394
}
9495
ControlGet, hctl, Hwnd,, SysTreeView321, % "ahk_id" DialogHwnd
9596
RTV := new RemoteTreeview(hctl)
96-
PathTree_Length := PathTree.Length()
9797
For Index, Level in PathTree
9898
{
99-
hItem := RTV.GetHandleByText(Level)
100-
If !hItem {
101-
FurthestPath := ""
102-
For Index, Level in PathTree
103-
FurthestPath .= Level "\"
104-
Throw Exception("Walk failed at: `n" FurthestPath, "RemoteTreeview.GetHandleByText")
105-
Return
106-
}
107-
If (Index = PathTree_Length) {
108-
RTV.SetSelection(hItem, 1)
109-
} Else {
110-
RTV.SetSelection(hItem, 0)
111-
RTV.Expand(hItem)
112-
Loop
113-
hChild := RTV.GetChild(hItem)
114-
Until hChild
99+
T_Start := A_TickCount
100+
Loop {
101+
hItem := RTV.GetHandleByText(Level)
102+
If hItem {
103+
Break
104+
} Else If (A_TickCount - T_Start >= 60000) {
105+
Msgbox, 0x1004, , % "Been waiting for a minute. Abort?"
106+
IfMsgBox, Yes
107+
Return
108+
Else
109+
T_Start := A_TickCount
110+
} Else If !WinExist("ahk_id" DialogHwnd) {
111+
Return
112+
}
115113
}
114+
RTV.SetSelection(hItem, 0)
115+
RTV.Expand(hItem)
116116
}
117+
Loop
118+
Controlsend, , {Enter}, % "ahk_id " DialogHwnd
119+
Until !WinExist("ahk_id" DialogHwnd)
117120
}
118121

119122
GetExplorerPathTree(FolderPath) {
120123
Shell := ComObjCreate("Shell.Application")
121124
Folder := Shell.NameSpace(FolderPath)
122125
PathTree := []
123126
Loop
124-
PathTree.InsertAt(1, Folder.Title)
127+
PathTree.InsertAt(1, Folder.Self.Name)
125128
Until !(Folder := Folder.ParentFolder)
126129
Return PathTree
127130
}

0 commit comments

Comments
 (0)