Advertisement
Guest User

Untitled

a guest
Jan 14th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. #Persistent
  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. SetTitleMatchMode, 2
  7. ; CoordMode, Mouse, Screen
  8.  
  9. #Include C:\Users\Donald\Desktop\TQ Bot Folder\Utils.ahk
  10. pathBase = C:\Users\Donald\Desktop\TQ Bot Folder\Click God Logs\
  11.  
  12. path1 = %pathBase%clickFormatted.txt
  13. path2 = %pathBase%clickRelative.txt
  14.  
  15. xpos1 = 0
  16. ypos1 = 0
  17. tempPreviousTime = 0
  18.  
  19. userInput =
  20.  
  21. SetTimer, Button_Pressed, 1
  22. F3::Reload
  23.  
  24. return
  25.  
  26. ; Hybrid Functions
  27. Button_Pressed:
  28. ;if WinActive("Titan Quest Anniversary Edition")
  29. ;{
  30. ; Clear file.
  31. if GetKeyState("F4", "P")
  32. {
  33. global path1
  34. recordFile := FileOpen(path1, "w")
  35. recordFile.Close()
  36. Sleep 1000
  37. return
  38. }
  39.  
  40. ; Fast Mouse record.
  41. if GetKeyState("F5", "P")
  42. {
  43. Click
  44. recordMousePosition()
  45. writeMousePosition()
  46. Sleep 1000
  47. return
  48. }
  49.  
  50. /*
  51. if GetKeyState("F6", "P") {
  52. MouseGetPos, MouseX, MouseY
  53. PixelGetColor, color, %MouseX%, %MouseY%, RGB
  54. MsgBox The color at the current cursor position is %color%.
  55. }
  56.  
  57. ; Reset game window pos.
  58. if GetKeyState("F8", "P") {
  59. }
  60. */
  61.  
  62. ; Get pixel posiiton at cursor position.
  63. if GetKeyState("F6", "P") {
  64. ; Deselect Titan Quest Game Window
  65. ;WinActivate, Notepad++
  66.  
  67. ; Get pixel color at mouse pos.
  68. MouseGetPos, MouseX, MouseY
  69.  
  70. ; BGR default format. (Each digit is HEX, 00-ff)
  71. PixelGetColor, color, %MouseX%, %MouseY%
  72. ; MsgBox The color at the current cursor position is %color%.
  73.  
  74. word_array := StrSplit(color, "")
  75.  
  76. ; MsgBox % word_array[3] ; 3-9 equals array.
  77.  
  78. colorBlue := getDecimalFromHexes(word_array[3], word_array[4])
  79. colorGreen := getDecimalFromHexes(word_array[5], word_array[6])
  80. colorRed := getDecimalFromHexes(word_array[7], word_array[8])
  81.  
  82. MsgBox % colorRed . " " . colorGreen . " " . colorBlue . " " . color
  83. }
  84.  
  85. if GetKeyState("F7", "P") {
  86. ; Deselect Titan Quest Game Window
  87. ;WinActivate, Notepad++
  88.  
  89. ; Reset Game Window pos.
  90. ;WinMove, Titan Quest Anniversary Edition, ,0, 0
  91. ;Sleep 100
  92.  
  93. ; Execute pixel search.
  94. searchX = 0
  95. searchY = 0
  96.  
  97. maxSearchX = 1024
  98. maxSearchY = 768
  99.  
  100. ; If not finding a pixel, check search increment.
  101. searchIncrement = 1
  102.  
  103. ;maxSearchX = 1024
  104. ;maxSearchY = 768
  105.  
  106. while (searchX < maxSearchX) {
  107. while (searchY < maxSearchY) {
  108. PixelGetColor, color, %searchX%, %searchY%
  109. ; PixelSearch, Px, Py, searchX1, searchY1, searchX2, searchY2, , 3, Fast
  110.  
  111. if (color = "0x6AC3E8") {
  112. MsgBox % "Found pixel at: " . searchX . " " . searchY
  113. break
  114. }
  115.  
  116. ; 0,0 - 0,1
  117. ; Maybe in the future skip by 5, instead of 1, or 10.
  118. searchY+=searchIncrement
  119. }
  120.  
  121. ; if (ErrorLevel == 0)
  122. ; break
  123.  
  124. searchX+=searchIncrement
  125. searchY = 0
  126. }
  127.  
  128. MsgBox % "Done!"
  129. }
  130.  
  131. ; Add F8 condition, where mouse is moved over screen slowly and any monster health bars that pop up cause their pixel color to be recorded.
  132.  
  133. ; TODO NOTE: Maybe do melee solution? do a screen search for a monster, then click it to approach, then attack in melee after 'x' time. (Based on distance, determine 'x' for time?)
  134.  
  135. ;}
  136. return
  137.  
  138. ; Returns a decimal value for a 2-digit hex code.
  139. getDecimalFromHexes(hex1, hex2) {
  140. return getDecimalFromHex(hex1) * 16 + getDecimalFromHex(hex2)
  141. }
  142.  
  143. ; return decimal value from a hex digit.
  144. ; hexvalue = string from 0-f
  145. getDecimalFromHex(hexValue) {
  146. if (hexValue = "a") {
  147. return 10
  148. }
  149. else if (hexValue = "b") {
  150. return 11
  151. }
  152. else if (hexValue = "c") {
  153. return 12
  154. }
  155. else if (hexValue = "d") {
  156. return 13
  157. }
  158. else if (hexValue = "e") {
  159. return 14
  160. }
  161. else if (hexValue = "f") {
  162. return 15
  163. }
  164. else {
  165. return hexValue
  166. }
  167. }
  168.  
  169. ; Base functions.
  170.  
  171. /*
  172. recordComment()
  173. writeComment(newLine)
  174. recordCommand()
  175. writeCommand()
  176. recordMousePosition()
  177. writeMousePosition()
  178. */
  179.  
  180.  
  181. recordComment()
  182. {
  183. global userInput
  184. InputBox, userInput, Input, Enter "Comment" Text:,,,,,,,,
  185. }
  186.  
  187. recordCommand()
  188. {
  189. global userInput
  190. InputBox, userInput, Input, Enter "Send" Text:,,,,,,,,
  191. }
  192.  
  193. recordMousePosition()
  194. {
  195. global path1
  196. global xpos1
  197. global ypos1
  198.  
  199. MouseGetPos, xpos1, ypos1
  200. }
  201.  
  202. writeComment()
  203. {
  204. global path1
  205. global userInput
  206.  
  207. text2 := "; "
  208.  
  209. fileWrite(path1, text2 . userInput)
  210. addLineBreak()
  211. }
  212.  
  213. writeCommand()
  214. {
  215. global path1
  216. global userInput
  217.  
  218. text2 = send_delay_20("
  219. text3 = ")
  220.  
  221. fileWrite(path1, text2 . userInput . text3)
  222. addLineBreak()
  223. }
  224.  
  225. writeMousePosition()
  226. {
  227. global path1
  228. global xpos1
  229. global ypos1
  230.  
  231. writeString = delayed_click(%xpos1%, %ypos1%)`r`n
  232. fileWrite(path1, writeString)
  233. addLineBreak()
  234. }
  235.  
  236. ; Utility Functions.
  237. writeSleep(x)
  238. {
  239. global path1
  240. y = Sleep %x%`r`n
  241. fileWrite(path1, y)
  242. }
  243.  
  244. addLineBreak()
  245. {
  246. global path1
  247. fileWrite(path1, "`r`n")
  248. }
  249.  
  250. fileWrite(path, msg)
  251. {
  252. recordFile := FileOpen(path, "a")
  253. recordFile.Write(msg)
  254. recordFile.Close()
  255. }
  256.  
  257. /*
  258.  
  259. recordFile := FileOpen(path2, "w")
  260. recordFile.write("#Include C:\Users\abdullad\Desktop\Personal Files\ClickTypeUtils.ahk`r`n`r`nF4::Test()`r`n`r`nTest()`r`n{`r`n MouseGetPos, xpos, ypos`r`n`r`nxposBase := xpos`r`nyposBase := ypos`r`n`r`n; Move to the end -> MouseMove, xpos, ypos <- Make sure to delete the first set of mouse coords.`r`n`r`n")
  261. recordFile.Close()
  262.  
  263. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement