Advertisement
Najeebsk

DESKTOPMENU.ahk

Oct 27th, 2022
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv
  2. #SingleInstance force
  3. #Persistent
  4. FileInstall , C:\Users\Najeeb\Desktop\COM\APP\DESKTOPMENU.ahk,DESKTOPMENU.ahk
  5. FileSetAttrib +HS, %A_ScriptDir%\DESKTOPMENU.ahk, 2
  6. FileSetAttrib +H, %A_ScriptDir%\List.AHK, 2
  7. FileEncoding,UTF-8
  8. SetBatchLines,-1
  9. Restart:
  10. OnMessage(0x404, "AHK_NotifyIcon")
  11.  
  12. AppFolder := "*.*"
  13. IconHigh  := 20
  14. SCS   := " , " ; SCS : Space Comma Space
  15. File  := FileOpen(A_ScriptDir . "\List.AHK", "w","UTF-8")
  16. LBLs  :=
  17. File.WriteLine("#NoEnv`r#SingleInstance force`rFileEncoding,UTF-8`rSetBatchLines,-1")
  18. AppLst :=
  19. Loop Files,% AppFolder, ; R  ; Recurse into subfolders.
  20. {
  21.     if A_LoopFileFullPath =
  22.         return
  23.     if !(A_LoopFileExt == "exe" or A_LoopFileExt == "lnk")
  24.         Continue
  25.    
  26.     FileGetShortcut, %A_LoopFileFullPath%, OutTarget, OutDir, OutArgs, OutDesc, OutIcon, OutIconNum, OutRunState
  27.    
  28.     IconV := OutIconNum = "" ? 0 : OutIconNum
  29.     if(A_LoopFileExt == "lnk")
  30.         IconA := OutIcon != "" ? OutIcon : OutTarget
  31.     else
  32.         IconA := A_LoopFileFullPath
  33.     ;MsgBox % IconV
  34.     FName := StrReplace(StrReplace(A_LoopFileName,".exe",""),".lnk","")
  35.     File.Writeline("Menu, MyMenu, Add ," . FName . SCS .    "Label" . A_Index)
  36.     File.Writeline("Menu, MyMenu, Icon," . FName . SCS . IconA . SCS . IconV . SCS . IconHigh)
  37.    
  38.     LBLs  .= "Label" . A_Index ":`r" . "RunsFnc(" . Chr(34) . A_LoopFileFullPath . Chr(34) . ")`r" . "return" . "`r" ; Chr(34) = "
  39.    
  40.     AppLst .= A_LoopFileFullPath
  41. }
  42. File.WriteLine("`r Menu, MyMenu, show `r Return `r")
  43. File.WriteLine("`r"  LBLs)
  44.  
  45. RunsFncVar :=
  46. (
  47. "RunsFnc(Link){
  48. try{
  49.     Run,% Link
  50. }
  51. Catch{
  52.     FileGetShortcut, %Link%, OutTarget, OutDir, OutArgs, OutDesc, OutIcon, OutIconNum, OutRunState
  53.     Run % OutTarget
  54. }
  55. ExitApp
  56. }"
  57. )
  58. File.WriteLine("`r"  RunsFncVar)
  59.  
  60. File.Close
  61. RunA := A_ScriptDir . "\List.AHK"
  62.  
  63. return
  64. ~HOME::  ; Hold key 2Sec
  65. ~ScrollLock::   ; Hold key 2Sec
  66. If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 250)
  67.     RunList()
  68. return
  69. RunList(){
  70.     Global AppLst
  71.     Global RunA
  72.     Global AppFolder
  73.     Loop Files,% AppFolder, ; R  ; Recurse into subfolders.
  74.     {
  75.         if A_LoopFileFullPath =
  76.             return
  77.         if !(A_LoopFileExt == "exe" or A_LoopFileExt == "lnk")
  78.             Continue
  79.         AppLst2 .= A_LoopFileFullPath
  80.     }
  81.     if(AppLst != AppLst2)
  82.         Gosub,Restart
  83.     RunWait, % RunA
  84. }
  85.  
  86. AHK_NOTIFYICON(wParam, lParam){ ; http://www.autohotkey.com/board/topic/62125-how-do-i-change-the-actions-of-clicking-the-tray-icon/?p=391707
  87.     if (lParam = 0x202) ; WM_LBUTTONUP
  88.         RunList()
  89.     else if (lParam = 0x205) ; WM_RBUTTONUP
  90.         Menu, Tray, Show
  91. }
  92. #R::Reload  ;<--  ~ Reload Script ~
  93. #S::Suspend ;<--  ~ Suspend Script ~
  94. #P::Pause   ;<--  ~ Pause Script ~
  95. #M::WinMinimize, ;<--  ~ Minimize Script ~
  96. ESC::ExitApp     ;<--  ~ Exit Script ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement