Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rohinomiya/2876046 to your computer and use it in GitHub Desktop.
Save rohinomiya/2876046 to your computer and use it in GitHub Desktop.
AutoHotKeyスクリプトを開く標準のテキストエディタを設定する ref: http://qiita.com/items/50de27ef9e498915146c
; Set text editor for editing AutoHotKey script.
ShowUsage(){
msgbox, [Usage]: %A_ScriptName% [FullPath of editor application]
}
ContainSpace(s)
{
StringGetPos, Pos, s, %A_Space% ,
return Pos >= 0
}
SurroundByDoubleQuoteIfNeed(s)
{
if(ContainSpace(s))
s = `"%s%`"
return s
}
SetRegistryForAutoHotKeyScriptEditor(EditorPath)
{
EditorPath := SurroundByDoubleQuoteIfNeed(EditorPath)
EditorPath = %EditorPath%%A_Space%`"`%1`"
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit\Command, , %EditorPath%
return ErrorLevel = 0
}
ArgCount=%0%
IfNotEqual ArgCount, 1
{
ShowUsage()
return
}
EditorPath=%1%
IfNotExist, %EditorPath%
{
MsgBox, ファイルが見つかりません: %EditorPath% .
return
}
; エディタの実行ファイルが ~.exe でなければエラー。
StringCaseSense, Off
StringGetPos, Pos, EditorPath, .exe , R
IfEqual, Pos, 0
{
msgbox, .exe ファイルではありません: %EditorPath%
return
}
if( SetRegistryForAutoHotKeyScriptEditor(EditorPath) )
{
MsgBox "AutoHotKeyスクリプト用のエディタを設定しました"
}
else
{
MsgBox "AutoHotKeyスクリプト用のエディタに失敗しました"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment