Skip to content

Instantly share code, notes, and snippets.

@budRich
Created August 30, 2013 21:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save budRich/6394610 to your computer and use it in GitHub Desktop.
Save budRich/6394610 to your computer and use it in GitHub Desktop.
/*
## NexusFolder.ahk
##
## Switch default filemanager by launching this script without
## commandline parameters. If you send a file or folder as a
## parameter, the folder will open in NexusFile.
##
## Script by budRich 2013
*/
GoSub, Init
If !FileExist("NexusFile.exe") {
MsgBox,Move %A_ScriptName% to the same foler as NexusFile.exe.
ExitApp
}
If !(cmd) {
RegRead, rchk, HKCR, Drive\shell\NexusFile
If (ErrorLevel=1)
RegNexus()
Else
RegExplorer()
} Else {
If !FileExist(cmd) {
MsgBox,%cmd% does not exist.
ExitApp
}
Loop, %cmd%,1
fld := ( (A_LoopFileExt) ? (A_LoopFileDir) : (A_LoopFileLongPath) )
ExploreFolder(fld)
}
ExitApp
ExploreFolder(fld) {
nexTtl := "NexusFile ahk_class TfMain"
if !WinExist(nexTtl)
Run, NexusFile.exe
WinActivate, %nexTtl%
WinWaitActive, %nexTtl%
ControlClick, TNXPaintPanel2,%nexTtl%,,right,,NA
Send,{DOWN 2}{Enter}%fld%{Enter}
}
RegNexus() {
MsgBox, 4,,Do you want to set NexusFile as the default file manager?
IfMsgBox, Yes
{
RegWrite, REG_SZ, HKCR, Drive\shell\,,NexusFile
RegWrite, REG_SZ, HKCR, Drive\shell\NexusFile,, Open in NexusFile
RegWrite, REG_SZ, HKCR, Directory\shell,,NexusFile
RegWrite, REG_SZ, HKCR, Directory\shell\NexusFile,, Open in NexusFile
if !A_IsCompiled
{ RegWrite, REG_SZ, HKCR, Drive\shell\NexusFile\command,, %A_AhkPath% %A_ScriptFullPath% `%1
RegWrite, REG_SZ, HKCR, Directory\shell\NexusFile\command,, %A_AhkPath% %A_ScriptFullPath% `%1
}
else
{ RegWrite, REG_SZ, HKCR, Drive\shell\NexusFile\command,, %A_ScriptFullPath% `%1
RegWrite, REG_SZ, HKCR, Directory\shell\NexusFile\command,, %A_ScriptFullPath% `%1
}
}
}
RegExplorer() {
MsgBox, 4,,Do you want to set Explorer as the default file manager?
IfMsgBox, Yes
{
RegWrite, REG_SZ, HKCR, Drive\shell\,,none
RegDelete, HKCR, Drive\shell\NexusFile,
RegWrite, REG_SZ, HKCR, Directory\shell,,none
RegDelete, HKCR, Directory\shell\NexusFile,
}
}
Init:
#SingleInstance force
#NoEnv
#NoTrayIcon
SetBatchLines, -1
SetWinDelay, -1
SetWorkingDir, %A_ScriptDir%
SendMode, Input
cmd = %1%
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment