-
-
Save sonhanguyen/d3af37dc88275ab34e707970a649743b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
## 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