Minecraft Keyboard Camera Control

Post gaming related scripts
punchin
Posts: 439
Joined: 17 Jan 2014, 17:54

Minecraft Keyboard Camera Control

Post by punchin » 25 May 2021, 22:11

I searched for several days to find a way to use keyboard commands to control the camera on Minecraft as I'm playing it over Windows Remote Desktop (only option on my current setup) and moving my mouse makes is spaz out.

So, I came up with this gem. It works very well even with the delay between my remote computer and host.

It has the typical left, right, up, down, but can also do the diagonals. Delete on my keyboard is right above my arrow left key, so that's my left click and Page Down is above my right arrow key, so that's right click.

You can adjust the scroll speed with the + and - on the numberpad and it stores your speed in your computer's registry so it will be the same next time you use it.

I don't have it locked into an #If section to only activate with Minecraft up, but you can if you want.

Code: Select all

#SingleInstance, Force

SendMode, InputthenPlay

SetBatchLines -1

RegRead, IncrementValue, HKCU, Minecraft\KeyboardControl, IncrementValue
If ErrorLevel
{
    IncrementValue = 5
    RegWrite, Reg_DWORD, HKCU, Minecraft\KeyboardControl, IncrementValue, 5
}

MouseDelay = 0
Return

Left::
Right::
Up::
Down::

If (A_ThisHotkey = "Down")
{
    If (GetKeyState("Right", "P"))
        xVal := IncrementValue, yVal = IncrementValue
    Else
        If (GetKeyState("Left", "P"))
            xVal := -IncrementValue, yVal = IncrementValue
        Else
            xVal := 0, yVal := IncrementValue
}

If (A_ThisHotkey = "Up")
{
    If (GetKeyState("Right", "P"))
        xVal := IncrementValue, yVal = -IncrementValue
    Else
        If (GetKeyState("Left", "P"))
            xVal := -IncrementValue, yVal = -IncrementValue
        Else
            xVal := 0, yVal = -IncrementValue
}

If (A_ThisHotkey = "Left")
{
    If (GetKeyState("Up", "P"))
        xVal := -IncrementValue, yVal = -IncrementValue
    Else
        If (GetKeyState("Down", "P"))
            xVal := -IncrementValue, yVal = IncrementValue
        Else
            xVal := -IncrementValue, yVal = 0
}

If (A_ThisHotkey = "Right")
{
    If (GetKeyState("Up", "P"))
        xVal := IncrementValue, yVal = -IncrementValue
    Else
        If (GetKeyState("Down", "P"))
            xVal := IncrementValue, yVal = IncrementValue
        Else
            xVal := IncrementValue, yVal = 0
}

If GetKeyState(A_ThisHotKey, "P")
    DllCall("mouse_event", uint, 1, int, xVal, int, yVal, uint, 0, int, 0) ;-- Relative mouse position instead of absolute
Return

Del::Click down
Del UP::Click up

PgDn::Click, Right Down
PgDn up::Click, Right Up

NumpadAdd::
    IncrementValue := IncrementValue + 5
    RegWrite, Reg_DWORD, HKCU, Minecraft\KeyboardControl, IncrementValue, %IncrementValue%
    ToolTip,%IncrementValue%
    SetTimer, TT_Off, -2000
Return

NumpadSub::
    IfGreater, IncrementValue, 5
        IncrementValue := IncrementValue - 5
    RegWrite, Reg_DWORD, HKCU, Minecraft\KeyboardControl, IncrementValue, %IncrementValue%
    ToolTip,%IncrementValue%
    SetTimer, TT_Off, -2000
Return

TT_Off:
ToolTip
Return

^Esc::ExitApp
[Mod edit: c-tags replaced with [code][/code] tags.]

User avatar
juxwillx
Posts: 3
Joined: 20 May 2021, 15:30

Re: Minecraft Keyboard Camera Control

Post by juxwillx » 03 Jun 2021, 20:28

Hello,

Can you share some tutorial? I mean, I am not a tech geek. But I really want to use it.

punchin
Posts: 439
Joined: 17 Jan 2014, 17:54

Re: Minecraft Keyboard Camera Control

Post by punchin » 10 Jun 2021, 18:45

juxwillx wrote:
03 Jun 2021, 20:28
Hello,

Can you share some tutorial? I mean, I am not a tech geek. But I really want to use it.
A tutorial as far as using this file? Sure.
  • Save and launch the file as an ahk or compile to execute on your machine playing Minecraft.
    Once you are logged into a world, DO NOT TOUCH YOUR MOUSE.
    Use the arrow keys on your keyboard to control the camera. You can adjust the speed with the + and - on the numberpad. DEL and PgDwn are left and right click respectively. Feel free to change which keys do what before use.
As far as how to play over Windows Remote Desktop, you have to have Win 10 Ultimate. There are plenty of tutorials out there for setting that up.

Post Reply

Return to “Gaming Scripts (v1)”