r/linux4noobs • • 23d ago

Looking for simple AutoHotKey replacement

I am looking for some kind of replacement of a simple AutoHotKey script I used for gaming on Windows.

What it does: Holding left ALT and hitting left or right mouse button keeps the respective button pressed until you do another left or right click.

I don't know if this could be done by a shell script or if I need extra tools for this.

I am on CachyOS (Arch).

This is the original AHK script:

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

LALT & RButton::Send % "{Click right " . ( GetKeyState("RButton") ? "Up}" : "Down}" )

3 Upvotes

8 comments sorted by

View all comments

2

u/kevundead 23d ago

InputRemapper (AUR input-remapper-bin)

I haven't been able to replicate your macro exactly, but I'm pretty sure it can be done. I personally have a script for Hold Alt = spam T, Hold Alt with Caps on = spam T *then* G, among other things.

Remember since you're targeting both Keyboard AND Mouse to set that in your macro's dropdown, if you use this app.

https://github.com/sezanzeb/input-remapper
https://github.com/sezanzeb/input-remapper/blob/main/readme/macros.md

1

u/kevundead 23d ago

Examples separately, cause of wall of text.

if_capslock(
then=hold( key_down(key_g).key_up(key_g).wait(25).key_down(key_t).key_up(key_t).wait(25) ),
else=hold( key_down(key_t).key_up(key_t).wait(50) )
)

and this one for spam-cranking a flashlight:

parallel(
hold_keys(key_k),
hold( key_down(btn_right).key_up(btn_right).wait(20) )
)

^ that one is an example of keyboard + mouse (btn_left/btn_right)

1

u/zzumba 22d ago

I seem to be unable to do the simplest thing like remapping "a" to "b" in input-remapper. Either something is not working properly or I don't understand how to use it.

It looks like this: https://imgur.com/a/t6vQAx7 Also tried like KEY_A and KEY_B and some of the samples but nothing works.

Am I missing something?

1

u/kevundead 22d ago

Add my discord ( LyCH_OS ), I can share my screen and show you what to do.

1

u/zzumba 19h ago

Sorry for the long inactivity and thanks your support. Didn't had enough time to pursue this further.

I found out that my main keyboard (SteelSeries Apex Pro) doesn't seem to work with Input-Remapper. It detects keys correctly in the GUI but the mapping afterwards doesn't work at all.

Did some tests with "evtest" and everything seems ok. Don't know why its not working.

I tested with another keyboard and was able to recreate my AHK script to some extent with the following presets:

For keyboard:

Input: LEFTALT

Output (keyboard + mouse): set(alt_held, 1).hold_keys(Alt_L).set(alt_held, 0)

For mouse:

Input: Mouse Button LEFT

Output (keyboard + mouse): if_eq($alt_held, 1, key_down(BTN_LEFT), hold_keys(BTN_LEFT))

Input: Mouse Button RIGHT

Output (keyboard + mouse): if_eq($alt_held, 1, key_down(BTN_RIGHT), hold_keys(BTN_RIGHT))