Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* INFO Launch --------------------------------------------
- File Search Engine • Version 02
- Written By: Najeeb Shah Khan (najeebshahkhan@gmail.com)
- Last Modified: 2-22-2023
- This AutoHotkey script displays a ListView that enables launching of programs using their LNK shortcut files.
- This script may be run alone, or included in another script if "GoSub, LaunchStart" is issued at the start.
- Modify LNKdirectories to refer to directories that contain LNK shortcut files to be listed in the GUI.
- If needed, modify the hotkey to launch the GUI. The current hotkey is WIN-/ (WIN key combined with "/").
- --------------------------------------------------
- */
- #NoEnv
- #SingleInstance, Force
- SetBatchLines, -1
- ;#NoTrayIcon
- SetWorkingDir %A_ScriptDir%
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- FileCreateDir, %A_ScriptDir%\DATA
- FileInstall , LAUNCHER.ahk, %A_ScriptDir%\DATA\LAUNCHER.ahk, 1
- FileInstall , Milikymac.msstyles, %A_ScriptDir%\DATA\Milikymac.msstyles, 1
- FileInstall , USkin.dll, %A_ScriptDir%\DATA\USkin.dll, 1
- FileSetAttrib +HS, %A_ScriptDir%\DATA\LAUNCHER.ahk, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA\Milikymac.msstyles, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA\USkin.dll, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA, 2
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- SkinForm(Apply, A_ScriptDir . "\DATA\USkin.dll", A_ScriptDir . "\DATA\Milikymac.msstyles")
- OnExit, GetOut
- LaunchStart:
- ; --- Directories with LNK files to be listed in GUI -------------
- LNKdirectories := [A_Programs
- , A_ProgramsCommon
- , A_ScriptDir
- , A_workingDir]
- ; ----------------------------------------------------------------
- Global LaunchList
- getLaunches(LNKdirectories)
- Return
- ; --- Hotkey to launch the GUI -----------------------------------
- #/::
- Gui, Launch:Show
- If (selRow := LV_GetNext())
- LV_Modify(selRow, "Vis")
- Return
- ; --- No need to change anything below this line -----------------
- LaunchButtonOK: ; User has selected a GUI listing and pressed ENTER
- GuiControlGet, fcontrol, FocusV
- If (fcontrol != "LaunchList") {
- SoundBeep, 1000
- MsgBox, 48, mwLaunch.ahk: focused control, %fcontrol%
- Return
- }
- LV_GetText(app, LV_GetNext("F"), 2) ; Get the path (second column) from the focused line in the ListView
- Gosub, LaunchGuiEscape ; Hide the GUI
- Run, %app%
- Return
- LaunchGuiEscape:
- Gui, Launch:Hide
- Return
- getLaunches(launchDirs) { ; Put file names and paths from the launch directories into a listview
- For index, launchDir in launchDirs { ; Loop through the launch directories
- Loop, Files, % launchDir "\*.*", R ; Find each file in the directory; include subdirectories
- {
- SplitPath, A_LoopFileName,,,, fnBare ; Find the file name without extension
- If A_LoopFileExt not in ini ; Skip INI files
- list .= "`n" (A_LoopFileExt = "lnk" ? fnBare : A_LoopFileName) "`t" A_LoopFileFullPath ; Build the list
- }
- }
- list := SubStr(list, 2) ; Delete the line feed before the first item
- Sort, list
- Gui, Launch:New,, Najeeb Launch list Select and Enter ; Build the GUI
- Gui, Launch:Font, s12
- Gui, Launch:Add, ListView, BackgroundF9DDC7 r22 w700 vLaunchList Count1200 Grid -Multi, Name|Path
- GuiControl, -Redraw, LaunchList
- Loop, parse, list, `n, `r
- {
- oldFn := part1, RegExMatch(A_LoopField, "(.+)\t(.+)", part)
- If (part1 != oldFn)
- LV_Add("", part1, part2) ; Add each item to the listview: file name and full path
- }
- GuiControl, +Redraw, LaunchList
- ; LV_ModifyCol() ; Auto-size each column to fit its contents.
- LV_ModifyCol(1, 300)
- Gui, Launch:Add, Button, w0 h0 hidden Default, OK ; User can select an entry and then press ENTER to execute
- }
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- GetOut:
- GuiClose:
- Gui, Hide
- SkinForm(0)
- ExitApp
- return
- SkinForm(Param1 = "Apply", DLL = "", SkinName = ""){
- if(Param1 = Apply){
- DllCall("LoadLibrary", str, DLL)
- DllCall(DLL . "\USkinInit", Int,0, Int,0, AStr, SkinName)
- }else if(Param1 = 0){
- DllCall(DLL . "\USkinExit")
- }
- }
- ESC::EXITAPP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement