Functionality added: Show icon
You will need Menu Icon v2 here: http://www.autohotke...-menu-icons-v2/
#SingleInstance force ;Skips the dialog box and replaces the old instance automatically
#notrayicon
stringleft, Adrive, A_ScriptDir, 2
XYplorerPath = E:\7Utilities\XYplorer\XYplorer.exe
;↓ Detect Win 64bits ↓
if (DllCall("IsWow64Process", "uint", DllCall("GetCurrentProcess"), "int*", isWow64process) && isWow64process OR IfInString, Processor_Architecture, 64)
{
NircmdPath = %A_ScriptDir%\nircmdx64\nircmd.exe
RegWorkshopPath = E:\2System\Registry Workshop\RegWorkshopX64.exe
UnlockerPath = E:\2System\Unlocker\Unlocker x64\Unlocker x64.exe
NK2EditPath = E:\2System\Nirsoft\nk2edit-x64\NK2Edit.exe
}
else
{
NircmdPath = %A_ScriptDir%\nircmdx32\nircmd.exe
RegWorkshopPath = E:\2System\Registry Workshop\RegWorkshop.exe
UnlockerPath = E:\2System\Unlocker\Unlocker x32\Unlocker.exe
NK2EditPath = E:\2System\Nirsoft\nk2edit\NK2Edit.exe
}
;↑ Detect Win 64bits ↑
;↓ Define main menu items ↓
MenuList=
(
&AHK > Reload AHK > Run Script.ahk
&AHK > Environment > Run Environment.ahk
&AHK > Running AHK Scripts > Run Running AHK scripts.ahk
&AHK > WhatColor > Run WhatColor.ahk
&AHK > Stop AHK > Run %NircmdPath% killprocess autohotkey.exe
&AHK > AHKspy > Run %Adrive%\7Utilities\Launcher\AutoHotkey\AU3_Spy.exe
&Nirsoft > CurrProcess > Run E:\2System\Nirsoft\Current Process\CProcess.exe
&Nirsoft > My Uninstaller > Run E:\2System\Nirsoft\My Uninstaller\myuninst.exe
&Nirsoft > Network traffic view > Run E:\2System\Nirsoft\Network traffic view\NetworkTrafficView.exe
&Nirsoft > NK2Edit > Run %NK2EditPath%
&Nirsoft > OfficeIns > Run E:\2System\Nirsoft\OfficeIns\OfficeIns.exe
&Nirsoft > Opened Files View > Run E:\2System\Nirsoft\Opened files view\OpenedFilesView.exe
&Nirsoft > WhatInStartup > Run E:\2System\Nirsoft\What in startup\WhatInStartup.exe
&Nirsoft > Icon Extract > Run E:\2System\Nirsoft\Icons extract\iconsext.exe
&System > Autorun > Run E:\2System\Autoruns\autoruns.exe
&System > CCleaner > Run E:\2System\CCleaner\CCleaner.exe
&System > Hosts > Run %Editpad% C:\Windows\System32\drivers\etc\hosts
&System > Driver Genius > Run E:\2System\Driver Genius 12\DriverGenius\DriverGenius.exe
&System > MiniTool Partition Wizard > Run E:\2System\Partition management\MiniTool Partition Wizard Professional\PartitionWizard.exe
&System > Registry Workshop > Run %RegWorkshopPath%
&System > Unlocker > Run %UnlockerPath%
&System > UltraISO > Run E:\2System\Virtual drive\UltraISO 9.3 Portable.exe
&System > ScreenSaver > PostMessage, 0x112, 0xF140,0,, Program Manager
&System > Shutdown timing > Run Shutdown.ahk
&System > Core settings > Mute > Send {Volume_Mute}
&System > Core settings > Set 800x600 > Run %NircmdPath% setdisplay 800 600
&System > Core settings > Set 1024x768 > Run %NircmdPath% setdisplay 1024 768
&System > Core settings > Restart Explorer > Run %NircmdPath% restartexplorer
&Office > One Note Sort > Run E:\3Office\OneNote sort\OneNoteSort.exe
&Office > Communicator > Run C:\Program Files\Microsoft Office Communicator\communicator.exe
&Office > Kalkules > Run E:\3Office\Kalkules\Kalkules.exe
&Office > Able2Extract > Run E:\3Office\OCR, Converter\Able2Extract Professional 7.0.exe
&Office > WhiteSmoke > Run E:\3Office\Whitesmoke 2011\WhiteSmoke 2011 Portable\Launch WhiteSmoke.exe
&Office > PDF Password remover > Run E:\3Office\PDF PASSWORD REMOVER 3.0.EXE
&Office > Outlook attach view > Run E:\2System\Nirsoft\Outlook attach view\OutlookAttachView.exe
)
;↑ Define main menu items ↑
;↓ Add menu items from recent document ↓
Loop, %A_AppData%\Microsoft\Windows\Recent\*.lnk
{
FileGetShortcut, %A_LoopFileFullPath%, OutTarget
SplitPath, OutTarget,,,FileExtension,Basename
If FileExtension
RecentItems = %RecentItems%%A_LoopFileTimeAccessed%`t%Basename%`t%OutTarget%`t%FileExtension%`n
}
Loop, %A_AppData%\Microsoft\Office\Recent\*.lnk
{
FileGetShortcut, %A_LoopFileFullPath%, OutTarget
SplitPath, OutTarget,,,FileExtension,Basename
If FileExtension
RecentItems = %RecentItems%%A_LoopFileTimeAccessed%`t%Basename%`t%OutTarget%`t%FileExtension%`n
}
Sort, RecentItems, R ;Sort in reverse order (by time)
Loop, parse, RecentItems, `n
{
if ProcessedItem > 25
break
if A_LoopField = "" ; Omit the last linefeed (blank item) at the end of the list.
continue
StringSplit, FileItem, A_LoopField, %A_Tab% ; Split into parts at the tab char.
ProcessedItem++
Menu, RecentDoc, Add, %FileItem2%, ShowRecentItemsAction
MI_SetMenuItemIcon("RecentDoc", ProcessedItem, AssocQueryApp(FileItem4), 1, 16)
}
Menu, RecentDoc, Add
Menu, RecentDoc, Add, Goto Recent Doc folder, GotoRecentItemsAction
Menu, RecentDoc, Add, Clear all, ClearRecentItemsAction
Menu, RecentDoc, Add, Clear invalid, InvalidRecentItemsAction
Menu, MyMenu, Add, RecentDoc, :RecentDoc
;↑ This is for recent document ↑
;↓ Add menu items from MenuList above ↓
Loop, parse, MenuList, `n
{
StringSplit, MenuLevel,A_LoopField, >
Menulevel1 = %MenuLevel1% ;Remove leading and trailing space thus avoid duplicate menu
Menulevel2 = %MenuLevel2% ;Remove leading and trailing space thus avoid duplicate menu
if(MenuLevel4 = "" )
{
Menu, %MenuLevel1%, Add, %MenuLevel2%, Action
Menu, MyMenu, Add, %MenuLevel1%, :%MenuLevel1%
Command := varize(MenuLevel2) ;Remove illegal characters
%Command% = %MenuLevel3%
if( InStr(MenuLevel3, ".exe") AND InStr(MenuLevel3, "Run") )
IconPath := trim(SubStr(MenuLevel3, InStr(MenuLevel3, "Run") + 3, InStr(MenuLevel3, ".exe") + 1 - InStr(MenuLevel3, "Run")))
Else If( InStr(MenuLevel3, "Run"))
{
Temp := trim(SubStr(MenuLevel3, InStr(MenuLevel3, "Run") + 3))
SplitPath, Temp,,,FileExtension
if( FileExtension = "Lnk")
FileGetShortcut, %Temp%, IconPath
Else
IconPath := AssocQueryApp(FileExtension)
}
MI_SetMenuItemIcon(MenuLevel1, A_LoopField, IconPath, 1, 16)
}
else
{
Menu, %MenuLevel2%, Add, %MenuLevel3%, Action
Menu, %MenuLevel1%, Add, %MenuLevel2%, :%MenuLevel2%
Menu, MyMenu, Add, %MenuLevel1%, :%MenuLevel1%
Command := varize(MenuLevel3) ;Remove illegal characters
%Command% = %MenuLevel4%
if( InStr(MenuLevel4, ".exe") AND InStr(MenuLevel4, "Run") )
{
IconPath := trim(SubStr(MenuLevel4, InStr(MenuLevel4, "Run") + 3, InStr(MenuLevel4, ".exe") + 1 - InStr(MenuLevel4, "Run")))
MI_SetMenuItemIcon(MenuLevel2, A_Index, IconPath, 1, 16)
}
VarSetCapacity(MenuLevel4,0) ;Reset Menulevel4 to blank
}
}
;↑ Process MenuList above ↑
;↓ Add menu items from RegHack folder ↓
Loop, %A_ScriptDir%\RegHack\*.*
{
Menu, RegHack, Add, %A_LoopFileName%, ReghackAction
Menu, &System, Add, RegHack, :RegHack
Menu, MyMenu, Add, &System, :&System
%Command% = varize(A_LoopFileName)
IconPath := AssocQueryApp(A_LoopFileExt)
MI_SetMenuItemIcon("RegHack", A_Index, IconPath, 1, 16)
}
;↑ Read RegHack folder ↑
;Menu, MyMenu, Check, AHK
;Menu, AHK, Check, Reload AHK For cosmetic only
CoordMode, Menu, Screen
X := A_ScreenWidth/2.3
Y := A_ScreenHeight/3.3
Menu, MyMenu, Show, %X%, %Y%
exitapp
Action:
selected := varize(A_ThisMenuItem) ;Remove illegal characters
exe = % %selected%
DynaRun("#notrayicon `n"exe)
exitapp
ReghackAction:
run Reghack\%A_ThisMenuItem%
exitapp
;↓ Recent document Action ↓
GotoRecentItemsAction:
If A_ThisMenuItem =
return
else
Run, %XYplorerPath% %A_AppData%\Microsoft\Windows\Recent
Run, %XYplorerPath% %A_AppData%\Microsoft\Office\Recent
exitapp
ClearRecentItemsAction:
FileDelete, %A_AppData%\Microsoft\Windows\Recent\*.lnk
FileDelete, %A_AppData%\Microsoft\Office\Recent\*.lnk
exitapp
ShowRecentItemsAction:
Run, %A_AppData%\Microsoft\Office\Recent\%A_ThisMenuItem%.Lnk, , UseErrorLevel
Run, %A_AppData%\Microsoft\Windows\Recent\%A_ThisMenuItem%.Lnk, , UseErrorLevel
exitapp
InvalidRecentItemsAction:
Loop, %A_AppData%\Microsoft\Windows\Recent\*.lnk
{
FileGetShortcut, %A_LoopFileFullPath%, RealFile
Ifnotexist, %RealFile%
FileDelete, %A_LoopFileFullPath%
}
Loop, %A_AppData%\Microsoft\Office\Recent\*.lnk
{
FileGetShortcut, %A_LoopFileFullPath%, RealFile
Ifnotexist, %RealFile%
FileDelete, %A_LoopFileFullPath%
}
exitapp
;↑ This is for recent document ↑
;Function Library:
AssocQueryApp(ext) {
RegRead, type, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.%Ext%, Application
If !ErrorLevel { ;Current user has overridden default setting
RegRead, act, HKCU, Software\Classes\Applications\%type%\shell
If ErrorLevel
act = open
RegRead, cmd, HKCU, Software\Classes\Applications\%type%\shell\%act%\command
}
Else { ;Default setting
RegRead, type, HKCR, .%Ext%
RegRead, act , HKCR, %type%\shell
If ErrorLevel
act = open
RegRead, cmd , HKCR, %type%\shell\%act%\command
EXEPosition := InStr(cmd,".exe",false,0,1)
exepath := Trim(SubStr(cmd,1,EXEPosition+3),"""")
}
Return, exepath
}
DynaRun(TempScript, pipename="")
{
static _:="uint",@:="Ptr"
If pipename =
name := "AHK" A_TickCount
Else
name := pipename
__PIPE_GA_ := DllCall("CreateNamedPipe","str","\\.\pipe\" name,_,2,_,0,_,255,_,0,_,0,@,0,@,0)
__PIPE_ := DllCall("CreateNamedPipe","str","\\.\pipe\" name,_,2,_,0,_,255,_,0,_,0,@,0,@,0)
if (__PIPE_=-1 or __PIPE_GA_=-1)
Return 0
Run, %A_AhkPath% "\\.\pipe\%name%",,UseErrorLevel HIDE, PID
If ErrorLevel
MsgBox, 262144, ERROR,% "Could not open file:`n" __AHK_EXE_ """\\.\pipe\" name """"
DllCall("ConnectNamedPipe",@,__PIPE_GA_,@,0)
DllCall("CloseHandle",@,__PIPE_GA_)
DllCall("ConnectNamedPipe",@,__PIPE_,@,0)
script := (A_IsUnicode ? chr(0xfeff) : (chr(239) . chr(187) . chr(191))) TempScript
if !DllCall("WriteFile",@,__PIPE_,"str",script,_,(StrLen(script)+1)*(A_IsUnicode ? 2 : 1),_ "*",0,@,0)
Return A_LastError
DllCall("CloseHandle",@,__PIPE_)
Return PID
}
varize(var, autofix = true) {
Loop, Parse, var
{ c = %A_LoopField%
x := Asc(c)
If (x > 47 and x < 58) or (x > 64 and x < 91) or (x > 96 and x < 123)
or c = "#" or c = "_" or c = "@" or c = "$" or c = "?" or c = "[" or c = "]"
IfEqual, autofix, 1, SetEnv, nv, %nv%%c%
Else er++
} If StrLen(var) > 254
IfEqual, autofix, 1, StringLeft, var, var, 254
Else er++
IfEqual, autofix, 1, Return, nv
Else Return, er
}