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 

Yet another program launcher
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Thu Oct 08, 2009 6:59 am    Post subject: Yet another program launcher Reply with quote

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.



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



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 Wink

critiques welcome.


Last edited by ..:: Free Radical ::.. on Fri Jan 22, 2010 7:29 pm; edited 15 times in total
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Thu Oct 08, 2009 7:07 am    Post subject: Re: Yet another program launcher Reply with quote

..:: 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 Question
_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Thu Oct 08, 2009 7:09 am    Post subject: Reply with quote

I put Sleep, 5000 Razz when I was testing this
but, to no avail
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Thu Oct 08, 2009 10:08 am    Post subject: Reply with quote

Fixed by sending command through %comspec%
Back to top
View user's profile Send private message
netfun81



Joined: 28 Oct 2006
Posts: 58

PostPosted: Fri Oct 09, 2009 6:45 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Sat Oct 10, 2009 7:09 am    Post subject: Persistent version Reply with quote

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
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Jan 21, 2010 9:10 am    Post subject: Looks great but two questions? Reply with quote

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?
Back to top
tg3793



Joined: 19 Jan 2010
Posts: 12
Location: Philippines

PostPosted: Thu Jan 21, 2010 9:11 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 1002
Location: Germany - Deutschland

PostPosted: Thu Jan 21, 2010 9:51 am    Post subject: Reply with quote

hy tg3793,
you launch it via right windows key.
Back to top
View user's profile Send private message
..:: Free Radical ::..



Joined: 20 Sep 2006
Posts: 72

PostPosted: Fri Jan 22, 2010 7:19 pm    Post subject: Reply with quote

@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
Back to top
View user's profile Send private message
TheGreatSwami Woo



Joined: 26 May 2011
Posts: 237
Location: uk

PostPosted: Sun Dec 04, 2011 8:51 pm    Post subject: Reply with quote

For some reason it doesn't pick up .txt files or .ahk in the search
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Dec 05, 2011 4:02 am    Post subject: Reply with quote

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
Back to top
TheGreatSwami Woo



Joined: 26 May 2011
Posts: 237
Location: uk

PostPosted: Mon Dec 05, 2011 11:39 am    Post subject: Reply with quote

@ 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?
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Dec 06, 2011 8:59 pm    Post subject: Reply with quote

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.
Back to top
Guest






PostPosted: Tue Dec 06, 2011 9:41 pm    Post subject: Reply with quote

Searching for text anywhere in the name slows it down too much so I changed

Code:

If Searchtext<>

; to

If StrLen(Searchtext)>2


YMMV.
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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