Guest User

Untitled

a guest
Oct 17th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. ; Set text editor for editing AutoHotKey script.
  2.  
  3. ShowUsage(){
  4. msgbox, [Usage]: %A_ScriptName% [FullPath of editor application]
  5. }
  6.  
  7. ContainSpace(s)
  8. {
  9. StringGetPos, Pos, s, %A_Space% ,
  10. return Pos >= 0
  11. }
  12.  
  13. SurroundByDoubleQuoteIfNeed(s)
  14. {
  15. if(ContainSpace(s))
  16. s = `"%s%`"
  17.  
  18. return s
  19. }
  20.  
  21. SetRegistryForAutoHotKeyScriptEditor(EditorPath)
  22. {
  23. EditorPath := SurroundByDoubleQuoteIfNeed(EditorPath)
  24. EditorPath = %EditorPath%%A_Space%`"`%1`"
  25. RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit\Command, , %EditorPath%
  26. return ErrorLevel = 0
  27. }
  28.  
  29. ArgCount=%0%
  30. IfNotEqual ArgCount, 1
  31. {
  32. ShowUsage()
  33. return
  34. }
  35.  
  36. EditorPath=%1%
  37.  
  38. IfNotExist, %EditorPath%
  39. {
  40. MsgBox, ファイルが見つかりません: %EditorPath% .
  41. return
  42. }
  43.  
  44. ; エディタの実行ファイルが ~.exe でなければエラー。
  45. StringCaseSense, Off
  46. StringGetPos, Pos, EditorPath, .exe , R
  47. IfEqual, Pos, 0
  48. {
  49. msgbox, .exe ファイルではありません: %EditorPath%
  50. return
  51. }
  52.  
  53. if( SetRegistryForAutoHotKeyScriptEditor(EditorPath) )
  54. {
  55. MsgBox "AutoHotKeyスクリプト用のエディタを設定しました"
  56. }
  57. else
  58. {
  59. MsgBox "AutoHotKeyスクリプト用のエディタに失敗しました"
  60. }
Add Comment
Please, Sign In to add comment