Keep holding on button held

x64 Replacement/Alternative to Microsoft's IntelliMouse application.
Forum rules
Please read the forum rules before posting for the first time.
The more information you can provide, the quicker and more accurately someone can help.
NOTE: To reduce spam, new users can not post links, files or images until they have at least 4 posts.
User avatar
maxoku
Fanatic
Posts: 208
Joined: Sun Apr 02, 2017 5:21 pm

Keep holding on button held

Post by maxoku »

I have a situation when for a button I need to execute key A then short click it and key B when holding. Problem with button held is that the key B can only be tapped (pressed and released immediately). What I need is the key B would be held as long as I hold the button, releasing it only when I physically stop holding the button. Is something like that possible or be implemented?
User avatar
phil
Site Admin
Posts: 8035
Joined: Sun Apr 06, 2003 11:12 pm

Re: Keep holding on button held

Post by phil »

I think you can do this with method 3 (during) and something like...
{OD}a{waitms:50}b

That should press A only when the button is pressed, wait 50ms (the short delay) and then press and hold b until the button is released.
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 11 x64 24H2, AMD Ryzen 9950x3D, MSI x870E Tomahawk, 64GB DDR5,
nVidia RTX 5070TI
User avatar
maxoku
Fanatic
Posts: 208
Joined: Sun Apr 02, 2017 5:21 pm

Re: Keep holding on button held

Post by maxoku »

phil wrote: Sun Nov 16, 2025 12:15 pm I think you can do this with method 3 (during) and something like...
{OD}a{waitms:50}b

That should press A only when the button is pressed, wait 50ms (the short delay) and then press and hold b until the button is released.
Unfortunately it doesn't work. It still press b after short press. I already came up with something familiar, though I used 300 instead of 50. B is still pressed on short click, just delayed. I need B be pressed only when holding the button, not after a short click.
User avatar
maxoku
Fanatic
Posts: 208
Joined: Sun Apr 02, 2017 5:21 pm

Re: Keep holding on button held

Post by maxoku »

I was able to do that with autohotkey script:
~*A::
{
if !KeyWait("A", "T0.2")
{
Send("{Blind}{B down}")
KeyWait("A")
Send("{Blind}{B up}")
}
}

is it possible to use that here?
User avatar
phil
Site Admin
Posts: 8035
Joined: Sun Apr 06, 2003 11:12 pm

Re: Keep holding on button held

Post by phil »

No, Autohotkey scripting language is far more advanced than XMBC's very simple scripts... You can of course compile the AHK script and call it from XMBC {RUN:} or something like that... not sure that will be practical in this case.

Its not entirely clear what you are trying to achieve (I'm not up to speed with AHK scripting language to fully reverse engineer it from that) but after re-reading the first post, I think I missed the point in my first reply...
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 11 x64 24H2, AMD Ryzen 9950x3D, MSI x870E Tomahawk, 64GB DDR5,
nVidia RTX 5070TI
User avatar
maxoku
Fanatic
Posts: 208
Joined: Sun Apr 02, 2017 5:21 pm

Re: Keep holding on button held

Post by maxoku »

Let's say A is mouse button and B is a key of which function I'd like to add to this mouse button. Normally when I press it it triggers native function of A, but when I hold longer the A button I want it to behave also as B. Let's say it's a modifier I need to hold it to trigger actions with other buttons/keys.

The closest I got in XMBC is held button, but it presses and releases B key. I need it to be still held to trigger other buttons/keys. Every other method triggers B even on short click (only delayed) which I don't want at all.

The script ensures to send B only if I hold the A button long enough, otherwise does nothing. And works like the 3rd method from XMBC, so I can hold it while holding A button.
~ ensures that A is not blocked and works normally either way the B is executed or not. * and {Blind} are for bypassing modifiers, don't pay much attention to that.
User avatar
phil
Site Admin
Posts: 8035
Joined: Sun Apr 06, 2003 11:12 pm

Re: Keep holding on button held

Post by phil »

So if you just click (press and release) A (are we really talking about a mouse button as action A or a key - not sure it matters!?)
You want A to work as usual and press/release.

But if you hold the button for longer, do you want to keep A held AND press and hold B while you continue to hold the button, or do you want A to be a single shot (press/release)?

I still thing this might be possiblew with a (maybe more complex) simkeys sequence...
Can you try this SIMKEY... its a bit more complex but it might just work...

Here I am assuming A is {MMB} you can change that as you wish.

{OD}{PRESS}{MMB}{OD}{RELEASE}{MMB}{WAITMS:200}b{OU}{FLUSH}

Breaking it down...
When the button is pressed, it will
1. PRESS MMB
2. RELEASE MMB
3. Wait 200ms (0.2s)
4. HOLD B
But if the button is released before 200ms, it will flush the buffer and will never press/release b

In theory - but maybe Im still missing something, I must admit... the whole A and B thing (should be simple) is confusing the hell out of me (probably because Im tired and I should be asleep right now!) :?
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 11 x64 24H2, AMD Ryzen 9950x3D, MSI x870E Tomahawk, 64GB DDR5,
nVidia RTX 5070TI
User avatar
maxoku
Fanatic
Posts: 208
Joined: Sun Apr 02, 2017 5:21 pm

Re: Keep holding on button held

Post by maxoku »

That actually works perfectly. Flush is a new function I don't understand at all.

But I made it simpler:
{WAITMS:200}b{OU}{FLUSH}
and set it to not block the original button.

The mouse button is actually 4th button. Maybe I should go with that than using A and B. I wanted to make it simple but it got more confusing by that, sorry.
Anyway thanks very much.
User avatar
phil
Site Admin
Posts: 8035
Joined: Sun Apr 06, 2003 11:12 pm

Re: Keep holding on button held

Post by phil »

Aha glad I hadn't complete lost my mind :)
{FLUSH} instructs XMBC to get rid of anything it has queued up to send (flush the buffer if you like). So as soon as the button is released {OU}, the buffer is flushed, the WAITMS:200 is cancelled and it never gets to the 'B'
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 11 x64 24H2, AMD Ryzen 9950x3D, MSI x870E Tomahawk, 64GB DDR5,
nVidia RTX 5070TI