Advertisement
congdantoancau

Programing Notepad (Auto tab)

Jan 21st, 2018
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5. SetTitleMatchMode, 2
  6. ; ______________________________________________________________________________________
  7. ; https://autohotkey.com/board/topic/43509-count-number-of-specific-character-in-string/
  8. ; https://autohotkey.com/board/topic/64454-solved-avoiding-multiple-ifinstring-or-if-with-an-or/
  9.  
  10. #If WinActive("メモ帳")
  11.  
  12. Enter::
  13. ClipSaved := Clipboard
  14. Send, +{home}
  15. Send, ^c
  16. Send, {end}
  17. Send, {Enter}
  18. Sleep, 100
  19. line := Clipboard
  20. StringReplace line,line,`t,`t,UseErrorLevel
  21. t := ErrorLevel
  22. tplus := t + 1
  23.  
  24. if Instr(line, "{") or Instr(line, ")")
  25. {
  26.     Loop, %tplus%
  27.     {
  28.         Send, `t
  29.     }
  30. }
  31. else
  32. {
  33.     Loop, %t%
  34.     {
  35.         Send, `t
  36.     }
  37. }
  38. Clipboard := ClipSaved
  39. return
  40.  
  41. +[::
  42. ClipSaved := Clipboard
  43. Send, +{home}
  44. Send, ^c
  45. Send, {end}
  46. Sleep, 100
  47. line := Clipboard
  48. If InStr(line, "if") or InStr(line, "while") or InStr(line, "for")
  49. {}
  50. else
  51.     Send, {bs}
  52. Send, {{}
  53. Clipboard := ClipSaved
  54. return
  55.  
  56. +]::
  57. ClipSaved := Clipboard
  58. Send, +{home}
  59. Send, ^c
  60. Send, {end}
  61. Sleep, 100
  62. line := Clipboard
  63. StringReplace line,line,`{,`{,UseErrorLevel
  64. open := ErrorLevel
  65. if (open < 1)
  66. {
  67.     Send, {left}
  68.     Send, {bs}
  69.     Send, {right}
  70. }
  71. Send, {}}
  72. Clipboard := ClipSaved
  73. return
  74.  
  75. #If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement