AutoHotkey Community

It is currently May 26th, 2012, 4:37 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: March 27th, 2009, 6:03 pm 
Offline

Joined: June 8th, 2006, 10:17 pm
Posts: 36
I'm trying to add a Left Menu selection for File Folders (that're in the
Recent dir) but Windows File Folders don't use extensions. Any idea?

i.e.
Types= "missing extension for Windows Folders">C:\windows\explorer.exe
(or actual command that windows used for opening file folders)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2009, 8:51 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
To handle directories the following changes are needed:
Add to the Types the line
Code:
      ,[DIR]>C:\windows\explorer.exe
Change the ShowRecent subroutine to
Code:
ShowRecent:
   Menu DocMenu, DeleteAll
   type = %A_ThisMenuItem%          ; Used in Open:
   If (type="[DIR]")
      Loop %Recent%\*.lnk
      {
         FileGetShortcut %Recent%\%A_LoopFileName%, file
         If (!InStr(FileExist(file),"D"))
            Continue
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         Menu DocMenu, Add, %file%, Open
      }
   else
      Loop %Recent%\*.%type%.lnk
      {
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         Menu DocMenu, Add, %file%, Open
      }
   Menu DocMenu, Show, 0                     ; Show still on the left
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 28th, 2009, 6:10 pm 
Offline

Joined: June 8th, 2006, 10:17 pm
Posts: 36
Thanks, the [DIR] works like a charm. Now I don't need to spend time manually hunting for opened folders/applications etc. in my windowing system (VirtuaWin). Almost everything* is accessible from the top and left menu
* Firefox is an occasional pain. winexist doesn't recognize the FF title "Mozilla Firefox" reliably, especially if it's at the end of a long sentence :(
Perhaps I should try the detect picture pixels workaround?



BTW, is it possible to add a toggle sort button/click to the 2nd popup window of the Left Menu, to toggle displaying the contents in "Reverse Chronological" sort order and "Alphabetical sort" order (what it is presently)?

reason: the files we need to access are also often the most recent of the Recent files, and thus should be the most acessible/readable (top of list).


e.g.

[Abc]
------------
zfile10.txt
file2.txt
file0.txt


[Recent]
-----------
file0.txt
file2.txt
zfile10.txt


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 28th, 2009, 8:16 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Instead of the "Mozilla Firefox" text in the title you could use "ahk_class MozillaUIWindowClass".

Sorting by date/time is not always reliable: some applications, like Total Commander don't update the recent files list. Still, you can replace the ShowRecent subroutine with this:
Code:
ShowRecent:
   type = %A_ThisMenuItem%          ; Used in Open:
   MouseGetPos,,Y

ShowDate:
   Menu DocMenu, DeleteAll
   Menu DocMenu, Add, [Sort by Name], ShowName
   Menu DocMenu, Add
   List =
   If (type="[DIR]")
      Loop %Recent%\*.lnk
      {
         FileGetShortcut %Recent%\%A_LoopFileName%, file
         If (!InStr(FileExist(file),"D"))
            Continue
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         FileGetTime Time, %Recent%\%A_LoopFileName%
         List .= Time file "`n"
      }
   else
      Loop %Recent%\*.%type%.lnk
      {
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         FileGetTime Time, %Recent%\%A_LoopFileName%
         List .= Time file "`n"
      }
   StringTrimRight List, List, 1
   Sort List, R
   Loop Parse, List, `n
      Menu DocMenu, Add, % SubStr(A_LoopField,15), Open
   Menu DocMenu, Show, 0, % Y-9                 ; Show in the same place
Return

ShowName:
   Menu DocMenu, DeleteAll
   Menu DocMenu, Add, [Sort by Date], ShowDate
   Menu DocMenu, Add
   If (type="[DIR]")
      Loop %Recent%\*.lnk
      {
         FileGetShortcut %Recent%\%A_LoopFileName%, file
         If (!InStr(FileExist(file),"D"))
            Continue
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         Menu DocMenu, Add, %file%, Open
      }
   else
      Loop %Recent%\*.%type%.lnk
      {
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         Menu DocMenu, Add, %file%, Open
      }
   Menu DocMenu, Show, 0, % Y-9                 ; Show in the same place
Return


Here is the complete script with directory handling and sorting for Vista:
Code:
#SingleInstance Force
#NoEnv
SetBatchLines -1
#Persistent
CoordMode Mouse, Screen
CoordMode Menu,  Screen

EnvGet APP,APPDATA
Recent = %APP%\Microsoft\Windows\Recent

XX := 0 "," 190 "," A_ScreenWidth -185 "," A_ScreenWidth -2 "," 9999
StringSplit XX, XX, `,              ; Region boundaries
YY := 0 "," 190 "," A_ScreenHeight-185 "," A_ScreenHeight-2 "," 9999
StringSplit YY, YY, `,

Loop 5                              ; MenuXY <- desired menu.
   Menu1%A_Index% = LeftMenu        ; 11 21 31 41 51    Left  1Y
Loop 5                              ; 12 22 32 42 52    Right 5Y
   Menu%A_Index%1 = TopMenu         ; :    ....    :    Top   X1
                                    ; 15 25 35 45 55    Botm  X5
Menu TopMenu, Add, WinWord, RUN
Menu TopMenu, Add, NotePad, RUN
Menu TopMenu, Add, CMD,     RUN
Menu TopMenu, Add, Calc,    RUN
Menu TopMenu, Add, www.autohotkey.com, RUN
; ... further menu items
                                    ; EDIT BELOW: ,FileType>Application Path
Types= AHK>C:\Program Files\Multi-Edit 9.10\Mew32.exe
      ,DOC>C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe
      ,MHT>C:\Program Files\Internet Explorer\IEXPLORE.EXE
      ,PDF>C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe
      ,PPT>C:\Program Files\Microsoft Office\OFFICE11\POWERPNT.EXE
      ,RTF>C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe
      ,TXT>C:\WINDOWS\NOTEPAD.EXE
      ,XLS>C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE
      ,[DIR]>C:\windows\explorer.exe

Menu LeftMenu,Add,[recent],LeftAgain ; Item1 = title
Menu LeftMenu,Add                    ; Separator
Loop Parse, Types, `,
{
   StringSplit t, A_LoopField, >
   Menu LeftMenu, Add, %t1%, ShowRecent
   App%t1% = %t2%                   ; Setup AppXXX vars for fast call
}
Menu LeftMenu,Add                   ; Separator
Menu LeftMenu,Add,ShowAll>, ShowAll ; After extensions, other menu items
Menu LeftMenu,Add,DelLink>, DelLink
Menu LeftMenu,Add,CleanUp>, CleanUp
; ... further menu items

Menu DocMenu, Add                   ; Dummy entry for 1st DeleteAll
Pcount = 1

SetTimer Edge, 250
Return

Edge:
   MouseGetPos X, Y
   P0 = %Pos%                       ; Previous mouse position
   Loop 5
      If (X <= XX%A_Index%) {
         Pos = %A_Index%            ; X region
         Break
      }
   Loop 5
      If (Y <= YY%A_Index%) {
         Pos = %Pos%%A_Index%       ; Position = XregionYregion
         Break
      }
   Pcount := Pcount*(P0=Pos) + 1    ; How long in this region
   If (Pcount <> 4 or Menu%Pos% = "")
      Return
   Menu % Menu%Pos%, Show
Return

RUN:
   Run %A_ThisMenuItem%
Return

LeftAgain:                          ; No real selection: re-show menu
   Menu leftMenu, Show, %X%, %Y%
Return

DelLink:
   Action = DeleteLink
   Goto Show
ShowAll:
   Action = RunLink
Show:
   Menu DocMenu, DeleteAll
   Loop %Recent%\*.lnk
   {
      StringTrimRight file,A_LoopFileName,4  ; remove .lnk
      Menu DocMenu, Add, %file%, %Action%
   }
   Menu DocMenu, Show, 0            ; Show still on the left
Return

RunLink:                            ; Run default application with document
   FileGetShortcut %Recent%\%A_ThisMenuItem%.lnk, file
   Run "%file%"
Return

DeleteLink:                         ; Delete selected link
   FileGetShortcut %Recent%\%A_ThisMenuItem%.lnk, file
   MsgBox 4,,Delete Shortcut to`n%file%
   IfMsgBox Yes
      FileDelete %Recent%\%A_ThisMenuItem%.lnk
GoTo LeftAgain                       ; Re-show Left menu

ShowRecent:
   type = %A_ThisMenuItem%          ; Used in Open:
   MouseGetPos,,Y

ShowDate:
   Menu DocMenu, DeleteAll
   Menu DocMenu, Add, [Sort by Name], ShowName
   Menu DocMenu, Add
   List =
   If (type="[DIR]")
      Loop %Recent%\*.lnk
      {
         FileGetShortcut %Recent%\%A_LoopFileName%, file
         If (!InStr(FileExist(file),"D"))
            Continue
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         FileGetTime Time, %Recent%\%A_LoopFileName%
         List .= Time file "`n"
      }
   else
      Loop %Recent%\*.%type%.lnk
      {
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         FileGetTime Time, %Recent%\%A_LoopFileName%
         List .= Time file "`n"
      }
   StringTrimRight List, List, 1
   Sort List, R
   Loop Parse, List, `n
      Menu DocMenu, Add, % SubStr(A_LoopField,15), Open
   Menu DocMenu, Show, 0, % Y-9                 ; Show in the same place
Return

ShowName:
   Menu DocMenu, DeleteAll
   Menu DocMenu, Add, [Sort by Date], ShowDate
   Menu DocMenu, Add
   If (type="[DIR]")
      Loop %Recent%\*.lnk
      {
         FileGetShortcut %Recent%\%A_LoopFileName%, file
         If (!InStr(FileExist(file),"D"))
            Continue
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         Menu DocMenu, Add, %file%, Open
      }
   else
      Loop %Recent%\*.%type%.lnk
      {
         StringTrimRight file,A_LoopFileName,4  ; remove .lnk
         Menu DocMenu, Add, %file%, Open
      }
   Menu DocMenu, Show, 0, % Y-9                 ; Show in the same place
Return

Open:                               ; Open linked file
   FileGetShortcut %Recent%\%A_ThisMenuItem%.lnk, file
   Run % App%type% " """ file """"
Return

CleanUp:                            ; Remove broken links
   Loop %Recent%\*.lnk
   {
      FileGetShortcut %A_LoopFileFullPath%, file
      If !FileExist(file) {
         ToolTip Deleting %A_LoopFileFullPath%
         FileDelete %A_LoopFileFullPath%
         Sleep 100
      }
      ToolTip                       ; Remove last tooltip
   }
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 28th, 2009, 9:45 pm 
Offline

Joined: June 8th, 2006, 10:17 pm
Posts: 36
The window class:
"ahk_class MozillaUIWindowClass".
doesn't work for me since I also run Thunderbird, which uses the same
ahk_class ... TB then always gets winactivated before FF.

Seems to be a bug? with AHK in not reading all the text in the wintitle?



Your latest additions for sorting is exactly what I wanted. Thanks!!!
fsnow55


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], maul.esel and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group