Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; # Windows Logo Key
- ; ! Alt
- ; ^ Control
- ; + Shift
- ; * Fire hotkey even if extra modifiers are held
- ; ~ Don't block native function
- ;==================================================================================================
- ; AHK setting
- #NoEnv
- SetBatchLines -1
- SetTitleMatchMode 2
- #SingleInstance Force
- SetWorkingDir %A_ScriptDir%
- ; Initialize SoundPlay to remove delay
- SoundPlay, ""
- ;==================================================================================================
- ; Globle values
- wintitle := Minecraft X-AHK V0.4
- targettitle := none
- TARGET_WIN_CLASS := GLFW30 ; Class of a Java program
- ModeText := Empty
- id := 0
- ProgState := 0
- autoSwing := 0
- switchClickEnabled := 0
- ;===================================================================================================
- ;Shortcuts
- ;===================================================================================================
- Hotkey !^s, Stop
- Hotkey !^w, SelectWindow ; Allows user to select active window
- Hotkey F8, KillScript
- Return
- KillScript:
- {
- ExitApp
- }
- ;===================================================================================================
- ; Called when Ctrl+Alt+W is pressed and captures target window information, checks its a java prog
- ;and then creates the first window.
- SelectWindow:
- {
- ;Get mouse pos on screen and grab details of program
- MouseGetPos, , , id, control
- WinGetTitle, targettitle, ahk_id %id%
- WinGetClass, targetclass, ahk_id %id%
- ;MsgBox, ahk_id %id%`nahk_class %targetclass%`n%targettitle%`nControl: %control%
- ;Check is Class of program is a Minecraft Java Class
- if InStr(targetclass, TARGET_WIN_CLASS)
- {
- ;Target window found
- ProgState = 2
- ; Add some hotkeys that are specific to this window handle
- ; Hotkey XButton1, RightClickThrough
- Hotkey, IfWinActive, ahk_id %id%
- Hotkey XButton1, HoldLeftMouseDown
- Hotkey XButton2, HoldRightMouseDown
- Hotkey F1, AutoRun
- Hotkey F4, SwitchClick
- Hotkey F5, EnableSwitchTimer
- Hotkey ~*s, AutoRunStop
- Hotkey ^b, TowerBuilder
- Hotkey !^m, MobGrind
- ; clear mouse clicks to target by sending UP to the keys
- ; ControlClick, , ahk_id %id%, ,Right, , NAU
- ; ControlClick, , ahk_id %id%, ,Left, ,NAU
- ; Indicate success
- SoundBeep 100
- sleep 500
- }
- Else
- {
- ;Class of target program not a match so give warning message
- MsgBox, You do not seam to have selected a Minecraft window. Please check before you continue.
- }
- Return
- }
- SwitchClick:
- {
- ; SoundBeep 400
- if (GetKeyState("RButton"))
- {
- Click Right Up
- Sleep 50
- Click Left Down
- }
- Else
- {
- if GetKeyState("LButton")
- {
- Click Left Up
- Sleep 50
- }
- Click Right Down
- }
- Return
- }
- TowerBuilder:
- {
- Click Down Right
- Sleep 50
- Send {Space Down}
- Return
- }
- ; F1
- AutoRun:
- {
- Send {w down}
- Return
- }
- ; ~*s
- AutoRunStop:
- {
- if GetKeyState("w")
- {
- Send {w up}
- Send {Click up}
- }
- Return
- }
- ; XButton1
- HoldLeftMouseDown:
- {
- if GetKeyState("RButton")
- {
- Click Right Up
- }
- if (!GetKeyState("LButton"))
- Click Left Down
- Return
- }
- ; XButton2
- HoldRightMouseDown:
- {
- if GetKeyState("LButton")
- Click Left Up
- if (!GetKeyState("RButton"))
- Click Right Down
- Return
- }
- ; F5
- EnableSwitchTimer:
- {
- if (switchClickEnabled > 0)
- {
- switchClickEnabled := 0
- }
- Else
- {
- switchClickEnabled := 1
- heartbeatCount := 0
- SetTimer, Heartbeat, 1000
- SoundBeep 200
- SoundBeep 250
- SoundBeep 300
- }
- Return
- }
- ;==================================================================================================
- ; CTRL+ALT+M
- MobGrind:
- {
- if (MobGrindActive)
- {
- SoundBeep, 100
- }
- Else
- {
- MobGrindActive := True
- SetTimer, MobGrindTimer, 750 ; 1000 = 1s
- SoundBeep 200
- SoundBeep 250
- SoundBeep 300
- }
- Return
- }
- Heartbeat:
- {
- heartbeatCount := heartbeatCount + 1
- maxValue := 90
- if (GetKeyState("RButton"))
- {
- maxValue := 120
- }
- if (heartbeatCount >= maxValue) and (switchClickEnabled > 0)
- {
- heartbeatCount := 0
- if (GetKeyState("RButton"))
- {
- Click Right Up
- Sleep 50
- Click Left Down
- }
- Else
- {
- if GetKeyState("LButton")
- {
- Click Left Up
- Sleep 50
- }
- Click Right Down
- }
- }
- Return
- }
- MobGrindTimer:
- {
- Random, r, 1, 100
- if (r <= 15) or (autoSwing >= 2)
- {
- autoSwing := 0
- ControlClick, , ahk_id %id%, ,Left, ,NAD
- Sleep 50
- ControlClick, , ahk_id %id%, ,Left, ,NAU
- }
- Else
- {
- autoSwing := autoSwing + 1
- }
- Return
- }
- ;==================================================================================================
- ; CTRL+ALT+S
- ; Due to mouse loss of focus, STOP will also force mouse keys UP.
- Stop:
- {
- BreakLoop := 1
- MobGrindActive := False
- SetTimer, MobGrindTimer, Off
- ControlClick, , ahk_id %id%, ,Right, , NAU
- ControlClick, , ahk_id %id%, ,Left, ,NAU
- Sleep 500
- Return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement