Auto-swing or auto-use keybind macro?

A place to talk to other users about the mod.
Post Reply
User avatar
MisterFister
Posts: 143
Joined: Wed Jun 15, 2016 1:41 pm
Location: New York City, New York

Auto-swing or auto-use keybind macro?

Post by MisterFister »

I tried searching for a fair bit of combos of the keywords in this thread's title ("macro" yielded a lot of false positives, "macroeconomics" and whatnot). Any suggestions on how I might turn my left-click into a toggle instead of a click-to-hold? For large digging projects and somesuch.

For example, I've found https://autohotkey.com/board/topic/9506 ... se-button/ and some others, but I have no clue how to "run" or "install" such a string. I have also seen mods, but none that clearly indicate compatibility with v1.5.2. :-\ (I am also flummoxed by one specifying that I should install to a .minecraft\mods folder, which I cannot seem to find...)

#NoobAlert
I consume a lot of YouTube. Some of what I consume is actually pretty good.
User avatar
Gilberreke
Posts: 4486
Joined: Thu Jul 14, 2011 3:12 pm
Location: Belgium

Re: Auto-swing or auto-use keybind macro?

Post by Gilberreke »

You don't need a Minecraft mod, just a mouse script.

http://ahkscript.org/
Come join us at Vioki's Discord! discord.gg/fhMK5kx
User avatar
Dorugami
Posts: 233
Joined: Mon Oct 14, 2013 11:18 am

Re: Auto-swing or auto-use keybind macro?

Post by Dorugami »

If you have AutoHotkey, you're welcome to use my script

Code: Select all

pause::suspend


z::
    toggle := !toggle
	if (toggle) {
	SendInput {LButton Down}
	}
	else {
	SendInput {LButton Up}
	}
return

c::
    toggle := !toggle
	if (toggle) {
	SendInput {w Down}
	}
	else {
	SendInput {w Up}
	}
return 
Just paste it on a notepad and save it as filename.ahk and can be run like an executable if you have autohotkey. The keys I bound are
Z [on toggle] - for autoswing
C [on toggle] - for autorun
and Pause/Break - for Suspend (which pauses the script) when you want to type something and don't want your Cs to turn into Ws.

If you wanna change the bindings just change the c:: or z:: to any letter on the keyboard. Since you want your left click to be a toggle, replace the z:: with LButton::
Better Than Wolves isn't a Mod. It's a Lifestyle.
Image
User avatar
Daisjun
Posts: 217
Joined: Thu May 02, 2013 1:06 am
Location: Sydney

Re: Auto-swing or auto-use keybind macro?

Post by Daisjun »

Another good macro:
Spoiler
Show
Image
User avatar
MisterFister
Posts: 143
Joined: Wed Jun 15, 2016 1:41 pm
Location: New York City, New York

Re: Auto-swing or auto-use keybind macro?

Post by MisterFister »

As old as this thread is, I submit that this is not truly a necro, because I have a follow-up question to the exact solution originally suggested here (thank you @Dorugami!)

The script I've been using to this point is as follows:

Code: Select all

z::Send % "{Click " . ( GetKeyState("LButton") ? "Up}" : "Down}" )

x::Send % "{Click " . ( GetKeyState("RButton") ? "Up r}" : "Down r}" )
The z-key (seems to be case sensitive and requires lowercase *shrug*) autoswings, and x (also seemingly lowercase-required) auto-interacts.

The reason I say that it seems to be lowercase-sensitive is because when holding LShift around ledges or lava (which I'm doing right now in a large lava level excavation project) the keybinds won't recognize unless I momentarily release the LShift. I dislike even that momentary vulnerability, but I've learned to live with that. My dawning issue now is that I have a desire to develop a keybind to hold LShift, alleviating stress on my poor misbegotten pinky finger.

1.) I note in the script I'm using that the right-click-hold x-keybind uses arguments "Up r}" and "Down r}" whereas the autoswing z-keybind is merely "Up}" and "Down}". I'm phonetically parroting and mimicking here, does anyone have any insight as to the syntactical meaning of the difference between those two argument strings?

2.) In attempting to use the following as a LShift-hold:

Code: Select all

c::Send % "{Shift" . ( GetKeyState("Shift") ? "Up}" : "Down}" )
... I note that the only way to un-toggle the LShift-hold is to tap LShift. In the z- and x-keybinds, I can toggle-off either by clicking / right-clicking (respectively) or I can re-tap the original keybind. In other words, a second tap to the z-key or the x-key toggles that respective keybind off again, without needing to perform any clicks or right-clicks on the mouse. Re-tapping the c-keybind shown here doesn't toggle-off the LShift-hold keybind. I suspect that this is because the keybind string is mapped to a lowercase-sensitive key.

Therefore, how do I reorient the strings to specify case-insensitive keybinds? I already tried duplicating the lines with a "!z" and "!x" arguments, but that didn't cause behavior that I could explain.

I've attempted to google and search through both the AHK and vMC forums, but I encountered no promising leads toward an answer.
I consume a lot of YouTube. Some of what I consume is actually pretty good.
jakerman999
Posts: 262
Joined: Sun Mar 04, 2012 7:58 pm

Re: Auto-swing or auto-use keybind macro?

Post by jakerman999 »

MisterFister wrote:...
It's not that hotkeys are case sensitive (try with caps lock to test this) it's that shift is a modifier key. Documentation can be found at https://www.autohotkey.com/docs/Hotkeys.htm

Duplicating the keybinds with the + modifier (for shift) would just give you too macoes, one with shift and one without (not what you want). Instead, add the * modifier (no duplicates).
Post Reply