Code:
#IfWinActive Path of Exile
#NoEnv
#SingleInstance , Force
SetWorkingDir %A_ScriptDir%
SendMode, Input
ConfigINI=%A_scriptdir%\Config.ini
ifnotexist,%ConfigINI%
{
IniWrite, 0 , %ConfigINI%, RerollPos, RerollPosX
IniWrite, 0 , %ConfigINI%, RerollPos, RerollPosY
IniWrite, 0 , %ConfigINI%, WindowGambleSearchGwennen, xLeft
IniWrite, 0 , %ConfigINI%, WindowGambleSearchGwennen, yLeft
IniWrite, 0 , %ConfigINI%, WindowGambleSearchGwennen, xRight
IniWrite, 0 , %ConfigINI%, WindowGambleSearchGwennen, yRight
}
SetMouseDelay, 45 ; ~latency
Global ReGixSearchedDelay := 200 ; ReGix search delay in game. This is a personal delay, it depends on ping and computer power
Global statusRoll := true
Global pixelColor := 0xE7B477
+F10::
MouseGetPos x, y
IniWrite,%x% , %ConfigINI%, RerollPos, RerollPosX
IniWrite,%y% , %ConfigINI%, RerollPos, RerollPosY
return
$F1::
if !GetKeyState("capslock","T")
{
SendInput, {F1}
}
else {
StartRoll()
}
return
+F9::
GetRange(x,y,w,h)
xr := x+w
yr := y+h
IniWrite,%x%, %ConfigINI%, WindowGambleSearchGwennen, xRight
IniWrite,%y%, %ConfigINI%, WindowGambleSearchGwennen, yRight
IniWrite,%xr%, %ConfigINI%, WindowGambleSearchGwennen, xRight
IniWrite,%yr%, %ConfigINI%, WindowGambleSearchGwennen, yRight
return
SearchItemAndClick(){
Global lastPositionFindX =
Global lastPositionFindY =
while(GetKeyState("F1","p") && statusRoll){
IniRead, _xLeft,Config.ini, WindowGambleSearchGwennen, xLeft
IniRead, _yLeft,Config.ini, WindowGambleSearchGwennen, yLeft
IniRead, _xRight,Config.ini, WindowGambleSearchGwennen, xRight
IniRead, _yRight,Config.ini, WindowGambleSearchGwennen, yRight
PixelSearch , Px, Py, _xLeft, _yLeft , _xRight, _yRight, pixelColor,3, Fast RGB
if (ErrorLevel) {
Break
}
else if (lastPositionFindX == Px && lastPositionFindY == Py){
Global statusRoll := false
Break
}
else{
Global lastPositionFindX := Px
Global lastPositionFindY := Py
SendInput, {Control down}
Sleep, 5
BlockInput, MouseMove
MouseClick, left, Px+=30, Py+=30
SendInput, {Control up}
BlockInput, MouseMoveOff
}
}
}
StartRoll(){
Global statusRoll := true
SearchItemAndClick()
while(GetKeyState("F1","p") && statusRoll) {
BlockInput, MouseMove
IniRead, _RerollPosX, Config.ini, RerollPos, RerollPosX
IniRead, _RerollPosY, Config.ini, RerollPos, RerollPosY
MouseClick, Left, _RerollPosX, _RerollPosY
Sleep ReGixSearchedDelay
BlockInput, MouseMoveOff
SearchItemAndClick()
}
}
GetRange(ByRef x="",ByRef y="",ByRef w="",ByRef h="")
{
; Save the initial state and set the current state
cmm:=A_CoordModeMouse
CoordMode, Mouse, Screen
; Create canvas GUI
nW:=A_ScreenWidth, nH:=A_ScreenHeight
Gui, Canvas:New, +AlWaysOnTop +ToolWindow -Caption
Gui, Canvas:Add, Picture, x0 y0 w%nW% h%nH% +0xE HwndPicID
; Create selection range GUI
Gui, Range:New, +LastFound +AlWaysOnTop -Caption +Border
+OwnerCanvas +HwndRangeID
WinSet, Transparent, 100
Gui, Range:Color, Yellow
; Screenshots to the memory image and sent to
; the picture control of the canvas window.
Ptr:=A_PtrSize ? "UPtr":"UInt", int:="int"
hDC:=DllCall("GetDC", Ptr,0, Ptr)
mDC:=DllCall("CreateCompatibleDC", Ptr,hDC, Ptr)
hBM:=DllCall("CreateCompatibleBitmap", Ptr,hDC, int,nW, int,nH, Ptr)
oBM:=DllCall("SelectObject", Ptr,mDC, Ptr,hBM, Ptr)
DllCall("BitBlt", Ptr,mDC, int,0, int,0, int,nW, int,nH
, Ptr,hDC, int,0, int,0, int,0x00CC0020|0x40000000)
DllCall("ReleaseDC", Ptr,0, Ptr,hDC)
;---------------------
SendMessage, 0x172, 0, hBM,, ahk_id %PicID%
if ( E:=ErrorLevel )
DllCall("DeleteObject", Ptr,E)
;---------------------
DllCall("SelectObject", Ptr,mDC, Ptr,oBM)
DllCall("DeleteDC", Ptr,mDC)
; Display the canvas window and start to wait for the selection range
Gui, Canvas:Show, NA x0 y0 w%nW% h%nH%
; Prompt to hold down the LButton key
ListLines, Off
oldx:=oldy:=""
Loop {
Sleep, 100
MouseGetPos, x, y
if (oldx=x and oldy=y)
Continue
oldx:=x, oldy:=y
;--------------------
ToolTip, Please hold down LButton key to select a range
}
Until GetkeyState("LButton","P")
; Prompt to release the LButton key
x1:=x, y1:=y, oldx:=oldy:=""
Loop {
Sleep, 100
MouseGetPos, x, y
if (oldx=x and oldy=y)
Continue
oldx:=x, oldy:=y
;--------------------
w:=Abs(x1-x), h:=Abs(y1-y)
x:=(x1+x-w)//2, y:=(y1+y-h)//2
Gui, Range:Show, NA x%x% y%y% w%w% h%h%
ToolTip, Please drag the mouse and release the LButton key
}
Until !GetkeyState("LButton","P")
; Prompt to click the RButton key to determine the range
oldx:=oldy:=""
Loop {
Sleep, 100
MouseGetPos, x, y, id
if (id=RangeID) and GetkeyState("LButton","P")
{
WinGetPos, x1, y1,,, ahk_id %RangeID%
Loop {
Sleep, 100
MouseGetPos, x2, y2
Gui, Range:Show, % "NA x" x1+x2-x " y" y1+y2-y
}
Until !GetkeyState("LButton","P")
}
if (oldx=x and oldy=y)
Continue
oldx:=x, oldy:=y
;--------------------
ToolTip, Please click the RButton key to determine the scope`,`n
and use the LButton key can adjust the scope
}
Until GetkeyState("RButton","P")
KeyWait, RButton
ToolTip
ListLines, On
; Clean the canvas and selection range GUI
WinGetPos, x, y, w, h, ahk_id %RangeID%
Gui, Range:Destroy
Gui, Canvas:Destroy
; Clean the memory image and restore the initial state
DllCall("DeleteObject", Ptr,hBM)
CoordMode, Mouse, %cmm%
}
How use: