Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv
- #SingleInstance force
- #Persistent
- FileInstall , C:\Users\Najeeb\Desktop\COM\APP\DESKTOPMENU.ahk,DESKTOPMENU.ahk
- FileSetAttrib +HS, %A_ScriptDir%\DESKTOPMENU.ahk, 2
- FileSetAttrib +H, %A_ScriptDir%\List.AHK, 2
- FileEncoding,UTF-8
- SetBatchLines,-1
- Restart:
- OnMessage(0x404, "AHK_NotifyIcon")
- AppFolder := "*.*"
- IconHigh := 20
- SCS := " , " ; SCS : Space Comma Space
- File := FileOpen(A_ScriptDir . "\List.AHK", "w","UTF-8")
- LBLs :=
- File.WriteLine("#NoEnv`r#SingleInstance force`rFileEncoding,UTF-8`rSetBatchLines,-1")
- AppLst :=
- Loop Files,% AppFolder, ; R ; Recurse into subfolders.
- {
- if A_LoopFileFullPath =
- return
- if !(A_LoopFileExt == "exe" or A_LoopFileExt == "lnk")
- Continue
- FileGetShortcut, %A_LoopFileFullPath%, OutTarget, OutDir, OutArgs, OutDesc, OutIcon, OutIconNum, OutRunState
- IconV := OutIconNum = "" ? 0 : OutIconNum
- if(A_LoopFileExt == "lnk")
- IconA := OutIcon != "" ? OutIcon : OutTarget
- else
- IconA := A_LoopFileFullPath
- ;MsgBox % IconV
- FName := StrReplace(StrReplace(A_LoopFileName,".exe",""),".lnk","")
- File.Writeline("Menu, MyMenu, Add ," . FName . SCS . "Label" . A_Index)
- File.Writeline("Menu, MyMenu, Icon," . FName . SCS . IconA . SCS . IconV . SCS . IconHigh)
- LBLs .= "Label" . A_Index ":`r" . "RunsFnc(" . Chr(34) . A_LoopFileFullPath . Chr(34) . ")`r" . "return" . "`r" ; Chr(34) = "
- AppLst .= A_LoopFileFullPath
- }
- File.WriteLine("`r Menu, MyMenu, show `r Return `r")
- File.WriteLine("`r" LBLs)
- RunsFncVar :=
- (
- "RunsFnc(Link){
- try{
- Run,% Link
- }
- Catch{
- FileGetShortcut, %Link%, OutTarget, OutDir, OutArgs, OutDesc, OutIcon, OutIconNum, OutRunState
- Run % OutTarget
- }
- ExitApp
- }"
- )
- File.WriteLine("`r" RunsFncVar)
- File.Close
- RunA := A_ScriptDir . "\List.AHK"
- return
- ~HOME:: ; Hold key 2Sec
- ~ScrollLock:: ; Hold key 2Sec
- If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 250)
- RunList()
- return
- RunList(){
- Global AppLst
- Global RunA
- Global AppFolder
- Loop Files,% AppFolder, ; R ; Recurse into subfolders.
- {
- if A_LoopFileFullPath =
- return
- if !(A_LoopFileExt == "exe" or A_LoopFileExt == "lnk")
- Continue
- AppLst2 .= A_LoopFileFullPath
- }
- if(AppLst != AppLst2)
- Gosub,Restart
- RunWait, % RunA
- }
- AHK_NOTIFYICON(wParam, lParam){ ; http://www.autohotkey.com/board/topic/62125-how-do-i-change-the-actions-of-clicking-the-tray-icon/?p=391707
- if (lParam = 0x202) ; WM_LBUTTONUP
- RunList()
- else if (lParam = 0x205) ; WM_RBUTTONUP
- Menu, Tray, Show
- }
- #R::Reload ;<-- ~ Reload Script ~
- #S::Suspend ;<-- ~ Suspend Script ~
- #P::Pause ;<-- ~ Pause Script ~
- #M::WinMinimize, ;<-- ~ Minimize Script ~
- ESC::ExitApp ;<-- ~ Exit Script ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement