AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

QuickDir

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
MsgBox



Joined: 17 Nov 2005
Posts: 179
Location: Leicester, UK

PostPosted: Tue Sep 12, 2006 10:33 pm    Post subject: QuickDir Reply with quote

Hello

Here is a script that I wrote because I have hundreds of folders within folders and found navigating them was taking forever...

Now its Lightning fast! Smile

Since the first posting it has morphed feature wise quite a bit and is now very stable.

Information is in the script.

QuickDir

Screenshots and description:

Add folder and edit window: Straight forward to use. Press button X or Esc to cancel.


Open dialogue: QuickDir is sized according to the size of the Open dialogue and stays in place even when moved. Press Esc to cancel or click cancel or "File Name" edit field in the dialogue. Right click or press the Apps key to access the context menu.


Xplorer2: In Xplorer2 and Windows Explorer, QuickDir docks and is sized to the address bar. Press Esc to cancel or click the address bar edit field. (If no address bar is found or is too small to dock the gui, QuickDir will open in edit mode)


Command Prompt: *** New ***


Windows Explorer: I don't use Explorer!


Editor:


New:
Code:
;______________________
; \____QuickDir_____/

; Coded by MsgBox.                                          Last Edit:- 13/05/07

; Bookmark your favourite folders/directories for lightning fast access.

; Works (but not exclusively) in:
;    Open/Save dialogues
;    Xplorer2
;    Windows Explorer
;    A43 **NEW**
;    Command Prompt **NEW**

; The QuickDir Gui attaches itself to the ListView control in Open/Save,
; and to the Address Bar in Xplorer2, A43 and Windows Explorer file managers.

; IMPORTANT: The ADDRESS BAR in your file manager MUST be visible (or at least 101px
; wide) for the QuickDir gui to attach it's self to. If it is not, or your file
; manager is not supported, QuickDir will open in EDIT MODE where double clicking
; or pressing enter will open the selected folder.


; FEATURES:-
;    (Via context menu)
;    Add a folder, keyword and alias.
;    Add currant folder.
;    Edit selected entry.
;    Delete selected entry.
;    Sort columns.
;    Show/Hide path column.
;    Edit QuickDir list file.
;    Backup QuickDir list file.
;    Keyboard navigation.
;  Run Editor.

;  There is no context menu in the editor (altsubmit conflicts with one of my other
;   scripts!....not needed anyway.)

;   All settings are saved (except gui size/pos and column order in the editor)

; TO USE:-

;         *** FOR BEST RESULTS SET UP A HOTKEY TO RUN THIS SCRIPT. ***

;    In your chosen app/dialogue press your hotkey to view your folder bookmarks.
;    Mouse:
;      Double click your chosen bookmark. Right click for menu options.
;    Keyboard:
;      Use Up/Down arrow keys to choose your bookmark then Enter. AppsKey for
;     menu options.
;     Enter a row number.
;    Use the context menu to add to, edit, sort the list etc...
;    To cancel the Gui press Esc, click in address bar (in Open/Save dialogue click
;   in the "File Name" edit field) or Exit in the context menu.

;  Resize the gui when visible by resizing the address bar.

;  To "Add This Directory" in a command window (Command Prompt) copy the path to
;  the clipboard first, then start QuickDir and choose the option from the menu.

;  Tip:   In Xplorer2, create a USER COMMAND to run the script and place the icon
;         next to the address bar for easy access.

#SingleInstance force
#NoTrayIcon
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
qdlFile = QuickDirList.txt
iniPath = QuickDir.ini
GoSub cfgLoad
If (runEditor) {
   runEditor = 0
   GoSub cfgSave
   App = None
   GoSub WinPos
   GoSub appNoneGui
   Return
   }
aClass=
(
ahk_class #32770
ahk_class ATL:ExplorerFrame
ahk_class ConsoleWindowClass
ahk_class ExploreWClass
ahk_class TfrmMain
)
Loop Parse, aClass, `n
{
   wClass := A_LoopField
   IfWinActive %wClass%
   {
      Gosub WinPos
      Break
      }
   }
IfWinNotActive %wClass%
{
   MsgBox 4, QuickDir, Your chosen application / dialogue is not supported...yet!`nPlease contact the author for inclusion.`n`nWould you like to run QuickDir in EDITOR mode?
   IfMsgBox No, ExitApp
   App = None
   GoSub WinPos
   }
If (wAdr < 100) {
   MsgBox 4, QuickDir, No "address bar" found or size is too small...`n`nWould you like to run QuickDir in EDITOR mode?
   IfMsgBox No, ExitApp
   App = None
   GoSub WinPos
}
If (App = "None") {
   GoSub appNoneGui
   Return
   }
Gui -Caption +Owner +AlwaysOnTop
Gui Margin, 0, 0
Gui Font, s8, Tahoma
Gui Add, ListView, w%w% h%h% -Hdr vDir gLVClick , #|Alias|Keyword|Path
Gui Add, Button, x-10 y -10 w1 h1 Default gbOK
Gosub FillListView
Gui Show, x%x% y%y% w%w% h%h%, QuickDir
Gosub ContextMenu
SetTimer Monitor, 50
Return

appNoneGui:
Gui 1:+AlwaysOnTop Resize
Gui 1:Margin, 0, 0
Gui 1:Font, s8, Tahoma
Gui 1:Add, Button, x0 y0 w0 h0 Default gnRun
Gui 1:Add, GroupBox, xm+5 ym+5 w106 h45 Section, Directory List
Gui 1:Add, Button, xs+10 ys+17 h20 gcmEditList, Ed&it
Gui 1:Add, Button, x+10 h20 gcmBackupList, &Backup
Gui 1:Add, GroupBox, x+15 ys  w152 h45 Section, Edit
Gui 1:Add, Button, xs+10 ys+17 h20 gcmInputGui, &Add
Gui 1:Add, Button, x+10 h20 gcmEditEntry, &Edit
Gui 1:Add, Button, x+18 h20 gcmConfirmRemove, &Delete
Gui 1:Font, s14, Tahoma
Gui 1:Add, Button, x+15 ym+10 w172 h41 Disabled, QuickDir - Editor
Gui 1:Font, s8, Tahoma
Gui 1:Add, ListView, xm yp+44 w%w% h%h% vDir gsBarText altSubmit, #|Alias|Keyword|Path
Gosub FillListView
Gui 1:Add, StatusBar
Gui  Show, Center, QuickDir - Double click or Enter to open selected.
Return

nRun:
GuiControlGet, FocusedControl, FocusV
IfNotEqual FocusedControl, Dir, Return
no := LV_GetNext(0, "Focused")
LV_GetText(Choice, no, 4)
Run %Choice%,, UseErrorLevel
If (ErrorLevel = ERROR) {
   MsgBox Cannot open " %Choice% "
   Return
   }
GoSub GuiEscape
Return

sBarText:
If (A_GuiEvent = "Normal" || A_GuiEvent = "I") {
   no := A_EventInfo
   LV_GetText(Choice, no, 4)
   SB_SetText(Choice)
   }
IfEqual A_GuiEvent, DoubleClick, GoSub nRun
Return

bOk:
GuiControlGet, FocusedControl, FocusV
IfNotEqual FocusedControl, Dir, Return
no := LV_GetNext(0, "Focused")
Gosub Go
Return

LVClick:
IfNotEqual A_GuiEvent, DoubleClick, Return
Gui Submit, NoHide
no := A_EventInfo
Gosub Go
Return

Go:
LV_GetText(Choice, no, 4)
If (App <> "CMD") {
   ControlSetText %adrBar%, %Choice%, %wClass%
   ControlFocus %adrBar%, %wClass%
   ControlSend %adrBar%, {Enter}, %wClass%
   }
Else {
   clipboard=
   clipboard := Choice
   WinActivate %wClass%
   Send chdir /d !{Space}ep{Enter}
}
Gosub GuiEscape
Return

FillListView:
FileRead list, %qdlFile%
Loop Parse, list, `n
{
   dir:=A_LoopField
   StringReplace dir, dir, `r,, A
   StringSplit div, dir, |
   Cnt:= LV_GetCount() +1
   LV_Add("", Cnt, div3, div2, div1)
   LV_ModifyCol(1, "20 Integer")
   LV_ModifyCol()
   If (!sPath)
      LV_ModifyCol(4, 0)
   }
If (cSort = 2)
   LV_ModifyCol(2, "Sort")
If (cSort = 3)
   LV_ModifyCol(3, "Sort")
If App = None
   LV_ModifyCol(4)
Return

GuiSize:
IfWinActive QuickDir - Double click or Enter to open selected.
   GuiControl, Move, Dir, % "w" . A_GuiWidth . " h" . A_GuiHeight -75
Else   GuiControl, Move, Dir, % "w" . w . " h" . h
Return

WinPos:
If (App = "None") {
   w = 450
   h = 300
   wadr = 101
   SetTimer Monitor, Off
   Return
   }
WinGetPos xO, yO, wO, hO, %wClass%
t := xO + yO + wO + hO
IfWinActive ahk_class ATL:ExplorerFrame
{
   App = X2                               ; Xplorer2.
   adrBar = Edit1
   adrSzCtrl = ReBarWindow321
   ControlGetPos xAdr, yAdr, wAdr,, ComboBox1, %wClass%
   x := xO + xAdr
   y := yO + yAdr +20   ; Put Gui below address bar.
   w := wAdr
   h := hO - yAdr -44   ; Minus height of address bar and status bar
   Return
   }
IfWinActive ahk_class #32770              ; "Open/Save".
{
   App = OS
   adrBar = Edit1
   ControlGetPos xAdr, yAdr, wAdr, hAdr, SysListView321, %wClass%
   x := xO + xAdr
   y := yO + yAdr
   w := wAdr
   h := hAdr
   Return
   }
IfWinActive ahk_class ConsoleWindowClass   ; Command prompt.
{
   App = CMD
   wAdr = %wO%
   adrSzCtrl=
   adrBar=
   x := xO + 5
   y := yO + 25
   w := wAdr - 10
   h := hO - 29
   Return
   }
IfWinActive ahk_class ExploreWClass       ; Windows Explorer.
{
   App = XP
   adrBar = Edit1
   adrSzCtrl = ReBarWindow321
   ControlGetPos xAdr, yAdr, wAdr, hAdr, ComboBox1, %wClass%
   x := xO + xAdr
   y := yO + yAdr +20
   w := wAdr
   h := hO - yAdr -44 ;300
   Return
   }
IfWinActive ahk_class TfrmMain            ; A43.
{
   App = A43
   adrBar = TTntEdit.UnicodeClass2
   adrSzCtrl = TPTSplitter2
   ControlGetPos xAdr, yAdr, wAdr, hAdr, TJamShellCombo.UnicodeClass2, %wClass%
   x := xO + xAdr
   y := yO + yAdr +20
   w := wAdr
   h := 300
   Return
   }
Return

Monitor:
If (App = "None") {
   SetTimer Monitor, Off
   Return
   }
IfWinNotExist %wClass%
{
   Gosub GuiEscape
   Return
   }
IfWinNotActive QuickDir
{
   IfWinNotActive %wClass%
   {
      Gosub GuiEscape
      Return
      }
   }
t1 := t
w1 := w
Sleep 20
CoordMode Mouse, Relative
MouseGetPos,,,, adrControl
GoSub WinPos
If GetKeyState("Lbutton", "P") && (adrControl = adrSzCtrl) {
   SetTimer Monitor, Off
   KeyWait LButton, U
   SetTimer Monitor, On
   GoSub Monitor
   }
If GetKeyState("Lbutton", "P") && (adrControl = adrBar)
   GoSub GuiEscape
If (t1 <> t) || (w1 <> w)
   Gui Show, x%x% y%y% w%w% h%h%, QuickDir
Return

GuiContextMenu:
IfEqual App, None, Return
Menu ContextMenu, Show
Return

ContextMenu:
Menu ContextMenu, Add, &Add This Directory, cmAddThisDir
Menu ContextMenu, Add, Add A &Directory, cmInputGui
Menu ContextMenu, Add
If (App <> "None") {
   Menu ContextMenu, Add, &Run Editor, cmrunEditor
   Menu ContextMenu, Add
   }
Menu ContextMenu, Add, &Edit This Entry, cmEditEntry
Menu ContextMenu, Add, Dele&te This Entry, cmConfirmRemove
Menu ContextMenu, Add
cSort := selectedMenuItem(cSort)
Menu ContextMenu, Add, Sort by &Number ( Path ! ), cmSortColumns
Menu ContextMenu, Add, Sort by Al&ias, cmSortColumns
Menu ContextMenu, Add, Sort by &Keyword, cmSortColumns
Menu ContextMenu, Check, %cSort%
Menu ContextMenu, Add
Menu ContextMenu, Add, Show &Path, cmShowPath
If (sPath)
   Menu ContextMenu, Check, Show &Path
Else
   Menu ContextMenu, UnCheck, Show &Path
Menu ContextMenu, Add
Menu ContextMenu, Add, Edit Directory &List, cmEditList
Menu ContextMenu, Add, &Backup Directory List, cmBackupList
Menu ContextMenu, Add
Menu ContextMenu, Add, E&xit, GuiEscape
IniRead cSort, %iniPath%, View, ColumnSort
Return

cmSortColumns:
cSort = %A_ThisMenuItem%
If (cSort = "Sort by &Number ( Path ! )") {
   Menu ContextMenu, Check, Sort by &Number ( Path ! )
   Menu ContextMenu, UnCheck, Sort by Al&ias
   Menu ContextMenu, UnCheck, Sort by &Keyword
   LV_ModifyCol(1, "Sort")
   cSort = 1
   }
If (cSort = "Sort by Al&ias") {
   Menu ContextMenu, Check, Sort by Al&ias
   Menu ContextMenu, UnCheck, Sort by &Number ( Path ! )
   Menu ContextMenu, UnCheck, Sort by &Keyword
   LV_ModifyCol(2, "Sort")
   cSort = 2
   }

If (cSort = "Sort by &Keyword") {
   Menu ContextMenu, Check, Sort by &Keyword
   Menu ContextMenu, UnCheck, Sort by &Number ( Path ! )
   Menu ContextMenu, UnCheck, Sort by Al&ias
   LV_ModifyCol(3, "Sort")
   cSort = 3
   }
GoSub cfgSave
Return

cmrunEditor:
runEditor = 1
GoSub cfgSave
Reload
Return

cmShowPath:
sPath := !sPath
If (sPath) {
   Menu ContextMenu, ToggleCheck, Show &Path
   LV_ModifyCol(4)
   }
Else {
   Menu ContextMenu, ToggleCheck, Show &Path
   LV_ModifyCol(4, 0)
   }
GoSub cfgSave
Return

cmEditEntry:
Gosub lvRowInfo
Gosub cmInputGui
GuiControl,2:, Alias, %lvAlias%
GuiControl,2:ChooseString, KeyWord, %lvKeyWord%
GuiControl,2:, dPath, %lvPath%
ReplaceEntry = 1
Return

lvRowInfo:
lvNo := LV_GetNext(0, "Focused")
LV_GetText(lvAlias, lvNo,2)
LV_GetText(lvKeyWord, lvNo,3)
LV_GetText(lvPath, lvNo,4)
Return

cmInputGui:
SetTimer Monitor, off
Gui 1:-AlwaysOnTop
Gui 2:Default
Gui 2:Margin, 5, 5
Gui 2: -Caption 0x800000 +AlwaysOnTop
Gui 2:Font, s8, Tahoma
Gui 2:Add, GroupBox, w170 h50 Section, Alias
Gui 2:Add, Edit, xs+10 ys+18 w150 vAlias, %Alias%
Gui 2:Add, GroupBox, x+15 ys w180 h50 Section, Keyword
Gui 2:Add, ComboBox, xs+10 ys+18 w150 vKeyword, %comboKeywords%
Gui 2:Add, Button, x+5 w30 h20 Default vAddToList gbGui2Ok, OK
Gui 2:Add, GroupBox, xm yp+32 w355 h50 Section, Directory Path
Gui 2:Add, Edit, xs+10 yp+18 w325 vdPath, %dPath%
Gui 2:Add, Button, x+5 w30 h20 vOpenDir gbOpenDir, &...
Gui 2:Add, Button, xm+340 ym+43 w30 h20 vCancel gbCancel, &X
Gui 2:Show,, QuickDir - Add / Edit ...
Return

bGui2Ok:
Gui 2:Submit, NoHide
If (dPath="") || (Alias="") || (Keyword="") {
   Gui 2: -AlwaysOnTop
   MsgBox,, QuickDir, One or more edit fields are empty.`nYou must enter an "alias" AND a "keyword" AND a "path".
   Gui 2: Destroy
   GoSub cmInputGui
   Return
   }
Gui 2:Hide
lvData = %lvPath%|%lvKeyWord%|%lvAlias%
StringRight dBSlash, dPath, 1
dLen := StrLen(dPath)
If (dBSlash = "\") && (dLen > 3) {
   StringTrimRight dPath, dPath, 1
   }
efData = %dPath%|%KeyWord%|%Alias%
Loop Parse, list, `n
{
   dir := A_LoopField
   IfInString dir, %efData%
   {
      MsgBox This entry already exists!:`n`nAlias - %Alias%`nKeyword - %KeyWord%`nPath - %dPath%`n`nCannot continue.
      Gosub bCancel
      Alias=
      Keyword=
      dPath=
      Return
      }
   }
If (ReplaceEntry)
   StringReplace list, list, %lvData%, %efData%
Else {
   list = %list%`n%efData%
   StringReplace list, list, |, %A_Tab%, A
   Sort list, cl u
   StringReplace list, list, %A_Tab%, |, A
   }
FileDelete %qdlFile%
FileAppend %list%, %qdlFile%
If (Keyword = "Folder") || (Keyword = "!Favourites")
   comboKeywords = %comboKeywords%
Else {
   comboKeywords = %comboKeywords%|%Keyword%
   StringReplace comboKeywords, comboKeywords, Folder||!Favourites|,,
   Sort comboKeywords, U D|
   comboKeywords = Folder||!Favourites|%comboKeywords%
   }
GoSub cfgSave
Gui 1: Default
LV_Delete()
Gosub FillListView
If (App = "None") {
   Gui 1:Default
   Gui 1:+AlwaysOnTop
   Gui 2:Destroy
   }
Else Gosub bCancel
ReplaceEntry=
lvData=
efData=
Return

bOpenDir:
Gui 2: -AlwaysOnTop
FileSelectFolder dirPath
Gui 2: +AlwaysOnTop
IfEqual dirPath,,   Return
GoSub fillGui
Return

cmAddThisDir:
If (App = "OS") {
   Loop {
      ControlGetText dName, ComboBox1, %wClass%
      sdList = My Documents|Desktop|Start Menu|Application Data|Startup
      Loop Parse, sdList, |
      {
         l := A_LoopField
         If (dName = l) {
            sfPath := sysFolder2Path(dName)
            dirPath = %sfPath%\%dirPath%
            Goto cont1
            }
         Continue
         }
      StringRight Root, dName, 4
      IfInString Root, :)
      {
         dLetter := SubStr(Root, 2, 1)
         dirPath = %dLetter%:\%dirPath%
         StringTrimRight OutFileName, dName, 5
         Gui 1:-AlwaysOnTop
         GoSub cmInputGui
         GoSub fillGui
         Return
         }
      dirPath = %dName%\%dirPath%
      ControlFocus SysListView321, %wClass%
      ControlSend SysListView321, {Bs}, %wClass%
      }
   }
If (App = "CMD") {
   dirPath := clipboard
   StringLeft drv, dirPath, 3
   IfNotInString drv, :\
   {
      Gui 1:-AlwaysOnTop
      MsgBox,, QuickDir, You must first copy a complete path to the clipboard.`n`nCannot continue.
      GoSub GuiEscape
      }
   }
Else ControlGetText dirPath, %adrBar%, %wClass%
cont1:
Gui 1:-AlwaysOnTop
GoSub cmInputGui
GoSub fillGui
Return

fillGui:
StringRight dBSlash, dirPath, 1
dLen := StrLen(dirPath)
If (dBSlash = "\") && (dLen > 3) {
   StringTrimRight dirPath, dirPath, 1
   }
SplitPath dirPath, OutFileName
GuiControl 2:, dPath, %dirPath%
GuiControl 2:, Alias, %OutFileName%
If (dLen < 4)
   GuiControl 2:ChooseString, KeyWord, Drive
dirPath=
Return

cmConfirmRemove:
Gosub lvRowInfo
lvData = %lvPath%|%lvKeyWord%|%lvAlias%
Gui 1:-AlwaysOnTop
MsgBox 1, QuickDir - WARNING, Alias - %lvAlias%`nPath - %lvPath%`nKeyword - %lvKeyWord%`n`nOK to remove entry?
IfMsgBox Ok
   Gosub cmDeleteEntry
Gui 1:+AlwaysOnTop
Return

cmDeleteEntry:
StringReplace list, list, %lvData%`n,, A
FileDelete %qdlFile%
FileAppend %list%, %qdlFile%
LV_Delete()
Gosub FillListView
Return

cmEditList:
Run %qdlFile%
IfNotEqual App, None, GoSub GuiEscape
WinMinimize QuickDir - Double click or Enter to open selected.
Return

cmBackupList:
Gui 1:-AlwaysOnTop
FileSelectFile backup, S24, %A_ScriptDir%\Copy of %qdlFile%,, *.txt
If !ErrorLevel {
   StringRight txtCheck, backup, 4
   If txtCheck <> .txt
      backup = %backup%.txt
   FileAppend %list%, %backup%
   }
Gui 1:+AlwaysOnTop
Return

cfgLoad:
IniRead sPath, %iniPath%, View, ShowPath, 0
IniRead cSort, %iniPath%, View, ColumnSort, 1
IniRead comboKeywords, %inPath%, ComboBox, ComboBoxList, Folder||!Favourites|Ahk|System|Drive
IniRead runEditor, %iniPath%, Editor, RunEditor, 0
Return

cfgSave:
IniWrite %sPath%, %iniPath%, View, ShowPath
IniWrite %cSort%, %iniPath%, View, ColumnSort
IniWrite %comboKeywords%, %iniPath%, ComboBox, ComboBoxList
IniWrite %runEditor%, %iniPath%, Editor, RunEditor
Return

GuiClose:
2GuiClose:
bCancel:
IfWinActive QuickDir - Double click or Enter to open selected.
   GoSub GuiEscape
Gui 1:Default
Gui 1:+AlwaysOnTop
Gui 2:Destroy
SetTimer Monitor, On
Return

GuiEscape:
2GuiEscape:
IfWinActive QuickDir - Add / Edit ...
{
   GoSub GuiClose
   Return
   }
list=
ExitApp
Return

sysFolder2Path(sysFolder)
{
IfEqual sysFolder, My Documents, Return, A_MyDocuments
IfEqual sysFolder, Desktop, Return, A_Desktop
IfEqual sysFolder, Start Menu, Return, A_StartMenu
IfEqual sysFolder, Application Data, Return, A_AppData
IfEqual sysFolder, Startup, Return, A_Startup
IfEqual sysFolder, Program Files, Return, A_ProgramFiles
IfEqual sysFolder, Windows, Return, A_WinDir
}

selectedMenuItem(cSort)
{
IfEqual cSort, 1, Return, "Sort by &Number ( Path ! )"
IfEqual cSort, 2, Return, "Sort by Al&ias"
IfEqual cSort, 3, Return, "Sort by &Keyword"
}


Original:
Code:
;______________________
; \____QuickDir_____/

; Coded by MsgBox.                                          Last Edit:- 12/09/06

; Bookmark your favourite folders/directories for lightning fast access.

; Works (but not exclusively) in Open/Save dialogues, Xplorer2 and Windows Explorer.
; The QuickDir Gui attaches itself to the ListView control in Open/Save, and
; to the Address bar in Xplorer2 and Windows Explorer.

; FEATURES:-
; (Via context menu)
; Add a folder.
; Add keyword.
; Add alias.
; Add currant folder.
; Edit selected entry.
; Delete selected entry.
; Edit QuickDir list file.
; Backup QuickDir list file.
; Keyboard navigation.

; TO USE:-
; In your chosen app/dialogue press Win-O to view your folder bookmarks.
; Mouse: Double click your chosen bookmark.
; Keyboard: Use Up/Down arrow keys to choose your bookmark then Enter.
;           Enter a row number then press Enter.
; Use the headers to sort the list. (First column sorts by path alphabetically)
; To show the bookmarked paths in QuickDir, set the variable ShowPath to 1.
; To cancel the Gui press Esc.
#O::
   #SingleInstance force
   SetTimer Monitor, 500
   
   DefFile = QuickDirList.txt
   ShowPath = 0
   
   aClass=
   (
   ahk_class #32770
   ahk_class ATL:ExplorerFrame
   ahk_class ExploreWClass
   )

   Loop Parse, aClass, `n
   {
      wClass := A_LoopField
      IfWinActive %wClass%
      {
         WinGetPos xO, yO, hO, wO, %wClass%
         Break
      }
   }
   IfWinNotActive %wClass%
      Return
   FirstRun = 1
   Gosub WinPos
   FirstRun = 0
   Gui -Caption +AlwaysOnTop
   Gui Margin, 0, 0
   Gui Add, ListView, w%w% h%h% vDir gLVClick , #|Alias|Keyword|Path
   Gui Add, Button, x-10 y -10 w1 h1 gbOk Default
   Gosub FillListView
   Gui Show, x%x% y%y% w%w% h%h%, QuickDir
   Gosub ContextMenu
Return

bOk:
   GuiControlGet, FocusedControl, FocusV
   IfNotEqual FocusedControl, Dir, Return
   no := LV_GetNext(0, "Focused")
   Gosub Go
Return

LVClick:
   IfNotEqual A_GuiEvent, DoubleClick, Return
   Gui Submit, NoHide
   no := A_EventInfo
   Gosub Go
Return

Go:
   LV_GetText(Choice, no, 4)
   ControlSetText Edit1, %Choice%, %wClass%
   ControlFocus Edit1, %wClass%
   ControlSend Edit1, {Enter}, %wClass%
   Gosub GuiEscape
Return

FillListView:
   FileRead list, %DefFile%
   Loop Parse, list, `n
   {
      dir:=A_LoopField
      StringReplace dir, dir, `r,, A
      StringSplit div, dir, |

      Cnt := LV_GetCount() +1
      LV_Add("", Cnt, div3, div2, div1)
      LV_ModifyCol(1, "20 Integer")
      LV_ModifyCol()
      If ShowPath = 0
         LV_ModifyCol(4, 0)
   }
Return

WinPos:
   WinGetPos xO, yO, wO, hO, %wClass%

   IfWinActive ahk_class #32770
   {
      App = OS
      ControlGetPos xOC, yOC, wOC, hOC, SysListView321, %wClass%
      x := xO + xOC
      y := yO + yOC
      w := wOC
      h := hOC
      }
   IfWinActive ahk_class ATL:ExplorerFrame
   {
      App = X2
      ControlGetPos xAdr, yAdr, wAdr, hAdr, Edit1, %wClass%
      x := xO + xAdr -3
      y := yO + yAdr -3
      w := wAdr
      h := 300
      }
   IfWinActive ahk_class ahk_class ExploreWClass
   {
      App = XP
      ControlGetPos xAdr, yAdr, wAdr, hAdr, Edit1, %wClass%
      x := xO + xAdr
      y := yO + yAdr -5
      w := wAdr
      h := 300
      }
   If FirstRun = 1
      Return
   Gui Show, x%x% y%y% w%w% h%h%, QuickDir
Return

ContextMenu:
   Menu ContextMenu, Add, Add This Directory, cmAddThisDir
   Menu ContextMenu, Add, Add A Directory, cmInputGui
   Menu ContextMenu, Add
   Menu ContextMenu, Add, Edit This Entry, cmEditEntry
   Menu ContextMenu, Add, Delete This Entry, cmConfirmRemove
   Menu ContextMenu, Add
   Menu ContextMenu, Add, Edit Directory List, cmEditList
   Menu ContextMenu, Add, Backup Directory List, cmBackupList
Return

GuiContextMenu:
   Menu ContextMenu, Show
Return

cmEditList:
   Gui Destroy
   Run %DefFile%
Return

cmBackupList:
   Gui 1:-AlwaysOnTop
   FileSelectFile backup, S16, %A_ScriptDir%,, *.txt
   FileAppend %list%, %backup%.txt
   Gui 1:+AlwaysOnTop
Return

cmEditEntry:
   Gosub lvRowInfo
   Gosub cmInputGui
   GuiControl,2:, Alias, %lvAlias%
   GuiControl,2:ChooseString, KeyWord, %lvKeyWord%
   GuiControl,2:, Path, %lvPath%
   ReplaceEntry = 1
Return

lvRowInfo:
   lvNo := LV_GetNext(0, "Focused")
   LV_GetText(lvAlias, lvNo,2)
   LV_GetText(lvKeyWord, lvNo,3)
   LV_GetText(lvPath, lvNo,4)
Return

cmDeleteEntry:
   Loop {
      StringReplace list, list, %LVData%`r`n,, UseErrorLevel
      If ErrorLevel = 0
        Break
      }
   FileDelete %DefFile%
   FileAppend %list%, %DefFile%
   LV_Delete()
   Gosub FillListView
Return

cmConfirmRemove:
   Gosub lvRowInfo
   LVData = %lvPath%|%lvKeyWord%|%lvAlias%
   EFData = %Path%|%KeyWord%|%Alias%
   Gui 1:-AlwaysOnTop
   MsgBox 1,,Ok to remove entry?
   IfMsgBox Ok
      Gosub cmDeleteEntry
   Gui 1:+AlwaysOnTop
Return

cmInputGui:
   SetTimer Monitor, off
   Gui 1:-AlwaysOnTop
   Gui 2:Default
   Gui 2:Margin, 5, 5
   Gui 2:Add, GroupBox, w345 h50 Section
   Gui 2:Add, Text, xp+20, Directory Path
   Gui 2:Add, Edit, xs+10 yp+18 w325 vPath
   Gui 2:Add, Button, x+5 w30 h20 vOpenDir gbOpenDir, ...
   Gui 2:Add, Button, xp yp+25 w30 h20 vCancel gbCancel, X
   Gui 2:Add, GroupBox, xm yp+9 w170 h50 Section
   Gui 2:Add, Text, xp+20 , Keyword
   Gui 2:Add, ComboBox, xs+10 yp+18 w150 vKeyword, Folder||!Favourites|Ahk|System|Drive
   Gui 2:Add, GroupBox, x+15 ys w170 h50
   Gui 2:Add, Text, xp+20, Alias
   Gui 2:Add, Edit, xp-10 ys+18 w150 vAlias
   Gui 2:Add, Button, x+5 w30 h20 vAddToList gbGui2Ok, Ok
   Gui 2:Show,,QuickDir Add...
Return

bOpenDir:
   FileSelectFolder fPath
   GuiControl,,Edit1, %fPath%
Return

bGui2Ok:
   Gui 2:Submit
   LVData = %lvPath%|%lvKeyWord%|%lvAlias%
   EFData = %Path%|%KeyWord%|%Alias%
   Loop Parse, list, `n
   {
      dir := A_LoopField
      IfInString dir, %EFData%
      {
         MsgBox This entry :-`n " %EFData% "`nalready exists!
         Gosub bCancel
         Return
      }
   }
   If ReplaceEntry = 1
      StringReplace list, list, %LVData%, %EFData%
   
   If ReplaceEntry <> 1
   {
      list = %list%`n%EFData%
      Sort list, U
   }
   FileDelete %DefFile%
   FileAppend %list%, %DefFile%
   Gui 1: Default
   LV_Delete()
   Gosub FillListView
   Gosub bCancel
   ReplaceEntry =
   LVData =
   EFData =
Return

cmAddThisDir:
   If App = OS
   {
      Loop {
      ControlGetText DirName, ComboBox1, %wClass%
      StringRight Root, DirName, 4
      StringRight End, Root, 2
      StringLeft Start, Root, 1
      If (Start = "(") and (End = ":)")
      {
         StringLeft Tmp, Root, 2
         StringRight Letter, Tmp, 1
         DirPath = %Letter%:\%DirPath%
         Gui 1:-AlwaysOnTop
         ControlSetText Edit1, %DirPath%, %wClass%
         ControlSend Edit1, {Enter}, %wClass%
         Gosub cmInputGui
         GuiControl,2:, Path, %DirPath%
         DirPath=
         Return
         }
      DirPath = %DirName%\%DirPath%
      ControlFocus SysListView321, %wClass%
      ControlSend SysListView321, {Bs}, %wClass%
      }
   }
   If (App = "X2") or (App = "XP")
   {
      ControlGetText DirName, Edit1, %wClass%
      DirPath = %DirName%
      Gui 1:-AlwaysOnTop
      Gosub cmInputGui
      GuiControl,2:, Path, %DirPath%
      DirPath=
      Return
   }
   Gui 1:+AlwaysOnTop
Return

Monitor:
   IfWinNotExist %wClass%
   {
      Gui Destroy
      SetTimer Monitor, off
      Return
      }
   If GetKeyState("LButton", "P")
      {
         s:=A_TickCount
         KeyWait LButton, Up
         e:=A_TickCount
         c:=e-s
         If e < 200
            Return
         Else
            Gosub WinPos
         }
Return

GuiClose:
bCancel:
   Gui 1:Default
   Gui 1:+AlwaysOnTop
   Gui 2:Destroy
   SetTimer Monitor, on
Return

GuiEscape:
   Gui Destroy
   SetTimer Monitor, off
Return


Last edited by MsgBox on Sun May 13, 2007 9:53 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
stevep



Joined: 28 Aug 2006
Posts: 20
Location: Ukraine

PostPosted: Wed Sep 13, 2006 8:11 am    Post subject: Reply with quote

Greetings!
An interesting idea on another approach on File-Dialogs Management.
A ListBox-replacer. And it can be far-far improved from it's current state.
Currently it have a lot of bugs.
* When no folder-items added to the list, empty Separators added to the End of the PopupMenu.
* The Columns in the ListView are not remembered and even not auto-sized.
* After resizing a File Dialog, the ListView Control isn't updated.
* Probably the Script should Hide the ListView in the FileDialog and the ListView should behave as it is actually really a Child Window of the Dialog. Probably it should be CreateWindowEx-ed by using the Hwnd of the Dialog as the Parent Window.

Great Beginning!
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Wed Sep 13, 2006 8:31 am    Post subject: Reply with quote

Cool! Thx for sharing this! Very Happy
Back to top
Uncle John



Joined: 13 Jun 2006
Posts: 34
Location: Australia

PostPosted: Mon Dec 18, 2006 8:59 pm    Post subject: Reply with quote

Hi MsgBox,

Congradulations. Very Happy
This is a brilliant idea.
However I can only get QuickDir to work with the File Open dialog box in Notepad.

I'd really like to get it to work in other applications (e.g. Excel, Windows Explorer etc.). But if I try it anywhere other than Notepad the QuickDir window opens and instantly shrinks to nothing in the top left corner of the screen. Confused

I'll put a link to this message in the help forum to get it a bit more exposure

Cioa
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Tue Dec 19, 2006 7:55 am    Post subject: Reply with quote

2msgbox
Nice idea for Open/Save !

2 Uncle
U can use Favmenu for all things you mentioned.
_________________
Back to top
View user's profile Send private message MSN Messenger
MsgBox



Joined: 17 Nov 2005
Posts: 179
Location: Leicester, UK

PostPosted: Sun May 13, 2007 12:47 pm    Post subject: Reply with quote

Updated...

Thanks for the positive comments. Cool

Added support for Command Prompt and A43 file manager. Fixed a lot of bugs and generally improved the whole script.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group