AutoHotkey

From MinecraftOnline
(Redirected from AutoHotkeys)
Jump to navigation Jump to search
Translations: Français

AutoHotkey, downloadable from AutoHotkey.com, is a program for executing scripted macro functions in Windows to issue a command with the press of a single hotkey, or combination of hotkeys.

AutoHotkey's main use as it relates to the MinecraftOnline Server and its Players is to enable one button execution of commands that would otherwise require a player to stop what they are doing and manually type out the command.

Usage

In practice, a Moderator, Admin, or donator with the ability to use the /descend command could assign a hotkey to execute the /descend command instantaneously, saving the time they would otherwise have spent accessing the chat and typing the command to execute it manually.

For example, the macro q::Send t /home {enter} will send you to your /sethome location with the press of the button "q".

NOTE: this is a Windows program and will not work on Mac OS X nor any version of Linux.

Samples

Below is a sample script that can be edited by an end user to fit their button preferences, enabling them to assign keys to the commands available on the MinecraftOnline Server.

Template AutoHotkey script for basic MineraftOnline Server commands:

   SetKeyDelay, 0, 50
   <hotkey>::Send <chat button>/descend{enter}
   <hotkey>::Send <chat button>/ascend{enter}
   <hotkey>::Send <chat button>/thru{enter}
   <hotkey>::Send <chat button>/heal{enter}
   <hotkey>::Send <chat button>/jumpto{enter}
   <hotkey>::Send <chat button>/sethome{enter}
   <hotkey>::Send <chat button>/home{enter}
   <hotkey>::Send <chat button>/playerlist{enter}
   <hotkey>::Send <chat button>/compass{enter}
   <hotkey>::Send <chat button>/getpos{enter}
   <hotkey>::Send <chat button>/spawn{enter}

The sample script can be downloaded here: AutoHotkey.ahk

This script contains a SetKeyDelay to prevent the command being entered too quickly, ensuring the Minecraft Client registers the chat button being pressed. On faster or slower machines, this can be lowered and raised accordingly to fit the player's needs.

Window selection

It's possible to restrict autohotkey to only activate in specific windows. The below example demonstrates use of autohotkey restricted to windows having the title "Minecraft". The line starting with a semicolon is a comment. The ^e means ctrl+e.

;Minecraft:
#IfWinActive, Minecraft
^e::Send t/jumpto{ENTER}

Delays

Since the release of Minecraft 1.8, previous scripts often fail due to the delay in opening the chat window. As a result, a delay variable needs to be introduced in most cases. Below is an example script demonstrating this in action:

;Minecraft:
#IfWinActive, Minecraft

Delay = 200

XButton1::
Send, t
Sleep, %Delay%
Send, /jumpto{ENTER}
return

^q::
Send, t
Sleep, %Delay%
Send, /ascend{ENTER}
return

^z::
Send, t
Sleep, %Delay%
Send, /descend{ENTER}
return

^w::
Send, t
Sleep, %Delay%
Send, /thru{ENTER}
return

^e::
Send, t
Sleep, %Delay%
Send, /heal{ENTER}
return

Functions

You may have noticed that many lines that are repeated for each command. To make defining new commands less tedious, you can use functions to do the repetitive work for you. A function that sends a text to the chat looks like this:

toChat(text)
{
   Send t
   Sleep 200
   Send %text%
   Send {Enter}
}

Now the list of commands from the previous section can be defined in a much more concise way:

XButton1::toChat("/jumpto")
^q::toChat("/ascend")
^z::toChat("/descend")
^w::toChat("/thru")
^e::toChat("/heal")

See Also