Advertisement
unluckyscarecrow

Untitled

Nov 22nd, 2017
1,357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.52 KB | None | 0 0
  1. ^b::
  2. ; Welcome to u/UnluckyScarecrow 's AutoHotKey perform macro
  3.  
  4. ; Time in miliseconds to wait between notes.
  5. ; Reference:
  6. ; 500 = 2 per second ; 333 = 3 per second ; 250 = 4 per second
  7. ; 200 = 5 per second ; 166 = 6 per second ; 143 = 7 per second ; 125 = 8 per second
  8. ; Caution - Performance actions may not be able to be used as fast as a song requires, and going too fast may cause notes to be skipped.
  9. TimeBetween := 166
  10.  
  11. ; Map each note to your hotkeys here
  12. ; Reminder - put ^ before the key to indicate holding Ctrl
  13. ; Put + before the key to indicate holding Shift
  14. ; First octave
  15. CMinus := "1"
  16. CsMinus := "2"
  17. DMinus := "3"
  18. EbMinus := "4"
  19. EMinus := "5"
  20. FMinus := "6"
  21. FsMinus := "7"
  22. GMinus := "8"
  23. GsMinus := "9"
  24. AMinus := "0"
  25. BbMinus := "-"
  26. BMinus := "="
  27. ; Second octave
  28. CMid := "^1"
  29. CsMid := "^2"
  30. DMid := "^3"
  31. EbMid := "^4"
  32. EMid := "^5"
  33. FMid := "^6"
  34. FsMid := "^7"
  35. GMid := "^8"
  36. GsMid := "^9"
  37. AMid := "^0"
  38. BbMid := "^-"
  39. BMid := "^="
  40. ; Third octave
  41. CPlus := "+1"
  42. CsPlus := "+2"
  43. DPlus := "+3"
  44. EbPlus := "+4"
  45. EPlus := "+5"
  46. FPlus := "+6"
  47. FsPlus := "+7"
  48. GPlus := "+8"
  49. GsPlus := "+9"
  50. APlus := "+0"
  51. BbPlus := "+-"
  52. BPlus := "+="
  53. ; High C
  54. CPlusPlus := "]"
  55.  
  56. ; The Pause and Stop hotkeys
  57. StopKey := "x"
  58. PauseKey := "v"
  59.  
  60. ; Put the notes to play in the list below.
  61. ; Make sure each note is enclused with double quotes. To indicate a pause or blank note, any character that is not recognized as a note will work.
  62. ; Note that AHK seems to struggle having too many items in a list when compiling. Therefore, you may need to make a second list and combine them. A sample is below.
  63. NoteList := ["E","-","F","-","G","-","F","-","C+","-","D+","-","C+","-","-","-","B","-","C+","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-"
  64. ,"D","-","E","-","F","-","A","-","F","-","E","-","D","-","-","-","C","-","A-","-","-","-","A-","-","D","-","E","-","F","-"
  65. ,"G","-","F","-","E","-","D","-","-","-","C","-","D","-","-","-","-","-"
  66. ,"D","-","E","-","F","-","A","-","F","-","E","-","D","-","-","-","C","-","A-","-","-","-","A-","-","D","-","E","-","F","-"
  67. ,"G","-","F","-","E","-","D","-","-","-","C","-","D","-","-","-","-","-"
  68. ,"F","-","-","-","G","-","E","-","-","-","E","-","F","-","G","-","A","-","G","-","F","-","E","F","F","-","G","-","A","-"
  69. ,"B","-","C+","-","D+","-","C+","-","-","-","A","B","A","B","G","D","A-","D","B","-","-","-","C+","-","A","-","-","-","A","-"
  70. ,"B","-","C+","-","E+","-","D+","-","C+","-","B","C+","-","-","D+","-","F+","-","E+","-","G+","-","C++","-","F+","-","-","-","-","-","F+","-","-","-","-","-"
  71. ,"C+","-","F+","G+","A+","-","C+","-","F+","G+","A+","-","B+","-","A+","-","G+","A+","G+","-","E+","-","B","-"]
  72. NoteList2 := ["D+","-","G+","A+","B+","-","A+","-","F+","-","C+","-","D+","-","-","-","G+","-","F+","-","C++","-","A+","-","G+","-","E+","F+","G+","-"
  73. ,"A+","-","F+","G+","A+","B+","G+","F+","C+","G+","F+","-","F+","E+","B","E+","B","-","A","-","F","G","A","-","G","-","E","-","G","-","F","-","-","-","C+","D+","F+"] ; I broke a rule at the end of this line
  74.  
  75. ; This short loop will merge the two above lists. Copy as many times as needed.
  76. for Key, Note in NoteList2 {
  77. NoteList.Insert(Note)
  78. }
  79.  
  80. ; This section translates notes in the list into hotkeys
  81. for Key, Note in NoteList {
  82. if NoteList[Key] = "C-" ; FIRST OCTAVE
  83. NoteList[Key] := CMinus
  84. else if NoteList[Key] = "C#-"
  85. NoteList[Key] := CsMinus
  86. else if NoteList[Key] = "D-"
  87. NoteList[Key] := DMinus
  88. else if NoteList[Key] = "Eb-"
  89. NoteList[Key] := EbMinus
  90. else if NoteList[Key] = "E-"
  91. NoteList[Key] := EMinus
  92. else if NoteList[Key] = "F-"
  93. NoteList[Key] := FMinus
  94. else if NoteList[Key] = "F#-"
  95. NoteList[Key] := FsMinus
  96. else if NoteList[Key] = "G-"
  97. NoteList[Key] := GMinus
  98. else if NoteList[Key] = "G#-"
  99. NoteList[Key] := GsMinus
  100. else if NoteList[Key] = "A-"
  101. NoteList[Key] := AMinus
  102. else if NoteList[Key] = "Bb-"
  103. NoteList[Key] := BbMinus
  104. else if NoteList[Key] = "B-"
  105. NoteList[Key] := BMinus
  106. else if NoteList[Key] = "C" ; SECOND OCTAVE
  107. NoteList[Key] := CMid
  108. else if NoteList[Key] = "C#"
  109. NoteList[Key] := CsMid
  110. else if NoteList[Key] = "D"
  111. NoteList[Key] := DMid
  112. else if NoteList[Key] = "Eb"
  113. NoteList[Key] := EbMid
  114. else if NoteList[Key] = "E"
  115. NoteList[Key] := EMid
  116. else if NoteList[Key] = "F"
  117. NoteList[Key] := FMid
  118. else if NoteList[Key] = "F#"
  119. NoteList[Key] := FsMid
  120. else if NoteList[Key] = "G"
  121. NoteList[Key] := GMid
  122. else if NoteList[Key] = "G#"
  123. NoteList[Key] := GsMid
  124. else if NoteList[Key] = "A"
  125. NoteList[Key] := AMid
  126. else if NoteList[Key] = "Bb"
  127. NoteList[Key] := BbMid
  128. else if NoteList[Key] = "B"
  129. NoteList[Key] := BMid
  130. else if NoteList[Key] = "C+" ; THIRD OCTAVE
  131. NoteList[Key] := CPlus
  132. else if NoteList[Key] = "C#+"
  133. NoteList[Key] := CsPlus
  134. else if NoteList[Key] = "D+"
  135. NoteList[Key] := DPlus
  136. else if NoteList[Key] = "Eb+"
  137. NoteList[Key] := EbPlus
  138. else if NoteList[Key] = "E+"
  139. NoteList[Key] := EPlus
  140. else if NoteList[Key] = "F+"
  141. NoteList[Key] := FPlus
  142. else if NoteList[Key] = "F#+"
  143. NoteList[Key] := FsPlus
  144. else if NoteList[Key] = "G+"
  145. NoteList[Key] := GPlus
  146. else if NoteList[Key] = "G#+"
  147. NoteList[Key] := GsPlus
  148. else if NoteList[Key] = "A+"
  149. NoteList[Key] := APlus
  150. else if NoteList[Key] = "Bb+"
  151. NoteList[Key] := BbPlus
  152. else if NoteList[Key] = "B+"
  153. NoteList[Key] := BPlus
  154. else if NoteList[Key] = "C++" ; C++
  155. NoteList[Key] := CPlusPlus
  156. else
  157. NoteList[Key] := ""
  158. }
  159. Sleep, 500
  160.  
  161. ; Setting default values for pause/stop state
  162. GetKeyState, state, %StopKey%
  163. GetKeyState, state2, %PauseKey%
  164.  
  165. ; Begin playing
  166. for Key, Note in NoteList {
  167. keypress := Note
  168. keystate := 0
  169. ; For anybody familiar with AHK, I found that using ^ or + to tell AHK to send Ctrl+ or Shift+ keys wasn't very reliable and missed it often
  170. ; By sending Ctrl down first, we guarentee it will always be down when it's supposed to.
  171. ; If anybody knows why this happens, whether it's a quirk of AHK or a quirk of FFXIV, let me know!
  172. if (SubStr(keypress,1,1) = "^") {
  173. Send {Ctrl down}
  174. keystate := 1
  175. keypress := SubStr(keypress,2,1)
  176. }
  177. else if (SubStr(keypress,1,1) = "+") {
  178. Send {Shift down}
  179. keystate := 2
  180. keypress := SubStr(keypress,2,1)
  181. }
  182. Sleep, (TimeBetween // 2)
  183. Send, %keypress%
  184. Sleep, (TimeBetween // 2)
  185. if keystate = 1
  186. Send {Ctrl up}
  187. else keystate = 2
  188. Send {Shift up}
  189.  
  190. GetKeyState, state, %StopKey%
  191. GetKeyState, state2, %PauseKey%
  192. if state2 = D
  193. {
  194. ; When the pause key is held down, script enters both loops
  195. ; When the pause key is released, script exits inner loop
  196. ; When the pause key is pressed once more, script exits outer loop and resumes play
  197. Loop {
  198. if state2 = D
  199. {
  200. Loop {
  201. GetKeyState, state2, %PauseKey%
  202. if state2 = U
  203. break
  204. Sleep, 100
  205. }
  206. }
  207. GetKeyState, state2, %PauseKey%
  208. if state2 = D
  209. break
  210. }
  211. Sleep, 250 ; Give the user a moment to release the key again
  212. }
  213. if state = D
  214. break
  215. }
  216. ; Thank you for using my script. Script by u/UnluckyScarecrow
  217. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement