Using mouse buttons to Open, Close and Cycle tabs in Chrome Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
iamMG
Posts: 28
Joined: 12 Nov 2017, 11:32

Using mouse buttons to Open, Close and Cycle tabs in Chrome

04 Feb 2019, 04:54

I made the following script to 'close tab', 'reopen closed tab' and 'cycle through tabs' in Chrome using only left, right mouse buttons and scroll wheel.
The close tab script works fine. But, after the other two scripts are executed, right click menu pops up. I still want to be able to use the right click menu otherwise, of course, but not while executing this script. Any help with this is appreciated.

Code: Select all

	#IfWinActive ahk_class Chrome_WidgetWin_1 		; Chrome
	; CLOSE TAB
	~LButton & RButton::Send, ^w

	; REOPEN CLOSED TAB
	~RButton & ~LButton::Send, ^+t

	; CYCLE THROUGH TABS
	;RButton::click right
	~RButton & WheelUp::Send ^{PgUp}
	~RButton & WheelDown::Send ^{PgDn}
AviationGuy
Posts: 188
Joined: 17 Jan 2019, 10:13

Re: Using mouse buttons to Open, Close and Cycle tabs in Chrome

12 Feb 2019, 03:36

Hi,

You can write the function as follows.

Code: Select all

~RButton & WheelUp::
Send ^{PgUp}
RButton::return
So when the right mousebutton and the scrollwheel up is used, shift+ctrl+t is being pressed, AND because of pressing the right mousebutton, the script will end when the right mousebutton will be released.

EDIT: Your right mousebutton won't work untill you end the script!
AviationGuy
Posts: 188
Joined: 17 Jan 2019, 10:13

Re: Using mouse buttons to Open, Close and Cycle tabs in Chrome

12 Feb 2019, 05:24

Found a solution for not disabling your right mousebutton for ever with the help of this post https://www.reddit.com/r/AutoHotkey/comments/4cr02b/disable_right_click_temporary/

Code: Select all

RButton & WheelUp::
	Send ^{PgUp}
return
RButton Up::
    Click Right
Return
iamMG
Posts: 28
Joined: 12 Nov 2017, 11:32

Re: Using mouse buttons to Open, Close and Cycle tabs in Chrome

13 Feb 2019, 01:52

Thanks for the reply. But this doesn't seem to work. And it is behaving the same way earlier script was behaving. Tab changes but when I lift the Right mouse button, context menu pops up.
AviationGuy
Posts: 188
Joined: 17 Jan 2019, 10:13

Re: Using mouse buttons to Open, Close and Cycle tabs in Chrome  Topic is solved

13 Feb 2019, 03:18

Strange, are you sure you have the right script because it works for me.

Code: Select all

RButton & WheelUp:: Send ^{PgUp}
RButton & WheelDown:: Send ^{PgDn}	
RButton Up:: Click Right
This is everything you need. Make sure to leave the ~ out, if you leave it in it won't work.
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: Using mouse buttons to Open, Close and Cycle tabs in Chrome

13 Feb 2019, 03:54

Try also

Code: Select all

~RButton & WheelUp:: 
	NoContextMenu := true
	Send ^{PgUp}
return

~RButton & WheelDown::
	NoContextMenu := true
	Send ^{PgDn}
return

#If (NoContextMenu)

	~*RButton Up:: 
		Send {Esc}
		NoContextMenu := false
	return

#If
iamMG
Posts: 28
Joined: 12 Nov 2017, 11:32

Re: Using mouse buttons to Open, Close and Cycle tabs in Chrome

19 Feb 2019, 00:40

Thanks @AviationGuy for that. I was using the script specifically for Chrome but it wasn't working.

Code: Select all

#IfWinActive ahk_class Chrome_WidgetWin_1 
; CHANGE TABS
RButton & WheelUp:: Send ^{PgUp}
RButton & WheelDown:: Send ^{PgDn}	
RButton Up:: Click Right
I removed the if condition and used globally, now it works flawlessly! :D

Also, thank you GEV for your suggestion. However it doesn't work. Context menu is showing up. :cry:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 274 guests