LoginSignup
5
6

More than 5 years have passed since last update.

AutoHotKeyスクリプトを開く標準のテキストエディタを設定する

Posted at

スクリプト

Set_Registry_Editor_AutoHotkeyScript.ahk
; 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スクリプト用のエディタに失敗しました"
}

使い方

こんな感じで、エディタとして使いたい実行ファイるを本スクリプトファイルにドロップしてください。
画像

あとは、.ahk ファイルを右クリックして [Edit Script]を選択すれば、上記手順で設定したテキストエディタで、.ahkファイルが開かれます!!

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6