Skip to content

Instantly share code, notes, and snippets.

@BanditTech
Last active July 4, 2020 07:22
Show Gist options
  • Save BanditTech/a975f7f8ee36e8ae6bbabcbe6809f55d to your computer and use it in GitHub Desktop.
Save BanditTech/a975f7f8ee36e8ae6bbabcbe6809f55d to your computer and use it in GitHub Desktop.
Inventory Testbench
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Create Executable group for gameHotkey, IfWinActive
global POEGameArr := ["PathOfExile.exe", "PathOfExile_x64.exe", "PathOfExileSteam.exe", "PathOfExile_x64Steam.exe", "PathOfExile_KG.exe", "PathOfExile_x64_KG.exe"]
for n, exe in POEGameArr
GroupAdd, POEGameGroup, ahk_exe %exe%
Global GameStr := "ahk_group POEGameGroup"
; Build array framework
StashGrid:={"Stash":{"X":{},"Y":{}}
,"StashQuad":{"X":{},"Y":{}}}
; Stash grid area
vX_StashTopL:=16, vY_StashTopL:=160
vX_StashBotR:=650, vY_StashBotR:=795
; Calculate space for the grid
totalX:=vX_StashBotR - vX_StashTopL, totalY:=vY_StashBotR - vY_StashTopL
; Give pixels for lines between slots
SlotSpacing:=2
; Fill in array with grid locations for 12x12 stash
Cnum:=Rnum:=12
Cwidth:=((totalX-((Cnum-1)*SlotSpacing))/Cnum)
, Rwidth:=((totalY-((Rnum-1)*SlotSpacing))/Rnum)
Loop, %Cnum%
{
If (A_Index = 1)
{
PointX:=vX_StashTopL+Cwidth//2
PointY:=vY_StashTopL+Rwidth//2
} Else {
PointX+=Cwidth+SlotSpacing
PointY+=Rwidth+SlotSpacing
}
StashGrid.Stash.X.Push(Round(PointX))
StashGrid.Stash.Y.Push(Round(PointY))
}
; Fill in array with grid locations for 24x24 stash
Cnum:=Rnum:=24
Cwidth:=((totalX-((Cnum-1)*SlotSpacing))/Cnum), Rwidth:=((totalY-((Rnum-1)*SlotSpacing))/Rnum)
Loop, %Cnum%
{
If (A_Index = 1)
{
PointX:=vX_StashTopL+Cwidth//2
PointY:=vY_StashTopL+Rwidth//2
} Else {
PointX+=Cwidth+SlotSpacing
PointY+=Rwidth+SlotSpacing
}
StashGrid.StashQuad.X.Push(Round(PointX))
StashGrid.StashQuad.Y.Push(Round(PointY))
}
WinActivate, %GameStr%
For C, Cval in StashGrid.Stash.X
{
For R, Rval in StashGrid.Stash.Y
{
If (C=R)
{
MouseMove Cval, Rval
Sleep, 30
}
}
}
For C, Cval in StashGrid.StashQuad.X
{
For R, Rval in StashGrid.StashQuad.Y
{
If (C=R)
{
MouseMove Cval, Rval
Sleep, 30
}
}
}
@BanditTech
Copy link
Author

this just takes the mouse and goes diagonally across the inventory grid. This is a scaled version of inventory system, which can allow for easier custom locations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment