Code:
#IfWinActive, Path of Exile ;check if a window with title "Path of Exile", casesensitive
Menu, Tray, Icon, Images\Off.ico ;get a icon image
Menu, Tray, Tip, Antyradio.pl ;tool tip when mouse over icon
Menu, Tray, Add ;creates a separator line
Menu, Tray, Add, Windowed (Borders), Border ; create a new menu item
Menu, Tray, Add, Windowed (Borderless), Borderless
Menu, Tray, Add, How To Use, HowToUse
;load border information from ini file
toggle = 0
IniRead, bl, setting.ini, border, borderleft
IniRead, br, setting.ini, border, borderright
IniRead, bt, setting.ini, border, bordertop
IniRead, bd, setting.ini, border, borderdown
IniRead, bd, setting.ini, border, borderdown
;load potion information from ini file
;high HP
IniRead, usepotionhphigh, setting.ini, potion_high, hpremain
IniRead, usepotionflaskindex1, setting.ini, potion_high, flask
;low HP
IniRead, usepotionhplow, setting.ini, potion_low, hpremain
IniRead, usepotionflaskindex2, setting.ini, potion_low, flask
;load defensive potion information from ini file
IniRead, usepotiondefensive, setting.ini, defensive_potion, hpremain
IniRead, usedefensivepotionflaskindex, setting.ini, defensive_potion, flask
IniRead, usedefcd, setting.ini, defensive_potion, defcd
;load mana potion information from ini file
IniRead, usepotionmp, setting.ini, mana_potion, mpremain
IniRead, usemanapotionflaskindex, setting.ini, mana_potion, flask
;load quicksilver potion information from ini file
IniRead, usepotionquick, setting.ini, quicksilver, timeleft
IniRead, usequickpotionflaskindex, setting.ini, quicksilver, flask
IniRead, usequickcd, setting.ini, quicksilver, quickcd
;load logout information from ini file
IniRead, logouthp, setting.ini, logout, hpremain
IniRead, logoutflaskindex, setting.ini, logout, flask
;load anchor information from ini file
IniRead, defaultLogoutX, setting.ini, anchor, logoutbtnx
IniRead, defaultLogoutY, setting.ini, anchor, logoutbtny
IniRead, defaultWindowWidth, setting.ini, anchor, windoww
IniRead, defaultWindowHeight, setting.ini, anchor, windowh
IniRead, defaultHPMiddleX, setting.ini, anchor, hpmiddlex
IniRead, defaultHPMiddleY, setting.ini, anchor, hpmiddley
IniRead, defaultHPTopY, setting.ini, anchor, hptopy
IniRead, defaultMPMiddleX, setting.ini, anchor, mpmiddlex
IniRead, defaultMPMiddleY, setting.ini, anchor, mpmiddley
IniRead, defaultMPTopY, setting.ini, anchor, mptopy
IniRead, defaultChatX, setting.ini, anchor, chaticonx
IniRead, defaultChatY, setting.ini, anchor, chaticony
IniRead, defaultHideX, setting.ini, anchor, hideiconx
IniRead, defaultHideY, setting.ini, anchor, hideicony
IniRead, defaultMovX, setting.ini, anchor, movposx
IniRead, defaultMovY, setting.ini, anchor, movposy
;load other information from ini file
IniRead, mousespeed, setting.ini, other, mousespeed ;0~100(instant~slow)
IniRead, checkdelay, setting.ini, other, checkdelay
;HP-Potion
defaultUsePotion1HPY := floor(defaultHPTopY + (defaultWindowHeight-defaultHPTopY-bd) * (1-usepotionhphigh/100))
defaultUsePotion2HPY := floor(defaultHPTopY + (defaultWindowHeight-defaultHPTopY-bd) * (1-usepotionhplow/100))
;Def-Potion
defaultUseDefensivePotionHPY := floor(defaultHPTopY + (defaultWindowHeight-defaultHPTopY-bd) * (1-usepotiondefensive/100))
;MP-Potion
defaultUseManaPotionMPY := floor(defaultMPTopY + (defaultWindowHeight-defaultMPTopY-bd) * (1-usepotionmp/100))
defaultLogoutHPY := floor(defaultHPTopY + (defaultWindowHeight-defaultHPTopY-bd) * (1-logouthp/100))
adjustLogout_X := 0
adjustLogout_Y := 0
return
;debug
`::
MouseGetPos, xpos, ypos
MsgBox, The cursor is at X%xpos% Y%ypos%.
return
;`::
;run, cports.exe /close * * * * PathofExile_x64.exe
;return
F3::
WinGetPos,,, w, h, A
heightResizeRatio := (h-bt-bd)/(defaultWindowHeight-bt-bd)
; calculate log out button position
if (adjustLogout_X == 0 && adjustLogout_Y == 0)
{
adjustLogout_X := w/2
;adjustLogout_Y := (defaultLogoutY-bt)*heightResizeRatio+bt
adjustLogout_Y := defaultLogoutY
}
; calculate HP center position and chat icon position
HX := defaultHPMiddleX
HY := defaultHPMiddleY
MX := defaultMPMiddleX
MY := defaultMPMiddleY
CX := defaultChatX
CY := defaultChatY
HIX:= defaultHideX
HIY:= defaultHideY
MOX:= defaultMovX
MOY:= defaultMovY
;use this to check if the position is correct
MouseMove HX, HY
;MouseMove MX, MY
;MouseMove CX, CY
; calculate use potion and logout HP Y
adjustUsePotion1HPY := defaultUsePotion1HPY
adjustUsePotion2HPY := defaultUsePotion2HPY
adjustUseDefensivePotionHPY := defaultUseDefensivePotionHPY
adjustUseManaPotionMPY := defaultUseManaPotionMPY
adjustLogoutHPY := defaultLogoutHPY
;use this to check if the position is correct
;MouseMove HX, adjustUsePotion1HPY
;MouseMove HX, adjustUsePotion2HPY
;MouseMove HX, adjustUseDefensivePotionHPY
MouseMove MX, adjustUseManaPotionMPY
;MouseMove HX, adjustLogoutHPY
;calculate chat icon search region, top left:(chatX1, chatY1), buttom right:(chatX2, chatY2)
chatX1 := CX-7
chatX2 := CX+7
chatY1 := CY-7
chatY2 := CY+7
;calculate hideout icon search region, top left:(hiX1, hiY1), buttom right:(hiX2, hiY2)
hiX1 := HIX
hiX2 := HIX
hiY1 := HIY
hiY2 := HIY
;calculate use potion hp search region, top left:(hp1_X1, hp1_Y1), buttom right:(hp1_X2, hp1_Y2)
hp1_X1 := HX-7
hp1_X2 := HX+7
hp1_Y1 := adjustUsePotion1HPY-7
hp1_Y2 := adjustUsePotion1HPY+7
hp5_Y1 := adjustUsePotion2HPY-7
hp5_Y2 := adjustUsePotion2HPY+7
;calculate use defensive potion hp search region, top left:(hp3_X1, hp3_Y1), buttom right:(hp3_X2, hp3_Y2)
hp3_X1 := HX-7
hp3_X2 := HX+7
hp3_Y1 := adjustUseDefensivePotionHPY-7
hp3_Y2 := adjustUseDefensivePotionHPY+7
;calculate use mana potion mp search region, top left:(mp1_X1, mp1_Y1), buttom right:(mp1_X2, mp1_Y2)
mp1_X1 := MX-7
mp1_X2 := MX+7
mp1_Y1 := adjustUseManaPotionMPY-7
mp1_Y2 := adjustUseManaPotionMPY+7
;calculate log out hp search region, top left:(hp2_X1, hp2_Y1), buttom right:(hp2_X2, hp2_Y2)
hp2_X1 := HX-7
hp2_X2 := HX+7
hp2_Y1 := adjustLogoutHPY-7
hp2_Y2 := adjustLogoutHPY+7
;calculate movearea search region, top left:(movX1, movY1), buttom right:(movX2, movY2)
movX1 := MOX
movX2 := MOX
movY1 := MOY
movY2 := MOY
;get hp center color and chat icon color used for pixel search later
PixelGetColor, hpcolor1 , %HX%, %adjustUsePotion1HPY% ; get color GRB
PixelGetColor, hpcolor1rgb , %HX%, %adjustUsePotion1HPY%, RGB ; get color RGB
PixelGetColor, hpcolor5 , %HX%, %adjustUsePotion2HPY% ; get color GRB
PixelGetColor, hpcolor5rgb , %HX%, %adjustUsePotion2HPY%, RGB ; get color RGB
PixelGetColor, hpcolor2 , %HX%, %adjustLogoutHPY% ; get color GRB
PixelGetColor, hpcolor2rgb , %HX%, %adjustLogoutHPY%, RGB ; get color RGB
PixelGetColor, hpcolor3 , %HX%, %adjustUseDefensivePotionHPY% ; get color GRB
PixelGetColor, hpcolor3rgb , %HX%, %adjustUseDefensivePotionHPY%, RGB ; get color RGB
PixelGetColor, mpcolor1 , %MX%, %adjustUseManaPotionMPY% ; get color GRB
PixelGetColor, mpcolor1rgb , %MX%, %adjustUseManaPotionMPY%, RGB ; get color RGB
PixelGetColor, chaticoncolor , %CX%, %CY%
PixelGetColor, chaticoncolorrgb , %CX%, %CY%, RGB
PixelGetColor, HOcolor , %HIX%, %HIY%
PixelGetColor, HOcolorrgb , %HIX%, %HIY%, RGB
;HOcolor:= put here your Pixelcolor
;HOcolorrgb := put here your RGB Pixelcolor
PixelGetColor, MoveColor , %MOX%, %MOY%
PixelGetColor, MoveColorrgb , %MOX%, %MOY%, RGB
;pop up a gui showing the finding color for user to double check
gui, new
gui, Default
gui, +LastFound ; make the GUI window the last found window for use by the line below.
gui, add, groupbox, w205 h200, Colors found:
gui, add, text, yp+25 xp+10, Chat Icon Color:
gui, add, Progress, xp+80 yp-5 w100 h20 c%chaticoncolorrgb%,100
gui, add, text, yp+25 xp-80, HP-High Potion:
gui, add, Progress, xp+80 yp-5 w100 h20 c%hpcolor1rgb%,100
gui, add, text, yp+25 xp-80, HP-Low Potion:
gui, add, Progress, xp+80 yp-5 w100 h20 c%hpcolor5rgb%,100
gui, add, text, yp+25 xp-80, Logout Color:
gui, add, Progress, xp+80 yp-5 w100 h20 c%hpcolor2rgb%,100
gui, add, text, yp+25 xp-80, Def. Potion Color:
gui, add, Progress, xp+80 yp-5 w100 h20 c%hpcolor3rgb%,100
gui, add, text, yp+25 xp-80, Mana Color:
gui, add, Progress, xp+80 yp-5 w100 h20 c%mpcolor1rgb%,100
gui, add, button, xp-80 yp+25 w25 h25 gDone, OK
gui, show, ,Activated
Menu, Tray, Icon, Images\On.ico
; Functions
RandomSleep(min,max){
Random, r, %min%, %max%
r:=floor(r/Speed)
Sleep %r%
return
}
AutoClicks(){
BlockInput On
Send {blind}{Lbutton down}{Lbutton up}
BlockInput Off
}
;start searching (render a frame takes 0.03 sec in 30FPS, so we set the search time to 0.1 sec to make sure it won't search the same frame twice)
Loop
{
IfWinActive, Path of Exile
{
;find the orange chat Icon (makes sure you are on a character)
;variable ErrorLevel is set to 0 if the color was found in the specified region, 1 if it was not found,
; or 2 if there was a problem that prevented the command from conducting the search.
PixelSearch, FoundoX, FoundoY, %chatX1%, %chatY1%, %chatX2%, %chatY2%, %chaticoncolor%, 5, Fast
if ErrorLevel = 0
{
;use potion when HP-High reaches the ratio user set
PixelSearch, FoundhX, FoundhY, %hp1_X1%, %hp1_Y1%, %hp1_X2%, %hp1_Y2%, %hpcolor1%, 5, Fast
if ErrorLevel = 1
{
SendInput, %usepotionflaskindex1%
RandomSleep(89,128)
}
;use potion when HP-Low reaches the ratio user set
PixelSearch, FoundhX, FoundhY, %hp1_X1%, %hp5_Y1%, %hp1_X2%, %hp5_Y2%, %hpcolor5%, 5, Fast
if ErrorLevel = 1
{
SendInput, %usepotionflaskindex2%
RandomSleep(89,128)
}
;use defensive potion when HP reaches the ratio user set
PixelSearch, FoundhX, FoundhY, %hp3_X1%, %hp3_Y1%, %hp3_X2%, %hp3_Y2%, %hpcolor3%, 5, Fast
if ErrorLevel = 1
{
if (A_TickCount > defcdnext)
{
SendInput, %usedefensivepotionflaskindex%
defcdnext:= A_TickCount + usedefcd - 200
}
}
;use mana potion when MP reaches the ratio user set
PixelSearch, FoundhX, FoundhY, %mp1_X1%, %mp1_Y1%, %mp1_X2%, %mp1_Y2%, %mpcolor1%, 5, Fast
if ErrorLevel = 1
{
SendInput, %usemanapotionflaskindex%
RandomSleep(89,128)
}
;Quicksilver
PixelSearch, FoundhX, FoundhY, %hiX1%, %hiY1%, %hiX2%, %hiY2%, %HOcolor%, 1, Fast
if ErrorLevel = 1
{
if (A_TickCount > tlast)
{
PixelSearch, FoundhX, FoundhY, %movX1%, %movY1%, %movX2%, %movY2%,%MoveColor%, 10, Fast
if ErrorLevel = 1
{
PixelGetColor, MoveColor , %MOX%, %MOY%
PixelGetColor, MoveColorrgb , %MOX%, %MOY%, RGB
tlast:= A_TickCount
RandomSleep(89,128)
PixelSearch, FoundhX, FoundhY, %movX1%, %movY1%, %movX2%, %movY2%, %MoveColor%, 10, Fast
if ErrorLevel = 1
{
SendInput, %usequickpotionflaskindex%
tlast := (A_TickCount + usequickcd - 100)
Goto, JumpToEnd
}
tlast:= A_TickCount + usepotionquick
PixelGetColor, MoveColor , %MOX%, %MOY%
PixelGetColor, MoveColorrgb , %MOX%, %MOY%, RGB
JumpToEnd:
}
}
}
;log out when HP reaches the ratio user set
PixelSearch, FoundhX, FoundhY, %hp2_X1%, %hp2_Y1%, %hp2_X2%, %hp2_Y2%, %hpcolor2%, 5, Fast
if ErrorLevel = 1
{
SendInput, %logoutflaskindex%
RandomSleep(89,128)
; run, cports.exe /close * * * * PathofExile_x64.exe
}
}
}
Sleep, checkdelay
}
return
Border:
MsgBox, Windowed (Borders all around)
;For Windowed (with Borders all round)
bl = 0
br = 0
bt = 29
bd = 0
IniWrite, %bl%, setting.ini, border, borderleft
IniWrite, %br%, setting.ini, border, borderright
IniWrite, %bt%, setting.ini, border, bordertop
IniWrite, %bd%, setting.ini, border, borderdown1212
return
Borderless:
MsgBox, Borderless (No Borders)
;For Fullscreen Borderless
bl = 0
br = 0
bt = 0
bd = 0
IniWrite, %bl%, setting.ini, border, borderleft
IniWrite, %br%, setting.ini, border, borderright
IniWrite, %bt%, setting.ini, border, bordertop
IniWrite, %bd%, setting.ini, border, borderdown
return
Done:
gui, submit, nohide
gui, destroy
return
HowToUse:
MsgBox, `: Instant Logout`nF3: Activate`nF4: Reload`nF12: Exit`nCtrl+X: resync
return
^x::
SendInput, {Enter}
sleep, 20
SendInput, {/}oos
SendInput, {Enter}
return
F4::Reload
F12::ExitApp
; KEY Binding
; Legend: ! = Alt ^ = Ctrl + = Shift
; -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
!WheelDown::Send {Right} ; ALT+WheelDown: Stash scroll
return
!WheelUp::Send {Left} ; ALT+WheelUp: Stash scroll
return
^WheelDown::AutoClicks() ; CTRL+WheelDown -> Spam CTRL+CLICK
return
+WheelDown::AutoClicks() ; SHIFT+WheelDown -> Spam SHIFT+CLICK
return
; -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$!H::Send {Enter} /hideout {Enter} ; ALT+H
return
$!R::Send {Enter} /remaining {Enter} ; ALT+R
return
The Hideout-Check is done by checking the Edit-button and his color, so if you start the script you have to be in the Hideout. After you find the exact color of the pixel you can take this color and impliment it in the AHK script (comment the two "PixelGetColor, HOcolor" lines and uncomment the "HOcolor" below). Now you can start the script even outside your hideout.