StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
JArt  
#1 Posted : Monday, July 4, 2022 3:45:59 AM(UTC)
JArt

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/29/2022(UTC)
Posts: 4
Sweden

Is it possible to simulate a Middle mouse button press when holding down, Right stroke button + Left mouse button?

I've checked Left Button in Modifiers and then use a virtualKey MBUTTON under Steps and inside Script. But I can't get it to work.

randomConstant  
#2 Posted : Monday, July 4, 2022 5:49:26 PM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 127

Thanks: 35 times
Was thanked: 16 time(s) in 13 post(s)
I'm not fully sure if you meant clicking both buttons and having middle button click effect instantly or clicking both buttons, keeping them pressed(hold) for some time, and then having the middle button click effect.

Here is the code for first scenario:
Code:
sp.MouseClick(sp.GetCurrentMousePoint(), MouseButtons.Middle, true, true);


Select Left Button in modifiers (Right Button if Left is your stroke), and keep Capture Modifiers option(it is to the right of modifiers) to Either.

Now the gesture should activate script when either:
  • LMB is pressed, then RMB(stroke)
  • RMB(stroke) is pressed, then LMB


Here is a screenshot of how it should look:
UserPostedImage

Hopefully it helps.

JArt  
#3 Posted : Monday, July 4, 2022 11:50:14 PM(UTC)
JArt

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/29/2022(UTC)
Posts: 4
Sweden

I still can't seem to get it to work. I want to use my left and right button to navigate in 3D programs and some other programs that uses the middle button for panning and chrome for scrolling and opening links. So I want the MMB to become instantly active as long as RMB+LMB is being held down, also while they are held down it should disable the blue stroke line. Currently your script only activates the midden button once I release RMB.

Edited by user Tuesday, July 5, 2022 12:04:39 AM(UTC)  | Reason: Not specified

Rob  
#4 Posted : Tuesday, July 5, 2022 3:28:57 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,267
United States
Location: Tampa, FL

Thanks: 27 times
Was thanked: 394 time(s) in 341 post(s)
I see what you're looking to accomplish, but it is actually a very complicated thing to do - well, to do properly in a way where it is seamless and doesn't interfere with normal left/right mouse button operations.

For example:

Unless you wait for X milliseconds to see if the other button is going to be pressed, then the button press event will occur (meaning the app will see the left or right button was pressed down).
So then what happens? Do you also allow the up event to flow through?
Will the app not properly handle the panning action because it sees another mouse button is down?
Will it cause an unintentional thing to happen in the app since it saw a left or right mouse button down event? Even though you just want to ultimately send the middle button.

If you do wait for like 400ms on left or right button down to see if the other button will be pressed (e.g. consume the down event so the apps/Windows doesn't see the button press), you're going to start noticing that delay quickly when you're just trying to do normal things.



However, if you spend a little time getting used to this finger click sequence, I think you'll find it does what you need and is just as efficient.

1) Go to Options > General and make sure Rocker Support is checked.

2) Replace the previous script with this:
Code:
// If the middle button was set as being held down
if(StrokesPlus.StoredValues.Booleans.Get("MiddleDown"))
{
    // Set a value so this action can know what to do next Left click
    // Clear this value since we're releasing the middle button
    StrokesPlus.StoredValues.Booleans.Set("MiddleDown", false);
    // Send the middle button up/release event
    StrokesPlus.Input.Mouse.Button.Release(MouseButtons.Middle);    
}
else
{
    // Set a value so this action can know what to do next Left click
    // Assign this value since we're starting the hold middle down
    StrokesPlus.StoredValues.Booleans.Set("MiddleDown", true);
    // Send the middle button down/hold event
    StrokesPlus.Input.Mouse.Button.Hold(MouseButtons.Middle);
}


3) In your action's Modifiers > Capture Modifiers dropdown, select After.

4) Go to Global Actions > Mouse Events > Release, check the Enabled box (only, do not consume) and paste this script:
Code:
// If the middle button was set as being held down
if(StrokesPlus.StoredValues.Booleans.Get("MiddleDown"))
{
    // Set a value so this action can know what to do next Left click
    // Clear this value since we're releasing the middle button
    StrokesPlus.StoredValues.Booleans.Set("MiddleDown", false);
    // Send the middle button up/release event
    StrokesPlus.Input.Mouse.Button.Release(MouseButtons.Middle);    
}




So now, to use this here's what you need to do:
  1. Press and hold the Right button down first
  2. Click the Left fully (down and up) while continuing to hold the Right button
  3. When you want to stop the panning, either click the Left button again OR just release the Right button
The above happens really fast, no need to wait - the main point is ensuring you strum your fingers so the right button is always the first button press just before the left and keep the right down.

Obviously, make sure you don't move the mouse when you hold the right button until after you click the left button (otherwise S+ will try to recognize a gesture).

Note that if you click the Left button to stop panning but continue to hold Right down, S+ will still be capturing the mouse and you can click Left again to start panning without releasing the Right button. So you can keep toggling the middle button down and up this way - but all mouse button events will be captured (consumed) while the Right button is down.

Edited by user Tuesday, July 5, 2022 3:50:49 AM(UTC)  | Reason: Not specified

JArt  
#5 Posted : Tuesday, July 5, 2022 5:57:02 PM(UTC)
JArt

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/29/2022(UTC)
Posts: 4
Sweden

Wow thank you!!

It works for the most part.
- Would it be possible to make the script work so I don't first have to release the LMB before MMB becomes active and making the MMB turn off once I release both buttons?

- If that is not possible can we make the panning to stop when I release the RMB which would be nice. Right now I have to release RMB and then click LMB again so it becomes very clicky after a while.
- Also I can mess it up at times making the panning stop but some part of the script is still going making left clicks stop working so I have to do ctrl+alt+del and then click on Task Manager to restore mouse control, I haven't figured out the exact combination yet, will let you know if I do.

Rob  
#6 Posted : Wednesday, July 6, 2022 3:01:40 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,267
United States
Location: Tampa, FL

Thanks: 27 times
Was thanked: 394 time(s) in 341 post(s)
Unfortunately, overall this is really not an ideal implementation in terms of stability/usability.

In addition, the way S+ works with modifiers and other logic, it's about as close as you can get within the scope of the core functionality of S+.
You might be able to hook into the S+ mouse hook event logic and manage all mouse button events, but you will run into a lot of complications - plus it's not very efficient since S+ is running the events in separate threads, etc. which might affect normal mouse clicking responsiveness.

You could certainly make a separate program which installed a mouse hook, like S+ does, and have it do what you want better than S+ can.
However, I still think you would run into some kind of issues or interference with normal left/right mouse button UX.

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.