How can I perform a simulated key, only when pressing two buttons at the same time ?

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.
Post Reply
shodan
New User
Posts: 8
Joined: Tue Feb 13, 2024 5:22 am

How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by shodan »

Please fill in this template when posting!
XMBC Version: 2.20.5
Installed or Portable version: installed
Windows Version:
Edition Windows 10 Pro
Version 22H2
OS build 19045.3930
Experience Windows Feature Experience Pack 1000.19053.1000.0
Mouse Information (brand/model):
logitech mx master 3s
Relevant Computer Information (CPU, RAM etc):
Did the problem occur after an upgrade of XMBC? (If so, from what version?):
Did the problem occur after a Windows update/upgrade? (If so, from what version?):
How long have you used XMBC?:
year long
What language and keyboard layout do you use in Windows?:
english I think en_uk but windows always hides where the keyboard layout is and I can't find it !
Clear description of the problem - try and include as much information as possible, including what button and mappings you are having problems with (if applicable).:

Hi,

So, in my previous message, I figured out how to simulated a keypress on BUTTONUP rather than BUTTONDOWN.

The reason I want to do this is that when I press a button and hold, not do that action until I release.
BUT, if instead of release I press another mouse button, I want to send a different keypress !

Here is my full situation.


I have a profile for firefox.exe

mouse button 4 -> simlated keys (pressed) -> {ACTIVATE}{CTRL}{PGUP}
mouse button 5 -> simlated keys (pressed) -> {ACTIVATE}{CTRL}{PGDN}

So how this works is

When I press mouse 4 or mouse 5, it will go to previous or next tab. Works great, I love it, can't use a computer without it !

Now I what I want to do is, press mouse 4 and hold, then press mouse 5 and it should send CTRL+W which closes the current tab, now release and it should NOT send "{ACTIVATE}{CTRL}{PGUP}"

I should be able, while holding down mouse 4, to press mouse 5 several times to send several CTRL+W.

I would also like to press mouse 5, hold it, then press mouse 4 to do the same thing (maybe ? or maybe that would be another action ?)

Now, extra crazy would be ... I have the amazing app AltSnap installed.

Could I press and hold mouse 4, nothing happens, I press and hold mouse 1 but my computer things I'm alt+mouse1 dragging. That'd be awesome !


How can I do this ?
shodan
New User
Posts: 8
Joined: Tue Feb 13, 2024 5:22 am

Re: How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by shodan »

I asked ChatGPT, here is what it said, I'm going to try it !


Hello shodan,

What you're looking to achieve – having a mouse button perform a different action when pressed in combination with another button – is a bit more complex but definitely possible with some creative configuration in XMBC. Unfortunately, XMBC doesn't directly support "chording" (pressing two buttons simultaneously for a new action) in a straightforward manner, but we can work around this with some scripting or layer toggling.

For your specific request, you'll need to use simulated keys and possibly layer switching to achieve the desired effect. Here's a step-by-step guide that might help:
  • Layer Toggling: First, you'll need to set up a new layer in XMBC where the button mappings are different. You can toggle to this layer when one button is held down.

    Button 4 Configuration:
    On your default layer, configure button 4 to switch to a new layer (let's call it "Layer 2") when pressed and held. In "Layer 2", button 4 can be configured to do nothing on press but switch back to the default layer on release. This way, releasing button 4 without pressing button 5 will result in no action.

    Button 5 Configuration on Layer 2:
    On "Layer 2", configure button 5 to send the CTRL+W command on press. Ensure it's set to switch back to the default layer upon release if button 4 is not being held down anymore.

    Handling Button 5 then Button 4:
    For pressing button 5 and then button 4, you will need to replicate the layer switch logic but in reverse. This might be a bit more complex, as it requires the software to recognize the sequence. If XMBC cannot support this natively, you might need to look into a more advanced scripting solution or third-party macro software that supports chording.

    Advanced Functionality with AltSnap:
    Integrating AltSnap actions (like alt+mouse1 dragging) might be achievable by setting up another layer specifically for AltSnap actions and using simulated key presses to mimic the Alt+Drag functionality. This would involve a similar layer toggling approach where holding mouse 4 switches to an "AltSnap layer" where mouse 1 is mapped to Alt+Drag.
Remember, the key to making this work is the layer switching functionality in XMBC, which allows you to temporarily change the button mappings based on the state of other buttons. You may need to experiment with the settings and possibly use the "During" option in the simulated keys to ensure the command is executed as long as the button is held down.

Since this setup can get quite complex, I recommend trying to set up one piece of functionality at a time and testing thoroughly before moving on to the next. Also, keep an eye on the XMBC forum and documentation for any updates or new features that might make this process easier.

Hope this helps, and happy tweaking!
User avatar
phil
Site Admin
Posts: 7601
Joined: Sun Apr 06, 2003 11:12 pm

Re: How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by phil »

ChatGPT may be using out of date information there.
You might want to look at button chording instead (even if the GhatGPT method works).

Button chording allows you to chord two buttons to perform different actions. XMBC has supported that for quite some time now (at least 5 years), despite what ChatGPT said!

For scenario 1, button choring on button 4, default (no chord action) for button 4 in the chord setup, sim keys, {ACTIVATE}{CTRL}{PGUP} as before.
Simkeys for button 5 in the chord config: {ACTIVATE}{CTRL}{PGDN}

If you want it to work both ways, setup the chord appropriately (in reverse) on button 5.

NOTE: You have several options to control how the chord works/is released, including based on movement.

For the alt+drag...
In the button 4 chord, just set button 1 to change movement to scroll.
But of course, you still have button 4 no chrod action set to your simkeys, so if you press and hold button 4, do nothing and release button 4, it will, eventully send the simkeys in no chord. I'm not sure there is any way to prevent that currently (like there is no way to say only send the default/no chord if then button is held down for more than / less than Xms).
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
shodan
New User
Posts: 8
Joined: Tue Feb 13, 2024 5:22 am

Re: How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by shodan »

I got it working yesterday.

I just did my first organic tab close with this method, it felt pretty good !!

Here's how I set it up

http ://i imgur com/CMYoCt9.png

So firefox profile

Button 5 : chording : button 4 (released) chord simulate {activate}{ctrl}w , (released) no chording {activate}{ctrl}{pgup}
Disabled unblock when mouse moves
Disable unblock after timer

If I press mouse 5 and release, does ctrl+page down
If I press mouse 5 then mouse 4, does ctrl+w, will do another on every mouse 4 until I release mouse 5 and does not ctrl+page down when I release mouse 5
And it sends that to the window under my cursor.
I can hold mouse 5 indefinitely, doesn't do anything until I press or release something else.

Perfect !

Now I'm really curious to see if I can make AltSnap work with this, it would be an amazing combo.

AltSnap is a program that lets you move or resize a window from anywhere on that window, if you left click and hold it while pressing alt.

So I'm curious to make it "press alt" if I chord mouse 5 + left click to do a alt+leftclickdrag, is that possible ?
User avatar
phil
Site Admin
Posts: 7601
Joined: Sun Apr 06, 2003 11:12 pm

Re: How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by phil »

I think so, don't see why not... you wont be able to use "sticky left button [click drag]" because it wont send the alt.
On the left button try sim keys, and method 3 (during): {alt}{LMB}
That should do it... You will have to try it and see if it works (I am at work right now so cant test it here) it should be OK but if not let me know.
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
shodan
New User
Posts: 8
Joined: Tue Feb 13, 2024 5:22 am

Re: How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by shodan »

I tried like this, but it does not trigger.

http ://i imgur com yYmojzp.png

default profile mouse 5 chord -> left button -> sim key -> {activate}{alt} with disable block original input

I checked to see if mouse 5 press prevents alt-drag but it does not. I can alt+leftclick+mouse5+drag it works the same as alt+leftclick+drag

It is bed time and too tired to think of another way. I will give this a shot again tomorrow, it would be a game changer to altsnap with the mouse, there are so so many features built in to altsnap.

Really wish I could make alt function work with the thumb button of my mx master 3s but without installing the terrible logitech software ! But mouse5 would still be awesome.
shodan
New User
Posts: 8
Joined: Tue Feb 13, 2024 5:22 am

Re: How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by shodan »

Found these threads

viewtopic.php?t=1262

viewtopic.php?t=573

viewtopic.php?t=2726

And I managed this

https://youtu.be/jKgvT217nDw

So turning a mouse button into ALT works great, works with all AltSnap mouse action sweet !

Then I tried to only press ALT with chording of left click but could not figure it out yet !

Will try again tomorrow !
shodan
New User
Posts: 8
Joined: Tue Feb 13, 2024 5:22 am

Re: How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by shodan »

I have figured it out

It is amazing !

demo

https://www.youtube.com/watch?v=4Yq4ar7KuX0

default
mouse button 5 -> button chording -> default -> no change
disable block original button
mouse button 5 -> button chording -> left button -> simulate key (during) -> {ACTIVATE}{ALT}{LMB}
mouse button 5 -> button chording -> right button -> simulate key (during) -> {ACTIVATE}{ALT}{RMB}
mouse button 5 -> button chording -> middle button -> simulate key (during) -> {ACTIVATE}{ALT}{MMB}

firefox profile
mouse button 4 -> simulate key (during) -> {ACTIVATE}{CTRL}{PGUP}
mouse button 5 -> button chording -> default -> simulate key (release) -> {ACTIVATE}{CTRL}{PGUP}
mouse button 5 -> button chording -> left button -> simulate key (during) -> {ACTIVATE}{ALT}{LMB}
mouse button 5 -> button chording -> right button -> simulate key (during) -> {ACTIVATE}{ALT}{RMB}
mouse button 5 -> button chording -> middle button -> simulate key (during) -> {ACTIVATE}{ALT}{MMB}
mouse button 5 -> button chording -> mouse 4 -> simulate key (release) -> {ACTIVATE}{CTRL}W
User avatar
phil
Site Admin
Posts: 7601
Joined: Sun Apr 06, 2003 11:12 pm

Re: How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by phil »

That sounds good - its quite a complex configuration you have there, I not sure even I fully understand it, but glad you have got it working for your needs!

PS. I will be away on vacation (in Quebec) for a while, so further replies may be quite delayed (or maybe quicker if I'm in your timezone!)
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
shodan
New User
Posts: 8
Joined: Tue Feb 13, 2024 5:22 am

Re: How can I perform a simulated key, only when pressing two buttons at the same time ?

Post by shodan »

If you find yourself near 4201 Rue de Verdun, Verdun, QC H4G 1L4 , I recommend you get a poutine and a toasted hot dog there. The poutine there is delicious. It is not a touriste poutine, just a very good, normal one. It is a very working class, ordinary place but I go there every time I traverse the city when I visit my mom in the north ! Anyway....

I was surprised this forum, there had never been a mention of AltSnap ! It goes so well with xbmc !

https://github.com/RamonUnch/AltSnap

It is a continuation of AltDrag, the original big feature is that it allows you to move a window by left-clicking anywhere on it, not just the titlebar, by pressing alt while you do it.

In the current version, you can also alt right click to resize a window from anywhere and alt middle click to get a menu of actions to perform, like kill, maximize, always on top. etc..

Also, alt-scroll can make any window transparent

So my setup is that basically to enable all the ALT features, but with the alternative of using Mouse 5

The previous thing is, to go back and forth in the firefox tab bar with mouse4 mouse5 and close tab with mouse4+mouse5 chord

I've been doing the ctrl+page up/down for a while now and it worked great. But now I just added the close tab chord.

This key combo works in other tabbed applications, like Excel, Gajim and Notepad++

However, I notice minor glitches with "Mouse 5 as ALT" function. Not sure exactly what I'm doing wrong, but sometimes, the button or maybe ALT gets stuck on. pressing many buttons eventually unsticks it. I will need more experience with this setup to sus out this problem !
Post Reply