Guest User

Untitled

a guest
Jun 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. ; Set our co-ordinates relative to the active window
  2. AutoItSetOption("MouseCoordMode", 0)
  3. $registered = false
  4. Dim $keys[10][2]
  5.  
  6. While 1
  7. If WinActive("Plants vs. Zombies") Then
  8. RegisterKeys()
  9. Else
  10. UnregisterKeys()
  11. EndIf
  12. Sleep(100)
  13. WEnd
  14.  
  15. ; This function selects the plant associated with the hotkey and moves
  16. ; the mouse back into the existing position.
  17. Func SelectPlant()
  18. If WinActive("Plants vs. Zombies") Then
  19. $slot = @HotKeyPressed
  20. $slot -= 1;
  21. If $slot == -1 Then
  22. $slot = 9
  23. EndIf
  24. $currentPosition = MouseGetPos()
  25. MouseClick("primary", $keys[$slot][0], $keys[$slot][1], 1, 0)
  26. MouseMove($currentPosition[0], $currentPosition[1], 0)
  27. EndIf
  28. EndFunc
  29.  
  30. Func RegisterKeys()
  31. If NOT $registered Then
  32. $i = 0
  33. $x = 114
  34. $y = 70
  35. While $i < 10
  36. ; Add the plant position to the array
  37. $keys[$i][0] = $x
  38. $keys[$i][1] = $y
  39.  
  40. ; Register the hotkey for this number
  41. HotKeySet($i, "SelectPlant")
  42.  
  43. ; Increase the X value to be the next button
  44. $x += 52
  45. $i += 1
  46. WEnd
  47. $registered = true
  48. EndIf
  49. EndFunc
  50.  
  51. Func UnregisterKeys()
  52. If $registered Then
  53. $i = 0
  54. While $i < 10
  55. HotKeySet($i);
  56. $i += 1;
  57. WEnd
  58. $registered = false
  59. EndIf
  60. EndFunc
Add Comment
Please, Sign In to add comment