Mouse button hotkey to replace the default Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TOTAL
Posts: 52
Joined: 11 Nov 2016, 13:47

Mouse button hotkey to replace the default

09 May 2021, 18:26

I would have hoped the below code would fully replace the middle button functionality, but it does not - the mouse button does its click before pointer moves and a left click is triggered.

Code: Select all

$mbutton:: 
		click, 691 534 0
	Click,  down
	  
return
How to fix this?
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Mouse button hotkey to replace the default

09 May 2021, 18:33

A review of KeyHistory will show that this is incorrect. Keep in mind that a click down will hold the button.
TOTAL
Posts: 52
Joined: 11 Nov 2016, 13:47

Re: Mouse button hotkey to replace the default

10 May 2021, 16:45

That's right, thanks.

Code: Select all

~mbutton:: 		mousemove, 691, 538
Without tilde, the mouse movement does not take place at all and with, unwanted click happens.

I have tried mapping this action to a qwerty character and there are no issues.
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Mouse button hotkey to replace the default

10 May 2021, 16:54

The following should move your mouse relative to the active window.

Code: Select all

MButton::MouseMove, 691, 538
If not, it's possible that you need to run in admin mode, or there is some other software conflict, or a hardware failure, or the script is not actually running, or MButton is not being pressed. You can test it in Notepad.
TOTAL
Posts: 52
Joined: 11 Nov 2016, 13:47

Re: Mouse button hotkey to replace the default

10 May 2021, 18:10

Just tried running in admin mode but no change.

Had not occurred to me before but indeed it might be the thinkpad trackpoint software, then that is causing problems. With the generic Windows 7 mouse driver the pointer moves too slowly, though, and the middle button does not work at all, things which might be tricky to sort with ahk, mightn't they?

Or to ask this question in a positive way,
1. could lenovo's trackpoint (effectively, joystick) be made to move the mouse pointer faster than available in the mouse settings
2. could the middle button taking no action with the generic driver be hotkeyed? This would solve the problem of unwanted clicks :)
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Mouse button hotkey to replace the default  Topic is solved

10 May 2021, 19:14

Probably not so tough. The mouse sensitivity is adjustable. AHK can usually handle the MButton to make it do what you want. KeyHistory will tell you if the button is detected. You can try removing the mouse software utility, and then retest.

https://autohotkey.com/board/topic/8432-script-for-changing-mouse-pointer-speed/

I do not know how this would relate to a joystick-- possibly not at all.

You might also try searching the forum for "Lenovo", in case others have posted solutions.
TOTAL
Posts: 52
Joined: 11 Nov 2016, 13:47

Re: Mouse button hotkey to replace the default

10 May 2021, 20:29

Thanks a lot. In case anyone needs it: mouse speed is set to the max of 20 with a single line:

Code: Select all

DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, UInt, 20, UInt, 0)

Keyhistory readily shows middle button having been pressed:

04 000 s d 0.36 MButton
04 000 s u 0.16 MButton

Still, the middle button action was not in place until I added the line

Code: Select all

mbutton:: click  middle
does assign the m button the right button functionality.

What follows is for my own purposes, mbutton in a specific application and the above line for anything else.

Thank you for your help. Lots of new and useful skills.
Last edited by TOTAL on 10 May 2021, 20:51, edited 2 times in total.
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Mouse button hotkey to replace the default

10 May 2021, 20:45

Looks good-- though assigning a button to accomplish its own action does not seem especially useful! Actually, it is sometimes useful when combined with other commands.

When you create a hotkey, it executes other commands-- not itself-- unless you specifically program it that way, as you did, or unless you precede the hotkey with tilde, as you tried earlier.
TOTAL
Posts: 52
Joined: 11 Nov 2016, 13:47

Re: Mouse button hotkey to replace the default

10 May 2021, 20:50

That's what I would have thought but not in this case.

Code: Select all

mbutton:: 
{
if (WinActive("ahk_class AbletonVstPlugClass") or WinActive("ahk_class Ableton Live Window Class") or WinActive("ahk_class Ableton Live 10 Suite.exe")) 

	{
	mousemove, 691, 538
	}
	else
	{
	click middle
	}
}
return
I think this must be related to middle button working out-of-the-box only upon double clicking :D
Last edited by TOTAL on 10 May 2021, 20:53, edited 1 time in total.
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Mouse button hotkey to replace the default

10 May 2021, 20:52

What I wrote stands, but if you are running a separate mouse utility, you may get unexpected results as noted.
TOTAL
Posts: 52
Joined: 11 Nov 2016, 13:47

Re: Mouse button hotkey to replace the default

12 May 2021, 09:22

I ran it all from one script.
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Mouse button hotkey to replace the default

12 May 2021, 09:38

I just mean that if you have some Lenovo mouse utility also running, it could easily conflict with what you are trying to do.
TOTAL
Posts: 52
Joined: 11 Nov 2016, 13:47

Re: Mouse button hotkey to replace the default

12 May 2021, 14:53

Yes. I have uninstalled the software. At this stage, the middle button works as needed, with the in-Ableton functionality having been tweaked in the program, an option I had overlooked.
On second thought, pointer movement is fast enough. Acceleration could be a bit less linear but the code I found on ahk was dragging the pointer out of control at times, so I decided the setup is just good enough.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: OrangeCat, wilkster and 136 guests