AutoHotkey Community

It is currently May 26th, 2012, 6:14 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 35 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: March 19th, 2006, 8:01 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
It is easy to mimic the auto-hide behavior of the taskbar. When the mouse cursor is at a specified region on the edge of the screen, for about 1 second, a menu pops up. It is controlled by a slow running timer (4 times a second – without any measurable processor load). Different actions are performed at different regions, like with mouse gestures, but w/o the need for pressing any button or keyboard key.

In the script below two easy examples are provided: at the top of the screen a list of programs is shown, which can also contain documents or Internet shortcuts. Clicking on one, or pressing the Up/Down arrow keys and Enter, runs the associated program. Clicking outside of the menu or pressing Esc cancels.

The other example is more interesting. A menu pops up on the left edge of the screen, showing a list of document types I often work with. The bottommost entry is CleanUp, which checks the entries in the Windows Recent Documents list, end deletes the broken shortcuts (linking to files not there any more). There are also menu items for deleting a link, or showing all links pointing to recently used documents, and selecting one opens it with its default application.

This menu also contains items named by often used file extensions, like DOC, TXT. Activating one of them pops up another menu, with the files of this type, referenced in the Windows Recent Documents folder. Activating one starts a specified application with the selected file.

There are many possible extensions. For example, the list of programs, the boundaries of the regions could be read from an ini file, dynamically updated.

Version 1.2

Code:
#Persistent
CoordMode Mouse, Screen
CoordMode Menu,  Screen
Recent = %HOME%\Recent              ; = %USERPROFILE%\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

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:
   Menu DocMenu, DeleteAll
   type = %A_ThisMenuItem%          ; Used in Open:
   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

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


Edit 20060320: Single place for changes
Edit 20060320:
- Added "ShowAll" to Recent Documents menu, which shows all the links, and opens the selected document with its default application.
- Added "DelLink" to Recent Documents menu, which shows all the links. Selecting one removes the shortcut to the selected document.
- Defined 25 regions, where the mouse cursor is detected, 12 are on the edges of the screen. If the mouse is there for 4 timer periods (1…1.25 second), the menu pops up with the name MenuXY, with X and Y = 1…5. 1 corresponds the left/top edge, 5 corresponds to the right/bottom edge of the screen. The numbers in between denote left/mid/right or top/mid/low regions.
- The boundaries between the regions are defined in the strings assigned initially to XX and YY. They contain 5 numbers separated by commas, starting with 0, ending with a large number.


Last edited by Laszlo on March 21st, 2006, 12:54 am, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2006, 9:26 am 
Offline

Joined: April 17th, 2005, 7:47 pm
Posts: 289
Location: Sauerland
Nice and expandable idea!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2006, 4:11 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I updated the script in the original post to version 1.1. Any change in the list of file extensions and the corresponding applications has to be entered in only ONE place, making it easier to adapt the script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2006, 12:40 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Version 1.2 is posted:
- Added "ShowAll" to Recent Documents menu, which shows all the links, and opens the selected document with its default application.
- Added "DelLink" to Recent Documents menu, which shows all the links. Selecting one removes the shortcut to the selected document.
- Defined 25 regions, where the mouse cursor is detected, 12 are on the edges of the screen. If the mouse is there for 4 timer periods (1…1.25 second), the menu pops up with the name MenuXY, with X and Y = 1…5. 1 corresponds the left/top edge, 5 corresponds to the right/bottom edge of the screen. The numbers in between denote left/mid/right or top/mid/low regions.
- The boundaries between the regions are defined in the strings assigned initially to XX and YY. They contain 5 numbers separated by commas, starting with 0, ending with a large number.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 11:01 pm 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
I like the script! Thanks for mentioning it or I would have missed it - I may be missing something, but I can't get the left menu to work - Clicking the items won't do anything that I can see.

_________________
[Join IRC!]
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 11:21 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
In Vista the location of the recently used files changed. Replace
Code:
Recent = %HOME%\Recent
with
Code:
EnvGet APP,APPDATA
Recent = %APP%\Microsoft\Windows\Recent


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2009, 7:27 am 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
thanks for this, it rocks. Its so hard to find a decent "recent documents" app. This one is just about perfect :)

One thing I noticed though, the list of documents it shows, is alphabetical. Since this is about "recent" docs, wouldnt it make more sense to have them show by date modified (descending)? Is there a way to modify the existing script so it can do that?

Also I was wondering if there was a way to have it also show "recent folders" (not just documents)? I poked around on the forum but didnt really find anything like that (much to my surprise, it probably exists but I didnt see it with the keywords I was searching under...)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2009, 4:37 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
jak wrote:
show by date modified (descending)
See the AHK help, under Loop FilePattern, Example#4.
jak wrote:
also show "recent folders" (not just documents)
Under the label "Show:", the line "Loop %Recent%\*.lnk" can be extened by ", 1" to include folders. In the beginning of the loop block you have to add code to process the retrieved folder.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2009, 7:38 pm 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
thanks laszlo

Laszlo wrote:
In the beginning of the loop block you have to add code to process the retrieved folder.


I could do the first part, but "process the retrieved folder" - I think that may stump me...


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 16th, 2009, 6:11 am 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
menu appears as supposed to, but clicking on any item seems to do nothing.

I edited:

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


I edited the file types/apps as to my system - but still no result.

besides show a menu , what is this supposed to do :?:
________
Vaporite Solo Vaporizer


Last edited by webber on February 11th, 2011, 5:56 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 6:30 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
It supposed to open submenus with recent files, and selecting one should launch it in the corresponding application.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 4:41 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
If you modify the beginning of the script to the following, it should work in Win9x too (not sure about multi-user 9x setups):
Code:
#Persistent
CoordMode Mouse, Screen
CoordMode Menu,  Screen
If A_OSType in WIN32   ; enables this script in Win95/98/ME
   Recent = %A_WinDir%\Recent
else
   Recent = %HOME%\Recent              ; = %USERPROFILE%\Recent

_________________
AHK tools by Drugwash (AHK 1.0.48.05 and Win98SE)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 4:57 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Thanks! Most of us have only one computer, with one Windows version, so the posted scripts should be considered as code samples. We have to rely on users' feedback, so testing and adapting scripts for other Windows versions is valuable for the AHK community.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 6:35 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
Laszlo wrote:
It supposed to open submenus with recent files, and selecting one should launch it in the corresponding application.


...not working in win xp pro :(
________
GLAS


Last edited by webber on February 11th, 2011, 5:56 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2009, 6:49 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Which version does not work (Recent = ...)? In XP Recent = %HOME%\Recent should work, unless you added (or implicitly included) #NoEnv to your script. In that case you could add a line "EnvGet Home, Home" to the beginning of your script.


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 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users 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