 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
..:: Free Radical ::..
Joined: 20 Sep 2006 Posts: 72
|
Posted: Thu Oct 08, 2009 6:59 am Post subject: Yet another program launcher |
|
|
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
critiques welcome.
Last edited by ..:: Free Radical ::.. on Fri Jan 22, 2010 7:29 pm; edited 15 times in total |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Thu Oct 08, 2009 7:07 am Post subject: Re: Yet another program launcher |
|
|
| ..:: 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  |
|
| Back to top |
|
 |
..:: Free Radical ::..
Joined: 20 Sep 2006 Posts: 72
|
Posted: Thu Oct 08, 2009 7:09 am Post subject: |
|
|
I put Sleep, 5000 when I was testing this
but, to no avail |
|
| Back to top |
|
 |
..:: Free Radical ::..
Joined: 20 Sep 2006 Posts: 72
|
Posted: Thu Oct 08, 2009 10:08 am Post subject: |
|
|
| Fixed by sending command through %comspec% |
|
| Back to top |
|
 |
netfun81
Joined: 28 Oct 2006 Posts: 58
|
Posted: Fri Oct 09, 2009 6:45 pm Post subject: |
|
|
| 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 |
|
 |
..:: Free Radical ::..
Joined: 20 Sep 2006 Posts: 72
|
Posted: Sat Oct 10, 2009 7:09 am Post subject: Persistent version |
|
|
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 |
|
 |
Guest
|
Posted: Thu Jan 21, 2010 9:10 am Post subject: Looks great but two questions? |
|
|
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
|
Posted: Thu Jan 21, 2010 9:11 am Post subject: |
|
|
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 |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Thu Jan 21, 2010 9:51 am Post subject: |
|
|
hy tg3793,
you launch it via right windows key. |
|
| Back to top |
|
 |
..:: Free Radical ::..
Joined: 20 Sep 2006 Posts: 72
|
Posted: Fri Jan 22, 2010 7:19 pm Post subject: |
|
|
@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
Latest updated version in the first post |
|
| Back to top |
|
 |
TheGreatSwami Woo
Joined: 26 May 2011 Posts: 237 Location: uk
|
Posted: Sun Dec 04, 2011 8:51 pm Post subject: |
|
|
| For some reason it doesn't pick up .txt files or .ahk in the search |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Dec 05, 2011 4:02 am Post subject: |
|
|
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
|
Posted: Mon Dec 05, 2011 11:39 am Post subject: |
|
|
@ 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 |
|
 |
Guest
|
Posted: Tue Dec 06, 2011 8:59 pm Post subject: |
|
|
| 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
|
Posted: Tue Dec 06, 2011 9:41 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|