AutoHotkey Community

It is currently May 27th, 2012, 12:09 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: October 8th, 2009, 7:59 am 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
Hi folks, I felt the need of a Program Launcher in XP which lacks good desktop search and I didn't want to use third party apps.

Image

Yep we already have nDroid and Launchy, but i wanted something minimalistic and no caching, config files.

Image

It is intended to be used with a hotkey / hotcorner / gesture to launch/activate the gui so I have omitted those parts.

Latest updated version.
Code:
#SingleInstance ignore
#NoEnv
#Persistent

SetBatchLines, -1
Process, Priority, , High
Menu, Tray, Icon, shell32.dll, 25

OnMessage(0x06, "WM_ACTIVATE")

RegRead, Favorites, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, Favorites
If Not Favorites
   RegRead, Favorites, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, Favorites

RegRead, Recent, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, Recent
If Not Recent
   RegRead, Recent, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, Recent

;COMMANDER_PATH = E:\Total Commander
;AltType = jpg,bmp,gif,tiff,png

Gui, Color, EEAA99
Gui, +LastFound +ToolWindow
WinSet, TransColor, EEAA99
Gui, Font, s12 w700 cWhite
Gui, Add, ListView, w400 h320 Background000000 LV0x8 AltSubmit vSearched gListGo, Icon|Name|Link|Path
Gui, Font, s14 w500 cBlack
Gui, Add, Edit, w400 h32 vEdit gSearch
Gui, Add, Button, x+ h32 Default vGo, &Go

Menu, Info, Add, &Open, ButtonGo
Menu, Info, Add, Open &Location, Locate
Menu, Info, Add, &Edit, Edit
Menu, Info, Add, &Properties, Properties

Search:
i=0
Critical
IL_Destroy(ImageListID)
LV_Delete()
ImageListID := IL_Create("",1,1)
;Searchtext   := LastText
LV_SetImageList(ImageListID)
ControlGetText, SearchText, Edit1
If Searchtext<>
   {   
      Loop, %Favorites%\%SearchText%*, 0
      {
         GoSub, Shortcut
      }
      Loop, %Recent%\%SearchText%*, 0
      {
         GoSub, Shortcut
      }
      Loop, %A_AppData%\Microsoft\Internet Explorer\Quick Launch\%SearchText%*, 0, 1
      {
         GoSub, Shortcut
      }
      Loop, %A_AppData%\Microsoft\Windows\Recent\%SearchText%*, 0
      {
         GoSub, Shortcut
      }
      Loop, %A_StartMenu%\%SearchText%*, 0, 1
      {
         GoSub, Shortcut
      }
      Loop, %A_StartMenuCommon%\%SearchText%*, 0, 1
      {
         GoSub, Shortcut
      }
/*
      Loop, 26
      {
         k := A_Index - 1
         IniRead, Path, %COMMANDER_PATH%\wincmd.ini, RightHistory, %k%
         IfInString, Path, %SearchText%, GoSub, Dir
         IniRead, Path, %COMMANDER_PATH%\wincmd.ini, LeftHistory, %k%
         IfInString, Path, %SearchText%, GoSub, Dir
      }
*/
      Loop, HKEY_CURRENT_USER, Software\Quizo\QTTabBar\RecentlyClosed
    {
         RegRead, Path
         IfInString, Path, %SearchText%, GoSub, File   
    }
    Loop, HKEY_CURRENT_USER, Software\Quizo\QTTabBar\RecentFiles
    {
         RegRead, Path
         IfInString, Path, %SearchText%, GoSub, File   
    }
      GuiControl, +Tile, Searched
      LV_ModifyCol()
      LV_GetText(Link, 1, 2)
      If Link<>
         GuiControl, Show, Searched
      else
         GuiControl, Hide, Searched
   }
else
   {
      IL_Destroy(ImageListID)
      LV_Delete()
      GuiControl, Hide, Searched
   }
Gui, +Owner -Caption -SysMenu
Gui, Show, AutoSize Center, Launcher
WinGetPos, xX, yY, wW, hH, Launcher ahk_class AutoHotkeyGUI
ControlGetText, SearchText2, Edit1
if not SearchText2
   {
      IL_Destroy(ImageListID)
      LV_Delete()
      GuiControl, Hide, Searched
   }
else if SearchText2 != %SearchText%
   {
      Goto, Search
   }
If !WinActive("Launcher ahk_class AutoHotkeyGUI")
   {
      Goto, Close
   }
return

Dir:
   IfExist, %Path%
   {
      hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, Path, UShortP, iIndex)
      i += 1
      DllCall("ImageList_ReplaceIcon", UInt, ImageListID, Int, -1, UInt, hIcon)
      DllCall("DestroyIcon", Uint, hIcon)
      StringGetPos, pos, Path, `\, R2
      StringTrimLeft, Name, Path, %pos%
      StringReplace, Name, Name, `\,, 1
      StringGetPos, pos, Name, %SearchText%
      If pos = 0
         LV_Add("Icon" . i, Name, Path, Path)
      pos =
   }
return

File:
   IfExist, %Path%
   {
      hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, Path, UShortP, iIndex)
      i += 1
      DllCall("ImageList_ReplaceIcon", UInt, ImageListID, Int, -1, UInt, hIcon)
      SplitPath, Path, Name
      LV_Add("Icon" . i, Name, Path, Path)
   }
return

Shortcut:
   FileGetShortcut, %A_LoopFileLongPath%, Path
   IfExist, %Path%
   {
      hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, A_LoopFileLongPath, UShortP, iIndex)
      i += 1
      DllCall("ImageList_ReplaceIcon", UInt, ImageListID, Int, -1, UInt, hIcon)
      DllCall("DestroyIcon", Uint, hIcon)
      StringReplace, Name, A_LoopFileName, .lnk
      LV_Add("Icon" . i, Name, A_LoopFileLongPath, Path)
   }
return

Edit:
   Focused := LV_GetNext(0, "F")
   if not Focused
    return
   LV_GetText(Path, Focused, 3)
   Run, Edit %Path%,, UseErrorLevel
   Goto, Close
return

Locate:
   Focused := LV_GetNext(0, "F")
   if not Focused
    return
   LV_GetText(Path, Focused, 3)
   SplitPath, Path,, Dir
   Run, %Dir%,, UseErrorLevel
   Goto, Close
return
 
Properties:
   Focused := LV_GetNext(0, "F")
   if not Focused
    return
   LV_GetText(Link, Focused, 2)
   Run, Properties %Link%,, UseErrorLevel
   Goto, Close
return

ButtonGo:
   Focused := LV_GetNext(0, "F")
   if not Focused
      Focused = 1
   LV_GetText(Link, Focused, 2)
   If Link<>
      Run, %Link%,, UseErrorLevel
   else
      Run, %SearchText%,, UseErrorLevel
  Goto, Close
return

ListGo:
   if A_GuiEvent = Normal
   {
      LV_GetText(Path, A_EventInfo, 3)
      ToolTip, %Path%, 14, -28
   }
   else if A_GuiEvent = I
   {
      LV_GetText(Path, A_EventInfo, 3)
      ToolTip, %Path%, 14, -28
   }
   else if A_GuiEvent = DoubleClick
   {
      LV_GetText(Link, A_EventInfo, 2)
      Tooltip
      Goto, ButtonGo
   }
   else if A_GuiEvent = f
   {
      Tooltip
   }
return

GuiContextMenu:
   if A_GuiControl <> Searched
    return
  else If A_EventInfo = 0
      Goto, Close
   else
     Menu, Info, Show   
return

GuiEscape:
GuiClose:
Exit:
Close:
   SearchText =
   IL_Destroy(ImageListID)
   LV_Delete()
   GuiControl, Hide, Searched
   GuiControl, Hide, Edit
   GuiControl, Hide, Go
   MouseGetPos, , , id
   WinActivate, ahk_id %id%
return

WM_ACTIVATE(wParam, lParam)
{
   if wParam = 1
   {
      ControlSetText, Edit1,, Launcher ahk_class AutoHotkeyGUI
      GuiControl, Show, Edit
      GuiControl, Show, Go
      ControlFocus, Edit1, Launcher ahk_class AutoHotkeyGUI
   }
   else if wParam = 0
   {
      SearchText =
      IL_Destroy(ImageListID)
      LV_Delete()
      GuiControl, Hide, Searched
      GuiControl, Hide, Edit
      GuiControl, Hide, Go
   }
}

*RWin::
*#Space::
If WinActive("Launcher ahk_class AutoHotkeyGUI")
{
   Goto, Close
}
else
{
   ControlSetText, Edit1,, Launcher ahk_class AutoHotkeyGUI
   GuiControl, Show, Edit
   GuiControl, Show, Go
   WinActivate, Launcher ahk_class AutoHotkeyGUI
   ControlFocus, Edit1, Launcher ahk_class AutoHotkeyGUI
}
return


Works great and very fast ;)

critiques welcome.


Last edited by ..:: Free Radical ::.. on January 22nd, 2010, 8:29 pm, edited 15 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 8th, 2009, 8:07 am 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
..:: Free Radical ::.. wrote:
I have an encountered a problem. If I run an image file (which is associated to the default Windows picture and Fax Viewe), the ExitApp command kills the launched image window.
I can avoid this using return and keeping the app persistent or by launching using rundll32 shimgvw, but I don't know why this is so. Is this wierdness expected or a bug?


Try to put sleep, 1000 before ExitApp :?:

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 8th, 2009, 8:09 am 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
I put Sleep, 5000 :P when I was testing this
but, to no avail


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 8th, 2009, 11:08 am 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
Fixed by sending command through %comspec%


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

Joined: October 28th, 2006, 5:01 pm
Posts: 58
I like it. Fast and resource friendly. I would suggest making the arrow keys select the program to run from the list. easier when fingers are already on keyboard


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Persistent version
PostPosted: October 10th, 2009, 8:09 am 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
Here is a persistent variant which you can compile.
Right windows key toggles it.

Code:
#SingleInstance ignore
#NoEnv
#Persistent

SetBatchLines, -1
Process, Priority, , High
Menu, Tray, Icon, shell32.dll, 25

OnMessage(0x06, "WM_ACTIVATE")

RegRead, Favorites, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, Favorites
If Not Favorites
   RegRead, Favorites, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, Favorites

RegRead, Recent, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, Recent
If Not Recent
   RegRead, Recent, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, Recent

COMMANDER_PATH = E:\Total Commander
;AltType = jpg,bmp,gif,tiff,png

Gui, Color, EEAA99
Gui, +LastFound +ToolWindow
WinSet, TransColor, EEAA99
Gui, Font, s12 w700 cWhite
Gui, Add, ListView, w400 h320 Background000000 AltSubmit vSearched gListGo, Icon|Name|Link|Path
Gui, Font, s14 w500 cBlack
Gui, Add, Edit, w400 h32 vEdit gSearch
Gui, Add, Button, x+ h32 Default vGo, &Go

Menu, Info, Add, &Open, ButtonGo
Menu, Info, Add, &Edit, Edit
Menu, Info, Add, &Properties, Properties

Search:
i=0
IL_Destroy(ImageListID)
LV_Delete()
ImageListID := IL_Create("",1,1)
;Searchtext   := LastText
LV_SetImageList(ImageListID)
ControlGetText, SearchText, Edit1
If Searchtext<>
   {   
      Loop, %Favorites%\%SearchText%*, 0
      {
         GoSub, Shortcut
      }
      Loop, %Recent%\%SearchText%*, 0
      {
         GoSub, Shortcut
      }
      Loop, %A_AppData%\Microsoft\Internet Explorer\Quick Launch\%SearchText%*, 0, 1
      {
         GoSub, Shortcut
      }
      Loop, %A_AppData%\Microsoft\Windows\Recent\%SearchText%*, 0
      {
         GoSub, Shortcut
      }
      Loop, %A_StartMenu%\%SearchText%*, 0, 1
      {
         GoSub, Shortcut
      }
      Loop, %A_StartMenuCommon%\%SearchText%*, 0, 1
      {
         GoSub, Shortcut
      }
      Loop, 26
      {
         k := A_Index - 1
         IniRead, Path, %COMMANDER_PATH%\wincmd.ini, RightHistory, %k%
         IfInString, Path, %SearchText%, GoSub, Dir
         IniRead, Path, %COMMANDER_PATH%\wincmd.ini, LeftHistory, %k%
         IfInString, Path, %SearchText%, GoSub, Dir
      }
      Loop, HKEY_CURRENT_USER, Software\Quizo\QTTabBar\RecentlyClosed
    {
         RegRead, Path
         IfInString, Path, %SearchText%, GoSub, File   
    }
    Loop, HKEY_CURRENT_USER, Software\Quizo\QTTabBar\RecentFiles
    {
         RegRead, Path
         IfInString, Path, %SearchText%, GoSub, File   
    }
      GuiControl, +Tile, Searched
      LV_ModifyCol()
      LV_GetText(Link, 1, 2)
      If Link<>
         GuiControl, Show, Searched
      else
         GuiControl, Hide, Searched
   }
else
   {
      IL_Destroy(ImageListID)
      LV_Delete()
      GuiControl, Hide, Searched
   }
Gui, +Owner -Caption -SysMenu
Gui, Show, AutoSize Center, Launcher
WinGetPos, xX, yY, wW, hH, Launcher ahk_class AutoHotkeyGUI
ControlGetText, SearchText, Edit1
if not SearchText
   {
      IL_Destroy(ImageListID)
      LV_Delete()
      GuiControl, Hide, Searched
   }
If !WinActive("Launcher ahk_class AutoHotkeyGUI")
   {
      Goto, Close
   }
return

Dir:
   IfExist, %Path%
   {
      hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, Path, UShortP, iIndex)
      i += 1
      DllCall("ImageList_ReplaceIcon", UInt, ImageListID, Int, -1, UInt, hIcon)
      DllCall("DestroyIcon", Uint, hIcon)
      StringGetPos, pos, Path, `\, R2
      StringTrimLeft, Name, Path, %pos%
      StringReplace, Name, Name, `\,, 1
      StringGetPos, pos, Name, %SearchText%
      If pos = 0
         LV_Add("Icon" . i, Name, Path, Path)
      pos =
   }
return

File:
   IfExist, %Path%
   {
      hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, Path, UShortP, iIndex)
      i += 1
      DllCall("ImageList_ReplaceIcon", UInt, ImageListID, Int, -1, UInt, hIcon)
      SplitPath, Path, Name
      LV_Add("Icon" . i, Name, Path, Path)
   }
return

Shortcut:
   FileGetShortcut, %A_LoopFileLongPath%, Path
   IfExist, %Path%
   {
      hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, Str, A_LoopFileLongPath, UShortP, iIndex)
      i += 1
      DllCall("ImageList_ReplaceIcon", UInt, ImageListID, Int, -1, UInt, hIcon)
      DllCall("DestroyIcon", Uint, hIcon)
      StringReplace, Name, A_LoopFileName, .lnk
      LV_Add("Icon" . i, Name, A_LoopFileLongPath, Path)
   }
return

Edit:
   Focused := LV_GetNext(0, "F")
   if not Focused
    return
   LV_GetText(Path, Focused, 3)
   Run, Edit %Path%,, UseErrorLevel
   Goto, Close
return
 
Properties:
   Focused := LV_GetNext(0, "F")
   if not Focused
    return
   LV_GetText(Link, Focused, 2)
   Run, Properties %Link%,, UseErrorLevel
   Goto, Close
return

ButtonGo:
   Focused := LV_GetNext(0, "F")
   if not Focused
      Focused = 1
   LV_GetText(Link, Focused, 2)
   If Link<>
      Run, %Link%,, UseErrorLevel
   else
      Run, %SearchText%,, UseErrorLevel
  Goto, Close
return

ListGo:
   if A_GuiEvent = Normal
   {
      LV_GetText(Path, A_EventInfo, 3)
      ToolTip, %Path%, 14, -28
   }
   else if A_GuiEvent = I
   {
      LV_GetText(Path, A_EventInfo, 3)
      ToolTip, %Path%, 14, -28
   }
   else if A_GuiEvent = DoubleClick
   {
      LV_GetText(Link, A_EventInfo, 2)
      Goto, ButtonGo
   }
   else
      Tooltip
return

GuiContextMenu:
   if A_GuiControl <> Searched
    return
  else If A_EventInfo = 0
      Goto, Close
   else
     Menu, Info, Show   
return

GuiEscape:
GuiClose:
Exit:
Close:
   SearchText =
   IL_Destroy(ImageListID)
   LV_Delete()
   GuiControl, Hide, Searched
   GuiControl, Hide, Edit
   GuiControl, Hide, Go
   MouseGetPos, , , id
   WinActivate, ahk_id %id%
return

WM_ACTIVATE(wParam, lParam)
{
   if wParam = 1
   {
      ControlSetText, Edit1,, Launcher ahk_class AutoHotkeyGUI
      GuiControl, Show, Edit
      GuiControl, Show, Go
      ControlFocus, Edit1, Launcher ahk_class AutoHotkeyGUI
   }
   else if wParam = 0
   {
      SearchText =
      IL_Destroy(ImageListID)
      LV_Delete()
      GuiControl, Hide, Searched
      GuiControl, Hide, Edit
      GuiControl, Hide, Go
   }
}

*RWin::
If WinActive("Launcher ahk_class AutoHotkeyGUI")
{
   Goto, Close
}
else
{
   ControlSetText, Edit1,, Launcher ahk_class AutoHotkeyGUI
   GuiControl, Show, Edit
   GuiControl, Show, Go
   WinActivate, Launcher ahk_class AutoHotkeyGUI
   ControlFocus, Edit1, Launcher ahk_class AutoHotkeyGUI
}
return


Also added total commander from wincmd.ini (you'll need to edit the path) and qttabbar history from regedit.

Also added WM_ACTIVATE to toggle states (click anywhere outside the gui to deactivate the window).

Doesn't write to the registry / any ini file.

You may use the following in your main scripts to toggle the launcher:

Code:
         IfWinNotExist, Launcher ahk_class AutoHotkeyGUI
            Run, %A_ScriptDir%\Launcher.AHK
         else IfWinNotActive, Launcher ahk_class AutoHotkeyGUI
            {
               WinActivate, Launcher ahk_class AutoHotkeyGUI
               ControlFocus, Edit1, Launcher ahk_class AutoHotkeyGUI
            }




@netfun, use shift-tab/tab to focus the listview and then you can use arrow keys


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 21st, 2010, 10:10 am 
Looks beautiful. Two questions:

1) Is there a way to launch it other than right-clicking on it's system tray icon?

2) Is there a way to add a path to it so my external HD is catalogued?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2010, 10:11 am 
Offline

Joined: January 19th, 2010, 11:39 am
Posts: 12
Location: Philippines
Looks beautiful. Two questions:

1) Is there a way to launch it other than right-clicking on it's system tray icon?

2) Is there a way to add a path to it so my external HD is catalogued?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2010, 10:51 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
hy tg3793,
you launch it via right windows key.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2010, 8:19 pm 
Offline

Joined: September 20th, 2006, 2:05 pm
Posts: 73
@tg3793
It doesn't as such catalog anything.
It just sifts through your history.
So even paths to removable drives (if they exist) are included.

Also, you may use the Right Windows key
or Windows + Space to launch

Change it to the key of your choice by editing
Code:
*RWin::
*#Space::


Latest updated version in the first post


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2011, 9:51 pm 
Offline

Joined: May 26th, 2011, 7:53 am
Posts: 237
Location: uk
For some reason it doesn't pick up .txt files or .ahk in the search


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 5th, 2011, 5:02 am 
th file loops in Search: use the search terms followed by *, you will have to modify that to search anywhere in the names.

The hIcon Dlls or something is broken here I suspect its a vista+ prob, there are functions around to fix that

Its a good idea, like that it uses the history. I modded it to not lose the last hits when gui was hidden


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 5th, 2011, 12:39 pm 
Offline

Joined: May 26th, 2011, 7:53 am
Posts: 237
Location: uk
@ Guest I dont understand
I dont want it to search within names - it works with most file types like pdf etc so Why not with txt or ahk without modification?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2011, 9:59 pm 
Code:
If Searchtext<>
   {   
      Loop, %Favorites%\%SearchText%*, 0
   ; and similar...


See how %SearchText% starts straight after the backslash then is followed by an asterisk, that means it must search at the beginning of the filenames. Try putting an asterisk between the backslash and %SearchText% as well. Or removing %SearchText%* from the loop line and underneath (withiin the loop) do a If InStr(A_LoopFileName, SearchText). You could even do regex searches.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2011, 10:41 pm 
Searching for text anywhere in the name slows it down too much so I changed

Code:
If Searchtext<>

; to

If StrLen(Searchtext)>2


YMMV.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Google [Bot], Rajat and 55 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