Script for middle mouse button and ctrl combo only in solidworks

Get help with using AutoHotkey and its commands and hotkeys
Haasjes
Posts: 6
Joined: 16 Jan 2019, 08:26

Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 08:32

Hello,

I'm using solidworks en there is a commant that i cant chance, so i need someting that if i press me middle mouse button that it makes the combo with ctrl.
But this needs only to work when im using solidworks.

So i need the combo "middle mouse button and ctrl" only in solid works on me middle mouse button.

I use the logitech MX master mouse.

I'm really hoping that u guys can help me :)
User avatar
Hellbent
Posts: 1240
Joined: 23 Sep 2017, 13:34

Re: Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 08:46

You will need to add the name of the program where indicated

Code: Select all

#ifWinactive,     ;<---------------------------------------- put the name of the program here
^MButton::
	; add what you want to do here
	return
#IF
Haasjes
Posts: 6
Joined: 16 Jan 2019, 08:26

Re: Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 09:02

Hellbent wrote:
16 Jan 2019, 08:46
You will need to add the name of the program where indicated

Code: Select all

#ifWinactive,     ;<---------------------------------------- put the name of the program here
^MButton::
	; add what you want to do here
	return
#IF
Can i take the name of the shortcut?

And where u write "add what you want to do here" do i need to put there the commant ?
sorry im no programmer
User avatar
Hellbent
Posts: 1240
Joined: 23 Sep 2017, 13:34

Re: Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 09:19

Haasjes wrote:
16 Jan 2019, 09:02
Can i take the name of the shortcut?
This can get a bit complicated, so lets try to start simple.
The thing that you want to add as the name is whatever the window has as its title
You said that it is "solidworks", if thats what the window says, use that. if it says "solidworks v.2.3.4.5" use that.

Haasjes wrote:
16 Jan 2019, 09:02
And where u write "add what you want to do here" do i need to put there the commant ?
sorry im no programmer
Inside the hotkey you need to tell it what you want to do when you press that hotkey.
Do you want it to click? then tell it to click.
do you want it to blow up your computer? Then tell it to do that.

This is not real code, it is just a example

Code: Select all

Some_Hotkey::
	run, notepad.exe
	mousemove, 300,300
	loop 10	{
		tooltip, I'm a tooltip
		sleep, 200
	}
	sleep, 2000
	tooltip,
	return
Haasjes
Posts: 6
Joined: 16 Jan 2019, 08:26

Re: Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 09:44

Hellbent wrote:
16 Jan 2019, 09:19
Haasjes wrote:
16 Jan 2019, 09:02
Can i take the name of the shortcut?
This can get a bit complicated, so lets try to start simple.
The thing that you want to add as the name is whatever the window has as its title
You said that it is "solidworks", if thats what the window says, use that. if it says "solidworks v.2.3.4.5" use that.

Haasjes wrote:
16 Jan 2019, 09:02
And where u write "add what you want to do here" do i need to put there the commant ?
sorry im no programmer
Inside the hotkey you need to tell it what you want to do when you press that hotkey.
Do you want it to click? then tell it to click.
do you want it to blow up your computer? Then tell it to do that.

This is not real code, it is just a example

Code: Select all

Some_Hotkey::
	run, notepad.exe
	mousemove, 300,300
	loop 10	{
		tooltip, I'm a tooltip
		sleep, 200
	}
	sleep, 2000
	tooltip,
	return

Oke, so me window name is "SOLIDWORKS Professional 2019 SP1.0"

And if i pres Mbutton i want Mbutton and ctrl

is this right then:
#ifWinactive, ;<SOLIDWORKS Profecional 2019 SP1.0
MButton::
;^Mbutton::
return
#IF
User avatar
Hellbent
Posts: 1240
Joined: 23 Sep 2017, 13:34

Re: Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 09:55

Haasjes wrote:
16 Jan 2019, 09:44


Oke, so me window name is "SOLIDWORKS Professional 2019 SP1.0"

And if i pres Mbutton i want Mbutton and ctrl

is this right then:
#ifWinactive, ;<SOLIDWORKS Profecional 2019 SP1.0
MButton::
;^Mbutton::
return
#IF
Remove the " ;< " from
#ifWinactive, ;<SOLIDWORKS Profecional 2019 SP1.0

Change:

;^Mbutton::

to:

Send, {^MButton}
Haasjes
Posts: 6
Joined: 16 Jan 2019, 08:26

Re: Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 10:08

is it possible that this give only one time a ^MButton signal
I need it untill i release the MButton
Haasjes
Posts: 6
Joined: 16 Jan 2019, 08:26

Re: Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 10:32

I tested this to see if everything worked.

#ifWinactive, SOLIDWORKS
MButton::
Send, OK
return

And this is worked, but if i replace "Send, OK" to "Send, {^MButton}" this doesnt work……..

I want this funtion on me middle button
Pan:
Use the CTRL Key + hold down your middle button, and you can Pan your Part on the screen.
User avatar
Hellbent
Posts: 1240
Joined: 23 Sep 2017, 13:34

Re: Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 11:10

Haasjes wrote:
16 Jan 2019, 10:32

And this is worked, but if i replace "Send, OK" to "Send, {^MButton}" this doesnt work……..
I likely have the wrong syntax for it, I almost never send stuff, or use hotkeys for that matter.

this should work:

send, {ctrl Down} {MButton Down} {ctrl Up} {MButton Up}

I'm sure that there is a way to do it like I had it before, but without looking it up I'm clueless. (Hint: look it up in the "send" doc page)

As for looping until you release the mbutton, I can come up with a way to do it no problem, but someone is sure to be along shortly that can do it better.
User avatar
Hellbent
Posts: 1240
Joined: 23 Sep 2017, 13:34

Re: Script for middle mouse button and ctrl combo only in solidworks

16 Jan 2019, 13:18

It occurs to me that you can probably remap the MButton to ^MButton
So forget about sending anything and just add this

MButton::^MButton


https://www.youtube.com/watch?v=lpcdEbGwGnk
Haasjes
Posts: 6
Joined: 16 Jan 2019, 08:26

Re: Script for middle mouse button and ctrl combo only in solidworks

17 Jan 2019, 02:09

Hellbent wrote:
16 Jan 2019, 13:18
It occurs to me that you can probably remap the MButton to ^MButton
So forget about sending anything and just add this

MButton::^MButton


https://www.youtube.com/watch?v=lpcdEbGwGnk
This almost works, if i try it like 10 time, 9 time it works and 1 time it dont.

maybe the program needs first ctrl and 10ms later MButton

Return to “Ask For Help”

Who is online

Users browsing this forum: mikeyww, Ross, TAC109, XMCQCX and 34 guests