Advertisement
Najeebsk

LAUNCHER.ahk

Mar 17th, 2023 (edited)
1,459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*   INFO Launch --------------------------------------------
  2. File Search Engine • Version 02
  3. Written By: Najeeb Shah Khan (najeebshahkhan@gmail.com)
  4. Last Modified: 2-22-2023
  5. This AutoHotkey script displays a ListView that enables launching of programs using their LNK shortcut files.
  6. This script may be run alone, or included in another script if "GoSub, LaunchStart" is issued at the start.
  7. Modify LNKdirectories to refer to directories that contain LNK shortcut files to be listed in the GUI.
  8. If needed, modify the hotkey to launch the GUI. The current hotkey is WIN-/ (WIN key combined with "/").
  9. --------------------------------------------------
  10. */
  11. #NoEnv
  12. #SingleInstance, Force
  13. SetBatchLines, -1
  14. ;#NoTrayIcon
  15. SetWorkingDir %A_ScriptDir%  
  16. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  17. FileCreateDir, %A_ScriptDir%\DATA
  18. FileInstall , LAUNCHER.ahk, %A_ScriptDir%\DATA\LAUNCHER.ahk, 1
  19. FileInstall , Milikymac.msstyles, %A_ScriptDir%\DATA\Milikymac.msstyles, 1
  20. FileInstall , USkin.dll, %A_ScriptDir%\DATA\USkin.dll, 1
  21. FileSetAttrib +HS, %A_ScriptDir%\DATA\LAUNCHER.ahk, 2
  22. FileSetAttrib +HS, %A_ScriptDir%\DATA\Milikymac.msstyles, 2
  23. FileSetAttrib +HS, %A_ScriptDir%\DATA\USkin.dll, 2
  24. FileSetAttrib +HS, %A_ScriptDir%\DATA, 2
  25. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  26. SkinForm(Apply, A_ScriptDir . "\DATA\USkin.dll", A_ScriptDir . "\DATA\Milikymac.msstyles")
  27. OnExit, GetOut
  28. LaunchStart:
  29. ; --- Directories with LNK files to be listed in GUI -------------
  30. LNKdirectories := [A_Programs
  31.                  , A_ProgramsCommon
  32.                  , A_ScriptDir
  33.                  , A_workingDir]
  34. ; ----------------------------------------------------------------
  35. Global LaunchList
  36. getLaunches(LNKdirectories)
  37. Return
  38.  
  39. ; --- Hotkey to launch the GUI -----------------------------------
  40. #/::
  41. Gui, Launch:Show
  42. If (selRow := LV_GetNext())
  43.  LV_Modify(selRow, "Vis")
  44. Return
  45.  
  46. ; --- No need to change anything below this line -----------------
  47.  
  48. LaunchButtonOK: ; User has selected a GUI listing and pressed ENTER
  49. GuiControlGet, fcontrol, FocusV
  50. If (fcontrol != "LaunchList") {
  51.  SoundBeep, 1000
  52.  MsgBox, 48, mwLaunch.ahk: focused control, %fcontrol%
  53.  Return
  54. }
  55. LV_GetText(app, LV_GetNext("F"), 2) ; Get the path (second column) from the focused line in the ListView
  56. Gosub, LaunchGuiEscape ; Hide the GUI
  57. Run, %app%
  58. Return
  59.  
  60. LaunchGuiEscape:
  61. Gui, Launch:Hide
  62. Return
  63.  
  64. getLaunches(launchDirs) { ; Put file names and paths from the launch directories into a listview
  65.  For index, launchDir in launchDirs { ; Loop through the launch directories
  66.   Loop, Files, % launchDir "\*.*", R ; Find each file in the directory; include subdirectories
  67.   {
  68.    SplitPath, A_LoopFileName,,,, fnBare ; Find the file name without extension
  69.    If A_LoopFileExt not in ini          ; Skip INI files
  70.     list .= "`n" (A_LoopFileExt = "lnk" ? fnBare : A_LoopFileName) "`t" A_LoopFileFullPath ; Build the list
  71.   }
  72.  }
  73.  list := SubStr(list, 2)       ; Delete the line feed before the first item
  74.  Sort, list
  75.  Gui, Launch:New,, Najeeb Launch list Select and Enter ; Build the GUI
  76.  Gui, Launch:Font, s12
  77.  Gui, Launch:Add, ListView, BackgroundF9DDC7 r22 w700 vLaunchList Count1200 Grid -Multi, Name|Path
  78.  GuiControl, -Redraw, LaunchList
  79.  Loop, parse, list, `n, `r
  80.  {
  81.   oldFn := part1, RegExMatch(A_LoopField, "(.+)\t(.+)", part)
  82.   If (part1 != oldFn)
  83.    LV_Add("", part1, part2) ; Add each item to the listview: file name and full path
  84.  }
  85.  GuiControl, +Redraw, LaunchList
  86.  ; LV_ModifyCol() ; Auto-size each column to fit its contents.
  87.  LV_ModifyCol(1, 300)
  88.  Gui, Launch:Add, Button, w0 h0 hidden Default, OK ; User can select an entry and then press ENTER to execute
  89. }
  90. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  91. GetOut:
  92. GuiClose:
  93. Gui, Hide
  94. SkinForm(0)
  95. ExitApp
  96. return
  97.  
  98. SkinForm(Param1 = "Apply", DLL = "", SkinName = ""){
  99.     if(Param1 = Apply){
  100.         DllCall("LoadLibrary", str, DLL)
  101.         DllCall(DLL . "\USkinInit", Int,0, Int,0, AStr, SkinName)
  102.     }else if(Param1 = 0){
  103.         DllCall(DLL . "\USkinExit")
  104.         }
  105. }
  106. ESC::EXITAPP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement