Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
3,801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.55 KB | None | 0 0
  1. #NoEnv
  2. SetWorkingDir %A_ScriptDir%
  3. ;Sets the working directory to be where the script is located.
  4. CoordMode, Mouse, Window
  5. ;Lets the finding of X and Y to be determined by the mouse's coordinates on the functions below.
  6. SendMode Input
  7. #SingleInstance Force
  8. SetTitleMatchMode 2
  9. #WinActivateForce
  10. SetControlDelay 1
  11. SetWinDelay 0
  12. SetKeyDelay -1
  13. SetMouseDelay -1
  14. SetBatchLines -1
  15.  
  16.  
  17. F1::
  18. ;Press F1 to start your macro.
  19. Macro1:
  20. CoordMode, Pixel, Window
  21. WinActivate, NoxPlayer ahk_class Qt5QWindowIcon
  22. Sleep, 350
  23. Loop
  24. {
  25. mainloopstart:
  26. FoundX := 0
  27. FoundY := 0
  28.  
  29. ConfirmPixel(FoundX, FoundY, 860, 390, 860, 390, "0x0D2910", 10, "Fast")
  30. If ErrorLevel >= 1
  31. return
  32.  
  33. ;Finds the color "0x0D2910" within the square that starts from X:374 Y:478 to X:374 Y:478,
  34. ;with 10 shade color variation,
  35. ;and then saves the resulting pixel to FoundX and FoundY.
  36. ;This is done to ensure that the screen has changed and confirm the color you passed exist within
  37. ;this pixel at this particular time.
  38. ;If the color is not found, the error count will be incremented to 1, resulting in the confirmation to re-run.
  39. ;It takes into account any possible lag so it won't proceed until the correct screen is confirmed.
  40. ;This check is for the Green Shinra's finest event box.
  41. ;The rest of the script follows the same logic. Optimize as you see fit.
  42.  
  43. ;The ConfirmPixel function is defined down below.
  44.  
  45. Sleep, 250
  46. Click, 860, 390 Left, 1
  47. Sleep, 250
  48.  
  49. ;Left Mouse clicks on the Shinra Finest event button.
  50.  
  51. ConfirmPixel(FoundX, FoundY, 1032, 783, 1032, 783, "0xF7961D", 10, "Fast")
  52. If ErrorLevel >= 1
  53. return
  54.  
  55. ;This check is for the Blue Enter Dungeon button.
  56.  
  57. Sleep, 250
  58. Click, %FoundX%, %FoundY% Left, 1
  59. Sleep, 250
  60.  
  61. ;Clicks the Enter Dungeon button.
  62.  
  63. ConfirmPixel(FoundX, FoundY, 999, 860, 999, 860, "0xE84A20", 10, "Fast")
  64. If ErrorLevel >= 1
  65. return
  66.  
  67. ;This check is for the Next on the Party Select screen button.
  68.  
  69. Sleep, 1000
  70. Click, %FoundX%, %FoundY% Left, 1
  71. Sleep, 250
  72.  
  73. ;Clicks the Next button.
  74.  
  75. ConfirmPixel(FoundX, FoundY, 993, 862, 993, 862, "0xDD3F18", 10, "Fast")
  76. If ErrorLevel >= 1
  77. return
  78.  
  79. ;This check is for the GO! button in the RW select screen.
  80.  
  81. Sleep, 500
  82. Click, 993, 862 Left, 1
  83. Sleep, 1000
  84.  
  85. ;Clicks the GO! button.
  86.  
  87. ConfirmPixel(FoundX, FoundY, 1127, 459, 1127, 459, "0xC3BBBB", 10, "Fast")
  88. If ErrorLevel >= 1
  89. return
  90.  
  91. ;This check is for the white edges of the boss platform button.
  92.  
  93. Click, 1127, 459 Left, 1
  94. Sleep, 250
  95.  
  96. ;Clicks the white edge of the boss platform.
  97.  
  98. ConfirmPixel(FoundX, FoundY, 1059, 685, 1059, 685, "0x9A2911", 30, "Fast")
  99. If ErrorLevel >= 1
  100. return
  101.  
  102. ;This check is for the begin battle button.
  103.  
  104. Sleep, 250
  105. Click, 1059, 685 Left, 1
  106. Sleep, 250
  107.  
  108. ;Clicks the begin battle button.
  109.  
  110. ;ConfirmPixel(FoundX, FoundY, 595, 922, 595, 922, "0x203ED8", 10, "Fast")
  111. ;If ErrorLevel >= 1
  112. ; return
  113.  
  114. ;Sleep, 250
  115. ;Click, %FoundX%, %FoundY% Left, 1
  116. ;Sleep, 2000
  117.  
  118. WorthyBoss := 0
  119.  
  120. Loop
  121. {
  122. battleloop:
  123. PixelSearch, FoundX, FoundY, 990, 296, 990, 296, 0x6A1405, 10, Fast
  124. If ErrorLevel = 0
  125. {
  126. Goto, resultsloop
  127. }
  128. ;Checks if the fight has ended and you are in the champion screen.
  129. ;If it is, it will click and check whether it should return to the beginning of the loop.
  130.  
  131. If ErrorLevel >= 1
  132. PixelSearch, FoundX, FoundY, 979, 810, 979, 810, 0xC8C8C8, 10, Fast
  133. ;Checks if your turn available by ensuring the 2nd ability slot includes the color white that is on the outer ring of the ability.
  134. If ErrorLevel = 0
  135. {
  136. ;If the turn is available..
  137. PixelSearch, FoundX, FoundY, 827, 830, 827, 830, 0xAD210F, 10, Fast
  138. ;Checks if the CMD2 is blue colored for attack/defend, meaning burst mode is inactive
  139. If ErrorLevel = 0
  140. ;If it is blue..
  141. {
  142. Click, 1131, 816 Left, 1
  143. ;Click the BSB button
  144. Sleep, 300
  145. Goto, battleloop
  146. ;Left click on bsb. Repeat the loop.
  147. }
  148. Else If ErrorLevel >= 1
  149. ;If it is not blue, meaning the cmd2 exists..
  150. ;PixelSearch, FoundX, FoundY, 847, 480, 847, 480, 0x0F0A0A, 10, Fast
  151. ;Check tank
  152. ;If ErrorLevel = 0
  153. ;{
  154. ; WorthyBoss += 1
  155. ;}
  156. PixelSearch, FoundX, FoundY, 780, 496, 780, 496, 0x0A0E15, 10, Fast
  157. ;Check Guard Scorpion
  158. If ErrorLevel = 0
  159. {
  160. WorthyBoss += 1
  161. }
  162. ;First we check if it is a worthy boss. There is a static spot on this boss.
  163. ;You can add one more counter if you want to do it for the other bosses as well, just have to find a good pixel.
  164. If WorthyBoss > 0
  165. ;If we confirmed it is this boss..
  166. {
  167. Click, 726, 840 Left, 1
  168. Sleep, 300
  169. WorthyBoss := 0
  170. Goto, battleloop
  171. ;Left click on cmd1. Repeat the loop.
  172. }
  173. Else
  174. ;Otherwise we will use cmd2.
  175. {
  176. Click, 827, 830 Left, 1
  177. Sleep, 300
  178. Goto, battleloop
  179. ;Left click on cmd2. Repeat the loop.
  180. }
  181. }
  182. }
  183.  
  184. resultsloop:
  185. Loop
  186. {
  187. Sleep, 100
  188. ConfirmPixel(FoundX, FoundY, 1007, 660, 1007, 660, "0x3ADAFE", 10, "Fast")
  189. If ErrorLevel >= 1
  190. return
  191. ;Checks on the mastery screen.
  192. Sleep, 1000
  193. ;Sleep is important so that the macro knows to wait before running the next command.
  194. Click, 1007, 660, Left, 2
  195. ConfirmPixel(FoundX, FoundY, 867, 848, 867, 848, "0xCC511E", 10, "Fast")
  196. If ErrorLevel >= 1
  197. return
  198. Sleep, 1000
  199. Click, 867, 848, Left, 2
  200. Sleep, 1000
  201. ;Click on the mastery screen to ensure your window focus has changed.
  202. ConfirmPixel(FoundX, FoundY, 977, 330, 977, 330, "0x1261FF", 10, "Fast")
  203. ;Checks on the Next button on the mastery screen.
  204. If ErrorLevel >= 1
  205. return
  206. Sleep, 1000
  207. Click, 946, 740, Left, 2
  208. Sleep, 1000
  209. ConfirmPixel(FoundX, FoundY, 867, 848, 867, 848, "0xCC511E", 10, "Fast")
  210. ;Checks on the Next button on the mastery screen.
  211. If ErrorLevel >= 1
  212. return
  213. Sleep, 300
  214. Click, 867, 848, Left, 2
  215. Sleep, 500
  216. ConfirmPixel(FoundX, FoundY, 993, 736, 993, 736, "0xE1491E", 10, "Fast")
  217. ;Checks on the Next button on the magicite screen.
  218. If ErrorLevel >= 1
  219. return
  220. Sleep, 1000
  221. Click, 993, 736, Left, 2
  222. Sleep, 500
  223. ConfirmPixel(FoundX, FoundY, 993, 736, 993, 736, "0xE1491E", 10, "Fast")
  224. ;Checks on the Next button on the Greater Dark Orb screen.
  225. If ErrorLevel >= 1
  226. return
  227. Sleep, 1000
  228. Click, 867, 848, Left, 2
  229. Click, 867, 848, Left, 2
  230. Click, 867, 848, Left, 2
  231. Sleep, 500
  232. ConfirmPixel(FoundX, FoundY, 930, 852, 930, 852, "0xFFFFFF", 10, "Fast")
  233. ;Checks on the Next button on the Major Dark Orb screen.
  234. If ErrorLevel >= 1
  235. Sleep, 1000
  236. Click, 930, 852, Left, 2
  237. Click, 930, 852, Left, 2
  238. Click, 930, 852, Left, 2
  239. ;Clicks the next button
  240. Sleep, 500
  241. ConfirmPixel(FoundX, FoundY, 740, 424, 740, 424, "0x20B9EA", 10, "Fast")
  242. ;Checks the dungeon complete next screen
  243. If ErrorLevel >= 1
  244. return
  245. Sleep, 500
  246. Click, 930, 852, Left, 2
  247. ConfirmPixel(FoundX, FoundY, 827, 830, 827, 830, "0x9B5E45", 10, "Fast")
  248. ;Checks the dungeon complete next button
  249. If ErrorLevel >= 1
  250. return
  251. Sleep, 1000
  252. Click, 827, 830, Left, 2
  253. ;Clicks the next button
  254. Sleep, 1000
  255. ConfirmPixel(FoundX, FoundY, 860, 390, 860, 390, "0x0D2910", 10, "Fast")
  256. ;Checks the shinra screen
  257. If ErrorLevel >= 1
  258. return
  259. Sleep, 500
  260. Goto, mainloopstart
  261.  
  262. }
  263. }
  264. Return
  265.  
  266.  
  267. F2::ExitApp
  268.  
  269. F3::Pause
  270.  
  271. ConfirmImage(byRef Out1, byRef Out2, X1, Y1, X2, Y2, ImageFile)
  272. {
  273. CoordMode, Pixel, Window
  274. myImg = %A_ScriptDir%\img\%ImageFile%
  275. Loop, 3000
  276. {
  277. ImageSearch, Out1, Out2, X1, Y1, X2, Y2, %myImg%
  278. ; MsgBox, 1,, %ErrorLevel% %ImageFile%
  279. CenterImgSrchCoords(myImg, Out1, Out2)
  280. If ErrorLevel = 0
  281. Break
  282. Sleep, 100
  283. }
  284. ; MsgBox, 1,, %Out1% %Out2%
  285. }
  286.  
  287. ConfirmPixel(byRef Out1, byRef Out2, X1, Y1, X2, Y2, color, tol, opt)
  288. {
  289. Loop, 3000
  290. {
  291. PixelSearch, Out1, Out2, X1, Y1, X1, Y1, %color%, tol, %opt%
  292. if ErrorLevel = 0
  293. Break
  294. Sleep, 100
  295. }
  296. }
  297.  
  298. CenterImgSrchCoords(File, ByRef CoordX, ByRef CoordY)
  299. {
  300. static LoadedPic
  301. LastEL := ErrorLevel
  302. Gui, Add, Pic, vLoadedPic, %File%
  303. GuiControlGet, LoadedPic, Pos
  304. Gui, Destroy
  305. CoordX += LoadedPicW // 2
  306. CoordY += LoadedPicH // 2
  307. ErrorLevel := LastEL
  308. }
  309.  
  310. ;Last edited by /u/richiealvian. Thanks /u/spirialis!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement