Skip to content

Instantly share code, notes, and snippets.

@sonhanguyen
Forked from budRich/NexusFolder.ahk
Last active November 12, 2017 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonhanguyen/d3af37dc88275ab34e707970a649743b to your computer and use it in GitHub Desktop.
Save sonhanguyen/d3af37dc88275ab34e707970a649743b 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
}
ExploreFolder(cmd)
}
ExitApp
ExploreFolder(fld) {
nexTtl := "NexusFile ahk_class TfMain"
if !WinExist(nexTtl)
Run, NexusFile.exe
WinActivate, %nexTtl%
WinWaitActive, %nexTtl%
ControlClick, TNXPaintPanel2,%nexTtl%,,right,,NA
Send,/cd %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