Advertisement
Guest User

ZK v1.6 Fast

a guest
Jul 7th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.03 KB | None | 0 0
  1. #include <Array.au3>
  2. #include "image_get_info.au3"
  3.  
  4. HotKeySet("{F1}", "Start")
  5. HotKeySet("{F2}", "End")
  6.  
  7. ; Toon name, check bmps for supported letter, lowercase only
  8. Global $playername = ""
  9. ; number of friend slost to search for the leecher
  10. Global $slots = 5
  11. ; Set this to true just to use slot 1, the above are not used if this is true.
  12. Global $useSlot1 = True
  13.  
  14.  
  15.  
  16. Global $noquest = False
  17. Global $error = True
  18.  
  19. While 1
  20. Sleep(100)
  21. WEnd
  22.  
  23. Func Start()
  24. ; List D3 windows + handles
  25. $dClients = WinList("[CLASS:D3 Main Window Class]")
  26. While 1
  27. ;Sleep until logged in
  28. Do
  29. Sleep(100)
  30. Until LoginCheck($dClients[1][1]) = 1
  31. ; Invite the leecher
  32. InviteParty($dClients[1][1])
  33. If Not $error And Not $noquest Then
  34. Do
  35. ErrorCheck($dClients[2][1])
  36. sleep(100)
  37. Until $error
  38. EndIf
  39. $noquest = False
  40. $error = False
  41. AcceptInvite($dClients[2][1])
  42. ; Sleep until the pop appears saying someone has joined.
  43. Do
  44. Sleep(100)
  45. Until PartyCheck($dClients[1][1]) = 1
  46. LeaveGame($dClients[2][1])
  47. LeaveParty($dClients[2][1])
  48. WaitforCrown($dClients[2][1])
  49. Resume($dClients[2][1])
  50. LeaveGame($dClients[1][1])
  51. ; Resume with "Leecher"
  52. Resume($dClients[1][1])
  53. ; Sleep until logged in
  54. Do
  55. Sleep(100)
  56. Until LoginCheck($dClients[2][1]) = 1
  57. ; Check where Adria is at & click on her when found
  58. ErrorCheck($dclients[2][1])
  59. AdriaCheck($dClients[2][1])
  60. Local $counter = 0
  61. Do
  62. Sleep(100)
  63. ErrorCheck($dclients[2][1])
  64. $counter += 1
  65. Until PopupCheck($dclients[2][1]) = 1 Or $counter == 50
  66. If $counter == 50 Then
  67. Send("{SPACE DOWN}")
  68. Sleep(100)
  69. Send("{SPACE UP}")
  70. $noquest = True
  71. Else
  72. For $i = 0 to 4
  73. ErrorCheck($dClients[2][1])
  74. Send("{SPACE DOWN}")
  75. ErrorCheck($dClients[2][1])
  76. Sleep(200)
  77. Send("{SPACE UP}")
  78. ErrorCheck($dClients[2][1])
  79. Sleep(200)
  80. Next
  81. EndIf
  82. WEnd
  83. EndFunc ;==>Start
  84.  
  85. Func WaitforCrown($handle)
  86. Local $dClient
  87. $dClient = WinGetPos($handle)
  88. If not (WinActive($handle)) Then
  89. WinActivate($handle)
  90. WinWaitActive($handle)
  91. EndIf
  92. Do
  93. $search = _ImageSearch(@ScriptDir & "\loggedout", $dClient[0] + 32, $dClient[1] + 593, $dClient[0] + 43, $dClient[1] + 607, "TRANSBLACK", 70, 1, 0)
  94. Sleep(100)
  95. Until IsArray($search)
  96. Do
  97. $crown = PixelSearch($dClient[0] + 582, $dClient[1] + 433, $dClient[0] + 604, $dClient[1] + 545, 0xFFC021, 10)
  98. sleep(100)
  99. Until Not IsArray($crown)
  100. Sleep(1000)
  101. EndFunc
  102.  
  103. Func Resume($handle)
  104. Local $dClient
  105. $dClient = WinGetPos($handle)
  106. If not (WinActive($handle)) Then
  107. WinActivate($handle)
  108. WinWaitActive($handle)
  109. EndIf
  110. While 1
  111. $resume = PixelSearch($dClient[0] + 95, $dClient[1] + 257, $dClient[0] + 182, $dClient[1] + 270, 0xDA954A, 3)
  112. $resume2 = PixelSearch($dClient[0] + 95, $dClient[1] + 257, $dClient[0] + 182, $dClient[1] + 270, 0xCFBDBA, 3)
  113. If IsArray($resume) or IsArray($resume2) Then
  114. Sleep(500)
  115. MouseMove($dClient[0] + 130, $dClient[1] + 255,0)
  116. MouseClick("primary", $dClient[0] + 130, $dClient[1] + 255)
  117. ExitLoop
  118. EndIf
  119. WEnd
  120. EndFunc ;==>Resume
  121.  
  122. Func LeaveParty($handle)
  123. Local $dClient
  124. $dClient = WinGetPos($handle)
  125. If not (WinActive($handle)) Then
  126. WinActivate($handle)
  127. WinWaitActive($handle)
  128. EndIf
  129. While 1
  130. $search = _ImageSearch(@ScriptDir & "\loggedout", $dClient[0] + 32, $dClient[1] + 593, $dClient[0] + 43, $dClient[1] + 607, "TRANSBLACK", 70, 1, 0)
  131. If IsArray($search) Then
  132. ;MouseMove($dClient[0] + 410, $dClient[1] + 332,1)
  133. ;Sleep(300)
  134. MouseClick("secondary", $dClient[0] + 410, $dClient[1] + 332)
  135. sleep(300)
  136. MouseMove($dClient[0] + 410 + 36, $dClient[1] + 332 + 96,0)
  137. MouseClick("primary", $dClient[0] + 410 + 36, $dClient[1] + 332 + 96)
  138. sleep(300)
  139. MouseMove($dClient[0] + 346, $dClient[1] + 381,0)
  140. MouseClick("primary", $dClient[0] + 346, $dClient[1] + 381)
  141. ExitLoop
  142. Else
  143. Sleep(100)
  144. EndIf
  145. WEnd
  146. EndFunc
  147.  
  148. Func PartyCheck($handle)
  149. Local $dClient
  150. $dClient = WinGetPos($handle)
  151. If not (WinActive($handle)) Then
  152. WinActivate($handle)
  153. WinWaitActive($handle)
  154. EndIf
  155. $search = _ImageSearch(@ScriptDir & "\entered", $dClient[0] + 13, $dClient[1] + 407, $dClient[0] + 237, $dClient[1] + 444, "TRANSBLACK", 70, 1, 0)
  156. If IsArray($search) Then
  157. Return 1
  158. Else
  159. Return 0
  160. EndIf
  161. EndFunc ;==>PartyCheck
  162.  
  163. Func LeaveGame($handle)
  164. Local $dClient
  165. $dClient = WinGetPos($handle)
  166. If not (WinActive($handle)) Then
  167. WinActivate($handle)
  168. WinWaitActive($handle)
  169. EndIf
  170. sleep(100)
  171. Send("{ESC DOWN}")
  172. Sleep(100)
  173. Send("{ESC UP}")
  174. Sleep(100)
  175. $menu = _ImageSearch(@ScriptDir & "\menu", $dClient[0] + 380, $dClient[1] + 172, $dClient[0] + 433, $dClient[1] + 196, "TRANSWHITE", 70, 1, 0)
  176. If IsArray($menu) Then
  177. MouseMove($dClient[0] + 409, $dClient[1] + 352,0)
  178. MouseClick("primary", $dClient[0] + 409, $dClient[1] + 352)
  179. Sleep(200)
  180. $party = _ImageSearch(@ScriptDir & "\party", $dClient[0] + 425, $dClient[1] + 257, $dClient[0] + 486, $dClient[1] + 277, "TRANSWHITE", 70, 1, 0)
  181. If IsArray($party) Then
  182. MouseMove($dClient[0] + 299, $dClient[1] + 381,0)
  183. MouseClick("primary", $dClient[0] + 299, $dClient[1] + 381)
  184. EndIf
  185. EndIf
  186. EndFunc
  187.  
  188. Func InviteParty($handle)
  189. Local $dClient
  190. $dClient = WinGetPos($handle)
  191. If not (WinActive($handle)) Then
  192. WinActivate($handle)
  193. WinWaitActive($handle)
  194. EndIf
  195. Send("{O DOWN}")
  196. Sleep(100)
  197. Send("{O UP}")
  198. Sleep(100)
  199. FindandClick()
  200. Send("{O DOWN}")
  201. Sleep(100)
  202. Send("{O UP}")
  203. EndFunc ;==>InviteParty
  204.  
  205. Func AcceptInvite($handle)
  206. Local $dClient
  207. $dClient = WinGetPos($handle)
  208. If not (WinActive($handle)) Then
  209. WinActivate($handle)
  210. WinWaitActive($handle)
  211. EndIf
  212. Do
  213. ErrorCheck($handle)
  214. $accept = PixelSearch($dClient[0] + 693, $dClient[1] + 537, $dClient[0] + 709, $dClient[1] + 553, 0x2CAC00, 3)
  215. If IsArray($accept) Then
  216. ErrorCheck($handle)
  217. MouseMove($dClient[0] + 701, $dClient[1] + 546,0)
  218. MouseClick("primary", $dClient[0] + 701, $dClient[1] + 546)
  219. Sleep(500)
  220. MouseMove($dClient[0] + 360, $dClient[1] + 382,0)
  221. MouseClick("primary", $dClient[0] + 360, $dClient[1] + 382)
  222. EndIf
  223. Until IsArray($accept)
  224. EndFunc ;==>AcceptInvite
  225.  
  226. Func FindandClick()
  227. $string = StringSplit($playername, "")
  228. $dClients = WinList("[CLASS:D3 Main Window Class]")
  229. $handle = $dClients[1][1]
  230. Local $dClient
  231. $dClient = WinGetPos($handle)
  232. If not (WinActive($handle)) Then
  233. WinActivate($handle)
  234. WinWaitActive($handle)
  235. EndIf
  236. $x = $dClient[0] + 537
  237. $y = $dClient[1] + 211
  238. $x2 = $dClient[0] + 761
  239. $y2 = $dClient[1] + 239
  240. If $useSlot1 Then
  241. MouseMove($dClient[0] + 598, $dClient[1] + 227,0)
  242. MouseClick("secondary", $dClient[0] + 598, $dClient[1] + 227)
  243. sleep(300)
  244. MouseMove($dClient[0]+ 598 + 77, $dClient[1] + 227 + 60,0)
  245. MouseClick("primary", $dClient[0]+ 598 + 77, $dClient[1] + 227 + 60)
  246. Else
  247. $counter = 1
  248. $scounter = 1
  249. Do
  250. Do
  251. $text = StringReplace(StringStripCR("\"), @LF, "") & $string[$counter]
  252. $player = _ImageSearch(@ScriptDir & $text, $x, $y, $x2, $y2, "TRANSWHITE", 70, 1, 0)
  253. $text2 = StringReplace(StringStripCR("\"), @LF, "") & $string[$counter] & ".bmp"
  254. $aInfo = _ImageGetInfo($text2)
  255. If IsArray($player) And $counter < $string[0] Then
  256. $p = _ImageGetParam($aInfo, "Width")
  257. $a = $player[1]+$p-1
  258. $b = $player[2]-6
  259. $c = $player[1]+10+$p
  260. $d = $player[2]+8
  261. $x = $player[1]+1
  262. Do
  263. $counter = $counter+1
  264. $text = StringReplace(StringStripCR("\"), @LF, "") & $string[$counter]
  265. $test = _ImageSearch(@ScriptDir & $text, $a, $b, $c, $d, "TRANSWHITE", 70, 1, 0)
  266. $text2 = @ScriptDir & StringReplace(StringStripCR("\"), @LF, "") & $string[$counter] & ".bmp"
  267. $aInfo = _ImageGetInfo($text2)
  268. If IsArray($test) Then
  269. $p = _ImageGetParam($aInfo, "Width")
  270. $a = $test[1]+$p-1
  271. $b = $test[2]-6
  272. $c = $test[1]+10+$p
  273. $d = $test[2]+8
  274. $x = $test[1]+1
  275. Else
  276. $counter = 1
  277. EndIf
  278. Until $counter == $string[0] Or $counter == 1
  279. EndIf
  280. Until $counter = $string[0] Or Not IsArray($player)
  281. $scounter = $scounter+1
  282. $x = $dClient[0] + 537
  283. $x2 = $dClient[0] + 761
  284. $y = $y+30
  285. $y2 = $y2+30
  286. Until $scounter > $slots Or $counter = $string[0]
  287. If IsArray($player) Then
  288. $x = $player[1]-150
  289. $y = $player[2]-10
  290. $x2 = $player[1]+150
  291. $y2 = $player[2]+20
  292. MouseMove($player[1], $player[2],0)
  293. MouseClick("secondary", $player[1], $player[2])
  294. Sleep(300)
  295. MouseMove($player[1] + 77, $player[2] + 60,0)
  296. MouseClick("primary", $player[1] + 77, $player[2] + 60)
  297. Else
  298. MsgBox(0, "Error", "Cannot find name specified")
  299. Exit
  300. EndIf
  301. EndIf
  302. EndFunc
  303.  
  304. Func LoginCheck($handle)
  305. Local $dClient
  306. $dClient = WinGetPos($handle)
  307. If not (WinActive($handle)) Then
  308. WinActivate($handle)
  309. WinWaitActive($handle)
  310. EndIf
  311. if (UnableCheck($handle) = 1) Then
  312. Resume($handle)
  313. EndIf
  314. ErrorCheck($handle)
  315. $loggedin = _ImageSearch(@ScriptDir & "\loggedin", $dClient[0] + 22, $dClient[1] + 514, $dClient[0] + 38, $dClient[1] + 530, "TRANSBLACK", 70, 1, 0)
  316. ;~ ConsoleWrite("Logged in." & @CRLF)
  317. If IsArray($loggedin) Then
  318. Return 1
  319. Else
  320. Return 0
  321. EndIf
  322. EndFunc ;==>LoginCheck
  323.  
  324. Func AdriaCheck($handle)
  325. Local $dClient
  326. $dClient = WinGetPos($handle)
  327. If not (WinActive($handle)) Then
  328. WinActivate($handle)
  329. WinWaitActive($handle)
  330. EndIf
  331. For $a = 0 To 6
  332. For $b = 0 To 1
  333. ErrorCheck($handle)
  334. Local $coord = PixelSearch($dClient[0] + 5, $dClient[1] + 25, $dClient[0] + 260, $dClient[1] + 160, 0x3B2621, 3)
  335. If Not @error Then
  336. ErrorCheck($handle)
  337. MouseMove($coord[0], $coord[1],0)
  338. Sleep(100)
  339. $adria = _ImageSearch(@ScriptDir & "\adria", $dClient[0] + 5, $dClient[1] + 25, $dClient[0] + 260, $dClient[1] + 160, "TRANSFF00FF", 85, 1, 0)
  340. If Not @error Then
  341. ErrorCheck($handle)
  342. MouseClick("primary", $coord[0], $coord[1])
  343. Return 1
  344. EndIf
  345. EndIf
  346. Next
  347. Next
  348. EndFunc ;==>AdriaCheck
  349.  
  350. Func ErrorCheck($handle2)
  351. Local $dClient
  352. $dClient = WinGetPos($handle2)
  353. If not (WinActive($handle2)) Then
  354. WinActivate($handle2)
  355. WinWaitActive($handle2)
  356. EndIf
  357. $result = _ImageSearch(@ScriptDir & "\error", $dClient[0] + 385, $dClient[1] + 258, $dClient[0] + 430, $dClient[1] + 274, "TRANSFF00FF", 85, 1, 0)
  358. If IsArray($result) Then
  359. $error = True
  360. MouseMove($dClient[0] + 390, $dClient[1] + 382,0)
  361. MouseClick("primary", $dClient[0] + 390, $dClient[1] + 382)
  362. EndIf
  363. EndFunc ;==>PopupCheck
  364.  
  365. Func UnableCheck($handle2)
  366. Local $dClient
  367. $dClient = WinGetPos($handle2)
  368. If not (WinActive($handle2)) Then
  369. WinActivate($handle2)
  370. WinWaitActive($handle2)
  371. EndIf
  372. $unable = _ImageSearch(@ScriptDir & "\unable", $dClient[0] + 357, $dClient[1] + 254, $dClient[0] + 473, $dClient[1] + 276, "TRANSFF00FF", 85, 1, 0)
  373. if IsArray($unable) Then
  374. MouseMove($dClient[0] + 390, $dClient[1] + 382,0)
  375. MouseClick("primary", $dClient[0] + 390, $dClient[1] + 382)
  376. return 1
  377. Else
  378. return 0
  379. EndIf
  380. EndFunc ;==>PopupCheck
  381.  
  382. Func PopupCheck($handle)
  383. Local $dClient
  384. $dClient = WinGetPos($handle)
  385. If not (WinActive($handle)) Then
  386. WinActivate($handle)
  387. WinWaitActive($handle)
  388. EndIf
  389. ErrorCheck($handle)
  390. If Hex(PixelGetColor($dClient[0] + 283, $dClient[1] + 463)) = "00000000" Then
  391. Return 1
  392. Else
  393. Return 0
  394. EndIf
  395. EndFunc ;==>PopupCheck
  396.  
  397. Func End()
  398. Exit 0
  399. EndFunc ;==>End
  400.  
  401. Func _Imagesearch($file, $x1 = 0, $y1 = 0, $x2 = @DesktopWidth, $y2 = @DesktopHeight, $trans = "transblack", $variation = 60, $runs = 1, $behavior = 1)
  402. If $behavior > 3 Or $behavior < 0 Then $behavior = 1
  403. If $runs < 1 Or $behavior = 0 Then $runs = 1
  404. Dim $aCoords[$runs] = [99999]; just some number to make the _ArrayMax <-> _ArrayMin comparison work on it's first run
  405. $findImage = '*' & $trans & ' ' & '*' & $variation & ' ' & $file & ".bmp"
  406. if @AutoItX64 Then
  407. $dll = DllOpen("ImageSearchDLL_x64.dll")
  408. Else
  409. $dll = DllOpen("ImageSearchDLL.dll")
  410. EndIf
  411. While 1
  412. $result = DllCall($dll, "str", "ImageSearch", "int", $x1, "int", $y1, "int", $x2, "int", $y2, "str", $findImage)
  413. If $result[0] = "0" Then
  414. _ArrayPush($aCoords, 0, 1)
  415. Else
  416. _ArrayPush($aCoords, 1, 1)
  417. If $behavior = 1 Then ExitLoop
  418. EndIf
  419. If _ArrayMax($aCoords) == _ArrayMin($aCoords) Then ExitLoop
  420. Sleep(40)
  421. WEnd
  422. DllClose($dll)
  423. If $aCoords[0] = 1 Then
  424. $array = StringSplit($result[0], "|")
  425. Dim $aCoords[5] = [4, Int(Number($array[2])), Int(Number($array[3])), Int(Number($array[2])) + Int(Number($array[4]) / 2), Int(Number($array[3])) + Int(Number($array[5]) / 2)]
  426. Return ($aCoords)
  427. Else
  428. Return (0)
  429. EndIf
  430. EndFunc ;==>_Imagesearch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement