Looking for a Right Mouse to Middle Mouse Hold Script Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
HenryCAD
Posts: 5
Joined: 20 Sep 2019, 01:36

Looking for a Right Mouse to Middle Mouse Hold Script

20 Sep 2019, 01:49

Hey,

I'm new here and I have no idea about scripting. I'm a CAD user, using SolidWorks. I don't like to hold middle mouse (wheel) to orbit inside the software. So I am looking for a script, that do the following:

When I just press and release the right mouse button -> make a normal right mouse button press and release.

But when I hold the right mouse button and also start to move my mouse courser -> simulate that I hold the mittle button.

I have googled for scripts like this but I did not found anything like it. I found similar scripts, so I think it could be possible. But with no idea about coding I was not able to create my own script. I hope someone can help me out. Thank you all in advance.

Greetings,

Henry
ilhom
Posts: 52
Joined: 19 Aug 2019, 17:58

Re: Looking for a Right Mouse to Middle Mouse Hold Script

20 Sep 2019, 02:04

The middle mouse button will trigger if you hold down the right mouse button for 200ms. You can increase this time by changing T0.2 to a higher value.

Code: Select all

$RButton::
keywait, RButton, T0.2
    if (Errorlevel = 1)
	{
		Click, down, Middle
		KeyWait, RButton
		Click, up, Middle
	}
	else
		Click, Right
Last edited by ilhom on 20 Sep 2019, 02:11, edited 2 times in total.
HenryCAD
Posts: 5
Joined: 20 Sep 2019, 01:36

Re: Looking for a Right Mouse to Middle Mouse Hold Script

20 Sep 2019, 02:07

Wow... that was fast! And it works like a charm. Thank you very much!

Edit: I can not use the CTRL modifier with this script. So, If I press CTRL + hold right button, I don't get the CTRL + middle mouse hold. Is there a way to fix it? I can live without it, but it would be the cherry on top. :D

Edit 2: I do not know if it makes sense, but I've tested some things an this seem to work

Code: Select all

^RButton::
SendInput {RButton Down}

$RButton::
keywait, RButton, T0.2
    if (Errorlevel = 1)
	{
		Click, down, Middle
		KeyWait, RButton
		Click, up, Middle
	}
	else
		Click, Right
Edit 3: It does not work. :(

Edit 4: I've tried this but I get an unwanted right click when I release the RButton Hold

Code: Select all

$RButton::
keywait, RButton, T0.2
    if (Errorlevel = 1)
	{
		Click, down, Middle
		KeyWait, RButton
		Click, up, Middle
	}
	else
		Click, Right


$^RButton::
keywait, RButton, T0.2
    if (Errorlevel = 1)
	{
		Click, down, Middle
		Click, down, CTRL
		KeyWait, RButton
		Click, up, Middle
		Click, up, CTRL
	}
	else
		Click, Right
HenryCAD
Posts: 5
Joined: 20 Sep 2019, 01:36

Re: Looking for a Right Mouse to Middle Mouse Hold Script

23 Sep 2019, 01:42

Maybe someone else has a solution to my problem? Otherwise, I leave it here and I'm glad that it works almost as well as I wanted. :)
User avatar
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: Looking for a Right Mouse to Middle Mouse Hold Script

23 Sep 2019, 03:35

Try this

Code: Select all

;Change acad.exe with your software name
#IfWinActive ahk_exe acad.exe



$RButton::
keywait, RButton, T0.150
if Errorlevel
{
	Send, {MButton Down}
	KeyWait, RButton, L
}
else
	Send, {RButton}
return


$RButton Up::
Send, {MButton Up}
return
:wave: There is always more than one way to solve a problem. ;)
HenryCAD
Posts: 5
Joined: 20 Sep 2019, 01:36

Re: Looking for a Right Mouse to Middle Mouse Hold Script

23 Sep 2019, 05:21

Thanks for your help. Unfortunately your script works exactly like ilhom's (missing the CTRL modofier function). Just to make sure that there are no misunderstandings, here are the things that I asked for:

When I single click RButton -> normal RButton click (works fine with both scripts)
When I hold RButton -> simulate MButton hold (works fine with both scripts)
When I press CTRL + hold RButton -> send CTRL + hold MButton (does not work with both scripts)
User avatar
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: Looking for a Right Mouse to Middle Mouse Hold Script

23 Sep 2019, 05:32

try this

Code: Select all

;Change acad.exe with your software name
#IfWinActive ahk_exe acad.exe



*$RButton::
keywait, RButton, T0.150
if Errorlevel
{
	Send, {MButton Down}
	KeyWait, RButton, L
}
else
	Send, {RButton}
return


$RButton Up::
Send, {MButton Up}
return
:wave: There is always more than one way to solve a problem. ;)
HenryCAD
Posts: 5
Joined: 20 Sep 2019, 01:36

Re: Looking for a Right Mouse to Middle Mouse Hold Script

23 Sep 2019, 06:36

Does not work either.

With you first script I've got a normal right click wehen using the CTRL modifier. With the new script I've got the hold Mbutton, but CTRL does not got recognized.
ilhom
Posts: 52
Joined: 19 Aug 2019, 17:58

Re: Looking for a Right Mouse to Middle Mouse Hold Script  Topic is solved

23 Sep 2019, 16:30

HenryCAD wrote:
23 Sep 2019, 06:36
Does not work either.

With you first script I've got a normal right click wehen using the CTRL modifier. With the new script I've got the hold Mbutton, but CTRL does not got recognized.
Adding the wildcard to my original should do what you're asking. This will also work with alt, shift, etc.

Code: Select all

$*RButton::
keywait, RButton, T0.2
    if (Errorlevel = 1)
	{
		Click, down, Middle
		KeyWait, RButton
		Click, up, Middle
	}
	else
		Click, Right

Return to “Ask For Help”

Who is online

Users browsing this forum: barkie, devil5967, devnullsp, George4All, Google [Bot], Rohwedder, scriptor2016, Smile_, ystin and 156 guests