Advertisement
Guest User

Untitled

a guest
Apr 6th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. global X1,Y1,X2,Y2
  6.  
  7. OnMessage(0x14, "WM_ERASEBKGND")
  8. Gui, -Caption +ToolWindow
  9. Gui, +LastFound
  10. WinSet, TransColor, Black
  11. ; Create the pen here so we don't need to create/delete it every time.
  12. RedPen := DllCall("CreatePen", "int", PS_SOLID:=0, "int", 5, "uint", 0xff)
  13. return
  14.  
  15. WM_ERASEBKGND(wParam, lParam)
  16. {
  17.     global x1, y1, x2, y2, RedPen
  18.     Critical 50
  19.     if A_Gui = 1
  20.     {
  21.         ; Retrieve stock brush.
  22.         blackBrush := DllCall("GetStockObject", "int", BLACK_BRUSH:=0x4)
  23.         ; Select pen and brush.
  24.         oldPen := DllCall("SelectObject", "uint", wParam, "uint", RedPen)
  25.         oldBrush := DllCall("SelectObject", "uint", wParam, "uint", blackBrush)
  26.         ; Draw rectangle.
  27.         DllCall("Rectangle", "uint", wParam, "int", 0, "int", 0, "int", x2-x1, "int", y2-y1)
  28.         ; Reselect original pen and brush (recommended by MS).
  29.         DllCall("SelectObject", "uint", wParam, "uint", oldPen)
  30.         DllCall("SelectObject", "uint", wParam, "uint", oldBrush)
  31.         return 1
  32.     }
  33. }
  34.  
  35. +LButton::
  36.    coordmode, mouse, screen
  37.     MouseGetPos, xorigin, yorigin
  38. ;   msgbox, %xorigin%, %yorigin%
  39.     SetTimer, rectangle, 10
  40. return
  41.  
  42. rectangle:
  43.   coordmode, mouse, screen
  44.     MouseGetPos, x2, y2
  45. ;   msgbox, %xorigin%, %yorigin%
  46.     ; Has the mouse moved?
  47.     if (x1 y1) = (x2 y2)
  48.         return
  49.    
  50.     ; Allow dragging to the left of the click point.
  51.     if (x2 < xorigin) {
  52.         x1 := x2
  53.         x2 := xorigin
  54.     } else
  55.         x1 := xorigin
  56.    
  57.     ; Allow dragging above the click point.
  58.     if (y2 < yorigin) {
  59.         y1 := y2
  60.         y2 := yorigin
  61. } else
  62.     y1 := yorigin
  63.  
  64. Gui, Show, % "NA X" x1 " Y" y1 " W" x2-x1 " H" y2-y1
  65. Gui, +LastFound +AlwaysOnTop
  66. WinGetPos, X, Y, W, H
  67. Tooltip % "X: " X ", Y: " Y "`nWidth: " W ", Height: " H
  68. DllCall("RedrawWindow", "uint", WinExist(), "uint", 0, "uint", 0, "uint", 5)
  69. return
  70.  
  71. +LButton Up::
  72. SetTimer, rectangle, Off
  73. Gui, Cancel
  74. coordmode, mouse, window
  75. tooltip
  76. msgbox % "X: " X ", Y: " Y "`nWidth: " W ", Height: " H
  77.  
  78.  
  79.  
  80. X1 = % X
  81. Y1 = % Y
  82. X2 = % W+X
  83. Y2 = % H+Y
  84. msgbox %X1% and %Y1% AND %X2% AND %Y2% %y1% %x1%
  85. MsgBox % "x2=" X2 "y2=" Y2
  86. ;call image search funcction IMPORTENT add X1,Y1,X2,Y2 INTO THE FUNCTION
  87. check_zombie()
  88. return
  89.  
  90.  
  91.  
  92.  
  93. check_zombie()
  94. {
  95.     WinActivate,Path of Exile
  96.     CoordMode Pixel, Relative
  97.     CoordMode Mouse, Relative
  98.     tooltip, Scanning for zombies
  99.     ;FoundX :=0
  100.     ;FoundY :=0
  101. ;;set it up like this
  102.     ImageSearch, FoundX, FoundY,%X1%, %Y1%, %X2%, %Y2%, zombie2.png
  103.    
  104.     if ErrorLevel = 2
  105.         tooltip Could not conduct the search.
  106.     else if ErrorLevel = 1
  107.         ;tooltip Image could not be found on the screen.
  108.         SendInput {e}
  109.    
  110.     else{
  111.         mousemove, %FoundX%, %FoundY%, 5
  112.         tooltip The image was found at %FoundX%x%FoundY%.
  113.        
  114.     }
  115. }
  116. ;coords area
  117. ;1795,126
  118.  
  119.  
  120. f4::
  121. check_zombie()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement