171 lines
4.7 KiB
Plaintext
171 lines
4.7 KiB
Plaintext
#SingleInstance Off
|
|
#Include options.ahk
|
|
|
|
;INIT MENU
|
|
Menu, NavMenu, Add
|
|
|
|
k_args_len=%0%
|
|
|
|
if (k_args_len == 0)
|
|
{
|
|
MsgBox,, NavigatorUtil, No arguments given. Specify "CheckReg", "AddItem", "Copy", or "Uninstall"
|
|
ExitApp
|
|
}
|
|
|
|
Loop, %0%
|
|
{
|
|
if (A_Index > 1)
|
|
{
|
|
k_arg := %A_Index%
|
|
k_index := A_Index - 1
|
|
k_args%k_index% := k_arg
|
|
}
|
|
}
|
|
GoSub, %1%
|
|
ExitApp
|
|
|
|
CheckReg:
|
|
#Include CheckReg.ahk
|
|
return
|
|
|
|
WriteReg:
|
|
if not (A_IsAdmin)
|
|
{
|
|
; Circular loop for admin privileges
|
|
Run *RunAs "%A_ScriptFullPath%" WriteReg /restart
|
|
ExitApp
|
|
}
|
|
|
|
; Add to Navigator contexts
|
|
|
|
; Folder context
|
|
RegWrite, REG_SZ, HKCR, Directory\shell\Navigator_Add,, Add folder to Navigator
|
|
RegWrite, REG_SZ, HKCR, Directory\shell\Navigator_Add, Icon, "%A_ScriptFullPath%"
|
|
RegWrite, REG_SZ, HKCR, Directory\shell\Navigator_Add\command,, "%A_ScriptFullPath%" "AddItem" "`%V"
|
|
|
|
; Background context
|
|
RegWrite, REG_SZ, HKCR, Directory\Background\shell\Navigator_Add,, Add folder to Navigator
|
|
RegWrite, REG_SZ, HKCR, Directory\Background\shell\Navigator_Add, Icon, "%A_ScriptFullPath%"
|
|
RegWrite, REG_SZ, HKCR, Directory\Background\shell\Navigator_Add\command,, "%A_ScriptFullPath%" "AddItem" "`%V"
|
|
|
|
; File context
|
|
RegWrite, REG_SZ, HKCR, *\shell\Navigator_Add,, Add file to Navigator
|
|
RegWrite, REG_SZ, HKCR, *\shell\Navigator_Add, Icon, "%A_ScriptFullPath%"
|
|
RegWrite, REG_SZ, HKCR, *\shell\Navigator_Add\command,, "%A_ScriptFullPath%" "AddItem" "`%1"
|
|
|
|
|
|
; Copy location contexts
|
|
|
|
; Folder context
|
|
RegWrite, REG_SZ, HKCR, Directory\shell\Navigator_Copy,, Copy folder location
|
|
RegWrite, REG_SZ, HKCR, Directory\shell\Navigator_Copy, Icon, "%A_ScriptFullPath%"
|
|
RegWrite, REG_SZ, HKCR, Directory\shell\Navigator_Copy\command,, "%A_ScriptFullPath%" "Copy" "`%V"
|
|
|
|
; Background context
|
|
RegWrite, REG_SZ, HKCR, Directory\Background\shell\Navigator_Copy,, Copy folder location
|
|
RegWrite, REG_SZ, HKCR, Directory\Background\shell\Navigator_Copy, Icon, "%A_ScriptFullPath%"
|
|
RegWrite, REG_SZ, HKCR, Directory\Background\shell\Navigator_Copy\command,, "%A_ScriptFullPath%" "Copy" "`%V"
|
|
|
|
; File context
|
|
RegWrite, REG_SZ, HKCR, *\shell\Navigator_Copy,, Copy file location
|
|
RegWrite, REG_SZ, HKCR, *\shell\Navigator_Copy, Icon, "%A_ScriptFullPath%"
|
|
RegWrite, REG_SZ, HKCR, *\shell\Navigator_Copy\command,, "%A_ScriptFullPath%" "Copy" "`%1"
|
|
|
|
return
|
|
|
|
Uninstall:
|
|
RegRead, k_reg, HKCR, Directory\shell\Navigator_Add
|
|
if k_reg <>
|
|
{
|
|
if not (A_IsAdmin)
|
|
{
|
|
; Circular loop for admin privileges
|
|
Run *RunAs "%A_ScriptFullPath%" Uninstall /restart
|
|
ExitApp
|
|
}
|
|
}
|
|
|
|
MsgBox, 35, Navigator, Uninstalling Navigator...`nWould you like to keep your config.ini?
|
|
IfMsgBox, Cancel
|
|
{
|
|
ExitApp
|
|
} else {
|
|
RegDelete, HKCR, Directory\shell\Navigator_Add
|
|
RegDelete, HKCR, Directory\Background\shell\Navigator_Add
|
|
RegDelete, HKCR, *\shell\Navigator_Add
|
|
RegDelete, HKCR, Directory\shell\Navigator_Copy
|
|
RegDelete, HKCR, Directory\Background\shell\Navigator_Copy
|
|
RegDelete, HKCR, *\shell\Navigator_Copy
|
|
}
|
|
IfMsgBox, Yes
|
|
{
|
|
Run, %ComSpec% /c "TASKKILL /f /im `"Navigator.exe`" > nul 2> nul & SLEEP 1 > nul 2> nul & DEL %A_ScriptDir%\*.bat > nul 2> nul & DEL %A_ScriptDir%\*.exe > nul 2> nul" ; Batch files and exe files
|
|
} else IfMsgBox, No
|
|
{
|
|
Run, %ComSpec% /c "TASKKILL /f /im `"Navigator.exe`" > nul 2> nul & SLEEP 1 > nul 2> nul & RD /S /Q %A_ScriptDir% > nul 2> nul"
|
|
}
|
|
return
|
|
|
|
AddItem:
|
|
Gui, Menu
|
|
Menu, NavMenu, DeleteAll
|
|
CreateMenu("NavMenu")
|
|
Menu, NavMenu, Show
|
|
return
|
|
|
|
Copy:
|
|
Clipboard = %k_args1%
|
|
return
|
|
|
|
ReloadConfig:
|
|
IniRead, k_address, %k_config%, System, Address
|
|
DllCall(%k_address%)
|
|
return
|
|
|
|
Select(menu_name) {
|
|
global k_config, k_args1
|
|
InputBox, k_label, Navigator, %menu_name%`nPlease enter the name of the new menu item
|
|
if (k_label <> "")
|
|
{
|
|
IniWrite, %k_label%`,%k_args1%, %k_config%, %menu_name%
|
|
GoSub, ReloadConfig
|
|
} else {
|
|
MsgBox, 21, Navigator, You must enter a name for this sub-menu.
|
|
IfMsgBox, Retry
|
|
{
|
|
Select(menu_name)
|
|
}
|
|
}
|
|
}
|
|
|
|
CreateMenu(menu_name) {
|
|
global k_config, k_ext_pattern
|
|
IniRead, k_nav_config, %k_config%, %menu_name%
|
|
If (k_nav_config == "")
|
|
{
|
|
MsgBox,, %menu_name%, No paths found for this sub-menu, please add some to the config.
|
|
}
|
|
StringSplit, k_nav, k_nav_config, `n
|
|
Loop, %k_nav0%
|
|
{
|
|
StringSplit, k_nav_array, k_nav%A_Index%, `,
|
|
If (k_nav_array0 == 1)
|
|
{
|
|
; No path, so this is a new menu
|
|
Menu, %k_nav_array1%, Add
|
|
Menu, %k_nav_array1%, DeleteAll
|
|
k_menu_name := k_nav_array1
|
|
k_menu_ini := k_nav_array1
|
|
StringSplit, k_menu_array, k_menu_name, |
|
|
If (k_menu_array0 > 1)
|
|
{
|
|
k_menu_name := k_menu_array2
|
|
k_menu_ini := k_menu_array1
|
|
}
|
|
CreateMenu(k_menu_ini)
|
|
Menu, %menu_name%, Add, %k_menu_name%, :%k_menu_ini%
|
|
}
|
|
}
|
|
fn := Func("Select").Bind(menu_name)
|
|
Menu, %menu_name%, Add, Select This Menu, %fn%
|
|
} |