Last active
February 24, 2016 02:29
-
-
Save itsthatguy/09cc4807946d8427ec43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StartX=1405 | |
StartY=560 | |
SizeX=50 | |
SizeY=50 | |
ClickOffset=15 | |
itemF1_1 := {x: 10, y: 3} | |
itemF1_2 := {x: 10, y: 5} | |
return | |
F1::SwapItems([itemF1_1, itemF1_2]) | |
F3::Boogers("X", 34) | |
Boogers(axis, x) { | |
MsgBox % Size%axis% | |
} | |
; Items | |
GetSlotPosX(x) { | |
global | |
return (x - 1) * SizeX + StartX + ClickOffset | |
} | |
GetSlotPosY(y) { | |
global | |
return (y - 1) * SizeY + StartY + ClickOffset | |
} | |
IsTheInventoryOpen() { | |
x=1596 | |
y=1 | |
w=120 | |
h=146 | |
ImageSearch, FoundX, FoundY, x,y, x+w,y+h, *100 images\inventory.jpg | |
if ErrorLevel | |
return 0 | |
else | |
return 1 | |
} | |
PurgeLeftMouse() { | |
GetKeyState, state, LButton, P | |
MouseClick, left, , , , 0, U | |
return state | |
} | |
PurgeRightMouse() { | |
GetKeyState, state, RButton, P | |
MouseClick, right, , , , 0, U | |
return state | |
} | |
RestoreLeftMouse(state) { | |
if (state == "D") { | |
MouseClick, left, , , , 0, D | |
} | |
} | |
RestoreRightMouse(state) { | |
if (state == "D") { | |
MouseClick, right, , , , 0, D | |
} | |
} | |
PurgeShift() { | |
GetKeyState, state, Shift, P | |
Send, {Shift Up} | |
return state | |
} | |
RestoreShift(state) { | |
if (state == "D") { | |
Send, {Shift Down} | |
} | |
} | |
SwapItems(items) { | |
MouseGetPos Mx, My | |
DidItStartOpen := IsTheInventoryOpen() | |
if (DidItStartOpen == 0) { | |
Send {i down}{i up} | |
} | |
; store current mouse state | |
shiftState := PurgeShift() | |
leftState := PurgeLeftMouse() | |
rightState := PurgeRightMouse() | |
for each, item in items { | |
fx := GetSlotPosX(item.x) | |
fy := GetSlotPosY(item.y) | |
MouseClick, right, %fx%, %fy%, , 0 | |
Sleep, 160 | |
} | |
if (DidItStartOpen == 0) { | |
Send {i down}{i up} | |
} | |
; put the mouse back where it started | |
MouseMove Mx, My, 0 | |
RestoreShift(shiftState) | |
RestoreLeftMouse(leftState) | |
RestoreRightMouse(rightState) | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the inventory image used...