Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.42 KB | None | 0 0
  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.  
  6. CoordMode, ToolTip, Screen
  7. CoordMode, Pixel, Screen
  8. CoordMode, Mouse, Screen
  9. CoordMode, Caret, Screen
  10. CoordMode, Menu, Screen
  11.  
  12. path := [""] ;We start at path[2]!
  13. pathInstructs := [""] ;includes color, coords, etc
  14. pathDetails := [""] ; 1 is move mouse subscreen color//
  15. pathXY := [""]
  16. grabcolor := false
  17. started := false
  18. stop := false
  19. sleepU := false
  20. sleepUI := false
  21. color = 0x0000
  22. colorSU = 0x0000
  23.  
  24. Gui, Show , w350 h640, Create a Script!
  25.  
  26. ; basic elements
  27. Gui, Add, Text, x20 y10 w150 Left, % "Click show path to see what your bot will loop on run"
  28. Gui, Add, Button, x20 y40 w90 h20 gshow_path, Show path
  29. Gui, Add, Text, x20 y100 w150 Left, % "Add commands to the list of things your bot will loop"
  30.  
  31. Gui, Add, Button, x20 y130 w150 h40 gadd_move_mouse_subwindow, Move mouse to a color (game subwindow)
  32. Gui, Add, Button, x20 y170 w150 h40 gadd_move_mouse_inventory, Move mouse to a color (inventory)
  33. Gui, Add, Button, x20 y210 w150 h40 gadd_move_mouse_chatbox, Move mouse to a color (chatbox)
  34. Gui, Add, Button, x20 y250 w150 h40 gadd_mouse_click, Click
  35. Gui, Add, Button, x20 y290 w150 h40 gadd_right_mouse_click, Right click
  36.  
  37. Gui, Add, Button, x20 y330 w150 h40 gadd_move_mouse_relative, Move mouse to relative X,Y position
  38. Gui, Add, Edit, w50 h20 x180 y330 vXRELATIVE Left,
  39. Gui, Add, Edit, w50 h20 x240 y330 vYRELATIVE Left,
  40. Gui, Add, Text, x180 y350 w170 Left, % "^ Enter X and Y then hit relative <-"
  41.  
  42. Gui, Add, Button, x20 y370 w150 h40 gadd_move_mouse_absolute, Move mouse to an absolute X,Y position
  43. Gui, Add, Edit, w50 h20 x180 y370 vXABSOLUTE Left,
  44. Gui, Add, Edit, w50 h20 x240 y370 vYABSOLUTE Left,
  45. Gui, Add, Text, x180 y390 w170 Left, % "^ Enter X and Y then hit absolute <-"
  46.  
  47. Gui, Add, Button, x20 y410 w150 h40 gadd_type, Type in text
  48. Gui, Add, Edit, w50 h20 x170 y410 vTYPE Left,
  49. Gui, Add, Text, x180 y430 w170 Left, % "Enter message and hit button <-"
  50.  
  51. Gui, Add, Button, x20 y450 w150 h40 gadd_sleep, Sleep for amount of milliseconds
  52. Gui, Add, Edit, w50 h20 x170 y450 vMILLI Left,
  53. Gui, Add, Text, x180 y470 w170 Left, % "^ Enter sleep time (milli) and hit button<-"
  54.  
  55. Gui, Add, Button, x20 y490 w150 h40 gadd_sleepU, Sleep until color appears in subwindow
  56.  
  57. Gui, Add, Button, x20 y530 w150 h40 gadd_sleepUI, Sleep until color appears in inventory
  58.  
  59. Gui, Add, Button, x20 y570 w150 h40 gremove_last_element, Delete previous addition
  60.  
  61.  
  62. Gui, Add, Button, x20 y610 w150 h40 gstart, Start the script (press C to stop)
  63.  
  64. Gui, Add, Text, x200 y10 w150 Left, % "Change subwindow coords (X1, Y1, X2, Y2)"
  65. Gui, Add, Edit, w30 h20 x200 y40 vSUBWINDOWTOPX Left, 5
  66. Gui, Add, Edit, w30 h20 x230 y40 vSUBWINDOWTOPY Left, 24
  67. Gui, Add, Edit, w30 h20 x200 y65 vSUBWINDOWBOTTOMX Left, 518
  68. Gui, Add, Edit, w30 h20 x230 y65 vSUBWINDOWBOTTOMY Left, 361
  69.  
  70. Gui, Add, Text, x200 y80 w150 Left, % "Change inventory coords (X1, Y1, X2, Y2)"
  71. Gui, Add, Edit, w30 h20 x200 y110 vINVENTORYTOPX Left, 565
  72. Gui, Add, Edit, w30 h20 x230 y110 vINVENTORYTOPY Left, 228
  73. Gui, Add, Edit, w30 h20 x200 y135 vINVENTORYBOTTOMX Left, 736
  74. Gui, Add, Edit, w30 h20 x230 y135 vINVENTORYBOTTOMY Left, 477
  75.  
  76. Gui, Add, Text, x200 y180 w150 Left, % "Change chatbox coords (X1, Y1, X2, Y2)"
  77. Gui, Add, Edit, w30 h20 x200 y210 vCHATBOXTOPX Left, 4
  78. Gui, Add, Edit, w30 h20 x230 y210 vCHATBOXTOPY Left, 363
  79. Gui, Add, Edit, w30 h20 x200 y235 vCHATBOXBOTTOMX Left, 504
  80. Gui, Add, Edit, w30 h20 x230 y235 vCHATBOXBOTTOMY Left, 479
  81.  
  82. return
  83.  
  84. start:
  85. {
  86. Gui, Submit, NoHide
  87. string := % path[1]
  88. counter := 2
  89. while (counter <= path.maxIndex())
  90. {
  91. string := % string . ">" . path[counter]
  92. counter ++
  93. }
  94. MsgBox % path.maxIndex() string
  95.  
  96.  
  97. Gui, Submit, NoHide
  98. stop := false
  99. started := true
  100. while (stop = false)
  101. {
  102. counter = 2
  103. while (counter <= path.maxIndex() and stop = false)
  104. {
  105. if (pathDetails[counter] = 1)
  106. {
  107. PixelSearch, Px, Py, SUBWINDOWTOPX, SUBWINDOWTOPY, SUBWINDOWBOTTOMX, SUBWINDOWBOTTOMY, pathInstructs[counter], 0, Fast
  108. if ErrorLevel
  109. {
  110. ;Color not found
  111. ;Sleep?
  112. }
  113. else
  114. MouseMove Px, Py
  115. }
  116. else if (pathDetails[counter] = 2)
  117. {
  118. PixelSearch, Px, Py, INVENTORYTOPX, INVENTORYTOPY, INVENTORYBOTTOMX, INVENTORYBOTTOMY, pathInstructs[counter], 0, Fast
  119. if ErrorLevel
  120. {
  121. ;Color not found
  122. ;Sleep?
  123. }
  124. else
  125. MouseMove Px, Py
  126. }
  127. else if (pathDetails[counter] = 3)
  128. {
  129. PixelSearch, Px, Py, CHATBOXTOPX, vCHATBOXTOPY, vCHATBOXBOTTOMX, vCHATBOXBOTTOMY, pathInstructs[counter], 0, Fast
  130. if ErrorLevel
  131. {
  132. ;Color not found
  133. ;Sleep?
  134. }
  135. else
  136. MouseMove Px, Py
  137. }
  138. else if (pathDetails[counter] = 4)
  139. {
  140. Click
  141. }
  142. else if (pathDetails[counter] = 5)
  143. {
  144. Click Right
  145. }
  146. else if (pathDetails[counter] = 6)
  147. {
  148. MouseMove pathInstructs[counter], pathXY[counter], 1, R
  149. }
  150. else if (pathDetails[counter] = 7)
  151. {
  152. MouseMove pathInstructs[counter], pathXY[counter]
  153. }
  154. else if (pathDetails[counter] = 8)
  155. {
  156. Send pathInstructs[counter] {enter}
  157. }
  158. else if (pathDetails[counter] = 9)
  159. {
  160. sleep pathInstructs[counter]
  161. }
  162. else if (pathDetails[counter] = 10)
  163. {
  164. temp := true
  165. sleepC := 0
  166. while (temp = true and sleepC < 10)
  167. {
  168. PixelSearch, Px, Py, SUBWINDOWTOPX, SUBWINDOWTOPY, SUBWINDOWBOTTOMX, SUBWINDOWBOTTOMY, pathInstructs[counter], 0, Fast
  169. if ErrorLevel
  170. {
  171. sleep 500
  172. sleepC ++
  173. }
  174. else
  175. {
  176. temp = false
  177. }
  178. }
  179. }
  180. else if (pathDetails[counter] = 11)
  181. {
  182. temp := true
  183. sleepC := 0
  184. while (temp = true and sleepC < 10)
  185. {
  186. PixelSearch, Px, Py, INVENTORYTOPX, INVENTORYTOPY, INVENTORYBOTTOMX, INVENTORYBOTTOMY, pathInstructs[counter], 0, Fast
  187. if ErrorLevel
  188. {
  189. sleep 500
  190. sleepC ++
  191. }
  192. else
  193. {
  194. temp = false
  195. }
  196. }
  197. }
  198. counter ++
  199. }
  200. sleep 50
  201. }
  202. started := false
  203. }
  204. return
  205.  
  206. show_path:
  207. {
  208. Gui, Submit, NoHide
  209. string := % path[1]
  210. counter := 2
  211. while (counter <= path.maxIndex())
  212. {
  213. string := % string . ">" . path[counter]
  214. counter ++
  215. }
  216. MsgBox % path.maxIndex() string
  217. }
  218. return
  219.  
  220. add_move_mouse_subwindow:
  221. {
  222. Gui, Submit, NoHide
  223. grabcolor := true
  224. MsgBox % "Press C to grab color [DO NOT CLOSE THIS BEFORE YOU PRESS C]"
  225. path[path.maxIndex()+1] := "Move mouse to subwindow and on color " color
  226. pathInstructs[pathInstructs.maxIndex()+1] := color
  227. pathDetails[pathDetails.maxIndex()+1] := 1 ;1 is subgame window move to color
  228. }
  229. return
  230.  
  231. add_move_mouse_inventory:
  232. {
  233. Gui, Submit, NoHide
  234. grabcolor := true
  235. MsgBox % "Press C to grab color [DO NOT CLOSE THIS BEFORE YOU PRESS C]"
  236. path[path.maxIndex()+1] := "Move mouse to inventory and on color " color
  237. pathInstructs[pathInstructs.maxIndex()+1] := color
  238. pathDetails[pathDetails.maxIndex()+1] := 2 ;2 is inventory move to color
  239. }
  240. return
  241.  
  242. add_move_mouse_chatbox:
  243. {
  244. Gui, Submit, NoHide
  245. grabcolor := true
  246. MsgBox % "Press C to grab color [DO NOT CLOSE THIS BEFORE YOU PRESS C]"
  247. path[path.maxIndex()+1] := "Move mouse to chatbox and on color " color
  248. pathInstructs[pathInstructs.maxIndex()+1] := color
  249. pathDetails[pathDetails.maxIndex()+1] := 3 ;3 is chatbox
  250. }
  251. return
  252.  
  253. add_mouse_click:
  254. {
  255. Gui, Submit, NoHide
  256. path[path.maxIndex()+1] := "Click"
  257. pathInstructs[pathInstructs.maxIndex()+1] := click
  258. pathDetails[pathDetails.maxIndex()+1] := 4 ;4 is Click
  259. }
  260. return
  261.  
  262. add_right_mouse_click:
  263. {
  264. Gui, Submit, NoHide
  265. path[path.maxIndex()+1] := "Click (Right)"
  266. pathInstructs[pathInstructs.maxIndex()+1] := right
  267. pathDetails[pathDetails.maxIndex()+1] := 5 ;5 is Right Click
  268. }
  269. return
  270.  
  271. add_move_mouse_relative:
  272. {
  273. Gui, Submit, NoHide
  274. MsgBox % "Added XY relative " XRELATIVE "," YRELATIVE
  275. path[path.maxIndex()+1] := "Move Mouse Relative" XRELATIVE "," YRELATIVE
  276. pathInstructs[pathInstructs.maxIndex()+1] := XRELATIVE
  277. pathXY[path.maxIndex()] := YRELATIVE
  278. pathDetails[pathDetails.maxIndex()+1] := 6 ;6 is move mouse relative
  279. }
  280. return
  281.  
  282. add_move_mouse_absolute:
  283. {
  284. Gui, Submit, NoHide
  285. MsgBox % "Added XY absolute " XABSOLUTE "," YABSOLUTE
  286. path[path.maxIndex()+1] := "Move Mouse Absolute" XABSOLUTE "," YABSOLUTE
  287. pathInstructs[pathInstructs.maxIndex()+1] := XABSOLUTE ;
  288. pathXY[path.maxIndex()] := YABSOLUTE
  289. pathDetails[pathDetails.maxIndex()+1] := 7 ;7 is move mouse absolute
  290. }
  291. return
  292.  
  293. add_type:
  294. {
  295. Gui, Submit, NoHide
  296. MsgBox % "Will type " TYPE " and hit {ENTER}!"
  297. path[path.maxIndex()+1] := "Type <" TYPE ">"
  298. pathInstructs[pathInstructs.maxIndex()+1] := TYPE
  299. pathDetails[pathDetails.maxIndex()+1] := 8 ;8 is type
  300. }
  301. return
  302.  
  303. add_sleep:
  304. {
  305. Gui, Submit, NoHide
  306. MsgBox % "Will sleep " MILLI "milliseconds"
  307. path[path.maxIndex()+1] := "Sleep for " MILLI
  308. pathInstructs[pathInstructs.maxIndex()+1] := MILLI
  309. pathDetails[pathDetails.maxIndex()+1] := 9 ;9 is sleep
  310. }
  311. return
  312.  
  313. add_sleepU:
  314. {
  315. Gui, Submit, NoHide
  316. sleepU := true
  317. MsgBox % "Press C to grab color you're waiting for [DO NOT CLOSE THIS BEFORE YOU PRESS C]"
  318. path[path.maxIndex()+1] := "Wait for " colorSU
  319. pathInstructs[pathInstructs.maxIndex()+1] := colorSU
  320. pathDetails[pathDetails.maxIndex()+1] := 10 ;10 is subgame window wait for color
  321. }
  322. return
  323.  
  324. add_sleepUI:
  325. {
  326. Gui, Submit, NoHide
  327. SleepUI := true
  328. MsgBox % "Press C to grab color you're waiting for [DO NOT CLOSE THIS BEFORE YOU PRESS C]"
  329. path[path.maxIndex()+1] := "Wait for " colorSU
  330. pathInstructs[pathInstructs.maxIndex()+1] := colorSU
  331. pathDetails[pathDetails.maxIndex()+1] := 11 ;11 is inventory wait for color
  332. }
  333. return
  334.  
  335. remove_last_element:
  336. {
  337. path.Pop()
  338. pathDetails.pop()
  339. pathInstructs.pop()
  340. MsgBox "Element deleted."
  341. }
  342. return
  343.  
  344. c::
  345. if (grabcolor = true)
  346. {
  347. MouseGetPos X, Y
  348. PixelGetColor, color, X, Y
  349. MsgBox
  350. (
  351. Color: %color%
  352. Mouse Coords: %X%, %Y%
  353. This color has been noted.
  354. )
  355. grabcolor := false
  356. }
  357. if (started = true)
  358. {
  359. stop := true
  360. }
  361. if (sleepU = true or sleepUI = true)
  362. {
  363. MouseGetPos X, Y
  364. PixelGetColor, colorSU, X, Y
  365. MsgBox
  366. (
  367. Color: %colorSU%
  368. Mouse Coords: %X%, %Y%
  369. This color has been noted.
  370. )
  371. sleepU := false
  372. sleepUI := false
  373. }
  374.  
  375. return
  376.  
  377. GuiClose:
  378. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement