Is it possible to implement the following Autohotkey script to fix bouncing clicks of a wornout mouse button:

40 views
Skip to first unread message

kenn

unread,
Jul 2, 2023, 9:29:33 AM7/2/23
to autokey-users
Is it possible to implement the following Autohotkey script to fix bouncing clicks of a wornout mouse button:.

LButton::    
   If (A_TimeSincePriorHotkey < 150) ;hyperclick
      Return
   Click Down
   KeyWait, LButton
   Click Up
Return

What it does:
1. Detects when the left mouse button (`LButton`) is clicked. ( It intercepts the click)
2. If the time between the current click and the previous click (`A_TimeSincePriorHotkey`) is less than 150 milliseconds, the script returns and does nothing (i.e., it ignores the click).
3. If the time between clicks is greater than or equal to 150 milliseconds, the script sends a "mouse button down" event (`Click Down`).
4. The script then waits for the left mouse button to be released (`KeyWait, LButton`).
5. Once the left mouse button is released, the script sends a "mouse button up" event (`Click Up`).

Stephen Meech

unread,
Jul 2, 2023, 2:33:50 PM7/2/23
to autoke...@googlegroups.com

You may be right, but I'm afraid you've fallen foul of the frequent confusion between the Windows AutoHotKey, and the Linux Autokey softwares. They're not interchangeable and this group is concerned with the latter.

I suggest you ask somewhere on https://www.autohotkey.com/boards/.

That having been said, others will probably suggest the solution to failing hardware is to replace it, especially when it's a cheap item!

--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/6e00c87f-d491-428d-bc5e-2d7800349493n%40googlegroups.com.
-- 
Regards,

Stephen

jos...@main.nc.us

unread,
Jul 2, 2023, 3:48:41 PM7/2/23
to autoke...@googlegroups.com
That should be *almost* doable.

The problem is that AutoKey does not consider mouse clicks as triggering
events (hotkeys...). If you can get past that, the rest is mostly routine.

So, you'd have to know when you were about to use your mouse button and
use another method to trigger your script.

Once the script is running, it can detect and time mouse clicks.

You would have to terminate the script somehow so it wouldn't run forever.

Theoretically, you could let the script run forever, which is closer to
what you need because AutoKey is multithreaded and can run other scripts
while one or more are already running. However, we don't recommend doing
that for extended peroiods of time. We have very little exerience with
running scripts concurrently, so you may run into undiscovered bugs in
AutoKey and a bad one might hang your system.

If you want to pursue this further, let us know and we can help with
actually coding it.

Joe

Little Girl

unread,
Jul 4, 2023, 9:45:14 AM7/4/23
to autoke...@googlegroups.com
Hey there,

It looks like everything would be possible except for steps 4 and 5.
AutoKey has an API call that waits for a mouse-click:

https://autokey.github.io/api/mouse.html#autokey.scripting.Mouse.wait_for_click

AutoKey doesn't, however, have an API call that waits for the mouse
button to be released. That might be doable with regular Python,
though, which you can use instead of an API call.

In addition, when a mouse starts to hyper-click, it also tends to
randomly fail to click as well. I can't imagine any kind of code that
could be written to recognize that you meant for something mechanical
to occur inside of a device and it didn't.

I have to agree with Stephen. Once the mouse starts to misbehave,
your best bet is to replace it, because it will only get worse. I
always have a stash of replacement mice ready, and the moment I use
one, I order another.

You can try your luck at mouse surgery, but it's not easy, because
the parts are so delicate:

https://www.youtube.com/watch?v=eDoXMJyimDU

I've tried it several times and failed. There's a pile of broken mice
in a cupboard here that are waiting for me to make surgery attempts
when I'm bored (like when on a call and customer service says, "Please
hold."). If I manage to fix one (very rare), it gets added to the
stash of replacement mice. Otherwise, it gets trashed.

--
Little Girl

There is no spoon.

Atilla Karaca

unread,
Jul 8, 2023, 3:57:27 PM7/8/23
to autoke...@googlegroups.com
Based on the analogy of that Autohotkey script it should be possible with python mouse tools such as pymouse, pynput, pyxhook etc.

Little Girl <littl...@gmail.com>, 4 Tem 2023 Sal, 16:45 tarihinde şunu yazdı:
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.

jos...@main.nc.us

unread,
Jul 8, 2023, 6:30:40 PM7/8/23
to autoke...@googlegroups.com
If you can figure out how to trigger your script to start with, you can
detect mouse clicks and see if any other modules such as the ones you
mention help with your task or if they confict with AutoKey.

Let us know how it goes.

If you run into any specific problems, you should post on Gitter where our
advanced users and developers hang out.

https://gitter.im/autokey/autokey

Joe
> https://groups.google.com/d/msgid/autokey-users/CADYNBN1kF16viwmpaVSsuwhYW1pVgjccDB7R2p3%2B%3DR_5sB%3DsWw%40mail.gmail.com.
>

Reply all
Reply to author
Forward
0 new messages