Page options

e


/*
未作测试
*/

;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, NoStandard
Menu, Tray, Add, Change Path, ChangePath
Menu, Tray, Add
Menu, Tray, Add, Exit, ExitScript
Menu, Tray, Default, Exit ;Double click on Icon to exit
Menu, ahkMenu, Add, Run, RunIt
Menu, ahkMenu, Add, Edit, OpenIt
Menu, ahkMenu, Add,
Menu, ahkMenu, Add, Copy, CopyIt
Menu, ahkMenu, Add, Delete, DeleteIt

;Get the old path or a new one
IniRead, AhkPath, AhkPath.ini, AutoHotkey Path, Path ;read path to ahk from IniFile

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

#IfWinActive, ahk_group ExplorerWindows
$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
}

    Post a comment

    Your Name or E-mail ID (mandatory)

    Note: Your comment will be published after approval of the owner.

    No Attachments Found. Click here to upload new file.




     RSS of this page

    Written by:   Version:   Edited By:   Modified