My first foray into AHK: Minecraft auto sell script

Post gaming related scripts
User avatar
Strahan
Posts: 17
Joined: 09 Dec 2016, 17:50
Location: Pennsylvania

My first foray into AHK: Minecraft auto sell script

09 Dec 2016, 18:06

I have been using Macro Express for years. I wanted to send a coworker a macro though but she didn't have M.E. and couldn't install it so I searched for macro progs that can compile, ergo I ended up using AutoHotKey. My God this is a great program :) Macro Express is going to be retired for me now :)

Sooo anyway, a kid on a Minecraft forum wanted a macro to sell all the enderpearls from a chest at a shop that uses Essentials sign eco. I came up with this:

Code: Select all

#IfWinActive, Minecraft

DebugMode := 1
SingleOrDouble := 2
StartX := 830
StartY := 410
PurchaseClicks := 16
ChestHome := "spawner"
ShopHome := "shop"
CurrentX := 0
CurrentY := 0
TotalLoops := SingleOrDouble * 27

if (SingleOrDouble = 2) {
  StartX := StartX - 10
  StartY := StartY - 52
}

^o::ExitApp

^r::
  Loop, %TotalLoops% {
    if (CurrentX = 9) {
      CurrentX = 0
      CurrentY++
    }
    ChestX := StartX + (CurrentX * 36)
    ChestY := StartY + (CurrentY * 36)

    if (DebugMode = 0 or (DebugMode = 1 AND CurrentX = 0 AND CurrentY = 0)) {
      send, T
      sleep 150
      send, /home %ChestHome%{enter}
      sleep 500
      
      MouseClick, right
      sleep 400
    }
  
    MouseMove ChestX, ChestY
    if (DebugMode = 0) {
      msgbox "debug off"
      sleep 50
      send, {shift down}
      sleep 100
      MouseClick, left
      sleep 100
      send, {shift up}
      sleep 100
      send, {escape}
      sleep 400
    
      send, T
      sleep 150
      send, /home %ShopHome%{enter}
      sleep 500
    
      Loop, %PurchaseClicks% {
        MouseClick, right
        sleep 350
      }
    } else {
      sleep 100
    }

    CurrentX++
  }

return
It tests good on my box, works great. As a noob though, I was wondering if experienced users saw any mistakes I made or things I could optimize? One thing I'd like to figure out how to do would be to automatically adjust the StartX and StartY screen positions in case the user's screen is not setup the way mine is. I designed this for a maximized game window on a 1080p resolution. DebugMode is there so one can preview where the macro thinks the slots are to let you adjust accordingly, but it'd be cool to figure a way to make it automatically adjust. Gotta get some more experience with AHK first I guess :)
Notus
Posts: 7
Joined: 14 Jun 2016, 19:58

Re: My first foray into AHK: Minecraft auto sell script

09 Dec 2016, 19:13

We have a separate forum for Gaming related script btw :)

Return to “Gaming Scripts (v1)”

Who is online

Users browsing this forum: No registered users and 56 guests