/*
未作测试
*/
;Script to make Temporary File Association for Ahk Files
;Double click on script opens it with the AutoHotkey.exe path you select on running
;Right click on a script opens a custom menu for edit and stuff.
;Made by None for people who like to run portable
;Make Some Menus
Menu, Tray, Add
Menu, Tray, Default, Exit ;Double click on Icon to exit
Menu, ahkMenu, Add, Run,
RunItMenu, ahkMenu, Add, Edit,
OpenItMenu, ahkMenu, Add,
Menu, ahkMenu, Add, Copy,
CopyIt
;Get the old path or a new one
IfNotExist, %AhkPath% ;if path not valid
AhkPath:=GetPath() ;get new path
If (AhkPath="Cancled") ;if you cancel the find ahk and there is no previous path exit
ExitApp
GroupAdd, ExplorerWindows, ahk_class Progman ;Desktop
GroupAdd, ExplorerWindows, ahk_class
CabinetWClass ;Explorer Window
GroupAdd, ExplorerWindows, ahk_class
ExploreWClass ;Other Explorer Window
Return ;end of Auto Execute
$LButton::
If (A_TimeSincePriorHotkey>400) or (A_TimeSincePriorHotkey=-1)
{
Send {LButton Down}
KeyWait LButton
Send {LButton Up}
Return
}
FilePath:=GetFile()
SplitPath, FilePath,,,Ext
If (Ext="ahk")
Run %AhkPath% "%FilePath%"
Else
Send {LButton} ;second Click of Double
Return
$Rbutton::
Send {LButton} ;to select the file under mouse
FilePath:=GetFile()
SplitPath, FilePath,,,Ext
If (Ext="ahk")
Menu, ahkMenu, Show
Else
{
Send {RButton Down}
KeyWait RButton
Send {RButton Up}
Return
}
Return
;Labels and Functions
ChangePath:
AhkPath:=GetPath(AhkPath) ;if Cancled previous path used
Return
ExitScript:
RunIt:
Run %AhkPath% "%FilePath%"
Return
Openit:
Run Notepad.exe "%FilePath%"
Return
CopyIt:
Send ^c
Return
DeleteIt:
FileRecycle, %FilePath%
Return
GetPath(Old="Cancled") {
FileSelectFile, tempvar , 3, %A_ScriptDir%, Find AutoHotkey.exe, AutoHotkey.exe
If !ErrorLevel
{
IniWrite, %tempvar%, AHKpath.ini,
AutoHotkey Path, Path
Return tempvar
}
Return Old
}
GetFile() {
ClipSave:=ClipboardAll
Clipboard:=""
Send ^c
ClipWait, .2
Path=%clipboard%
Clipboard:=ClipSave
Return Path
}