Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Rocker gestures


  • Please log in to reply
17 replies to this topic
dantown
  • Guests
  • Last active:
  • Joined: --
Hallo,

holding the left mouse button and clicking the right one and vice versa is called a rocker gesture. It's available in Maxthon and other browsers. I'd like to implement this in Windows Explorer. Unfortunately,
RButton & LButton::send !{left}
LButton & RButton::send !{right}
does work but hinders any single left/right click system-wide. What have I done wrong?

Daniel

AiKscroll
  • Members
  • 179 posts
  • Last active: Feb 25 2007 03:10 AM
  • Joined: 06 Jun 2005
A IfWinActive, Windows Explorer command may help... iono would it?
_AiK

dantown
  • Guests
  • Last active:
  • Joined: --
True, I'll have to check if Windows Explorer has focus. Nevertheless, even in Explorer I can't select anything with a left or right click.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Try adding a tilde in front of each hotkey. That allows the first button to pass through to the system normally:

~RButton & LButton::send !{left}
~LButton & RButton::send !{right}

The second one might still fail to work because most apps refuse to accept keystrokes while the left mouse button is down (or perhaps this is a built-in behavior for the entire system).

If that is the case, try:
~LButton & RButton::send {LButton Up}!{right}

If that doesn't work, try accomplishing the second hotkey's action via MouseClick, ControlClick, or WinMenuSelectItem.

dantown
  • Guests
  • Last active:
  • Joined: --
Thanks Chris, your last tip was amazing and works with both mouse click combinations. One problem persists:
~RButton & LButton::send {RButton Up}!{left}
opens the context menu. Any way to avoid this?

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
The following seems to work:
~RButton & LButton::
Send !{left}
KeyWait, RButton  ; Wait for physical release because that is often what shows the menu.
WinWait, ahk_class #32768, , 1  ; Menu's "window" (never active, but it does exist).
if not ErrorLevel  ; Menu found.
	Send {Escape}
return
Maybe there is some other solution involving sending the WM_CANCELMODE to dismiss the menu, but that is a long shot and would take some research.

dantown
  • Guests
  • Last active:
  • Joined: --
Thank you! That works except that I have to move "Send !{left}" right before "return".

It's a shame that the context menu is popping up though. The problem is that the right click is passed on to the system. Another problem is that your code waits until the right mouse button is released which is not the case with the other rocker gesture.

I'm thinking of a routine that takes care of the right click alltogether.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

The problem is that the right click is passed on to the system.

I think this could be avoided by removing the tilde prefix from RButton and adding the following additional hotkey:

RButton::MouseClick, right,,,,, U ; Use MouseClick vs. Send to avoid disruption of Ctrl/Alt/Shift keys.

However, the above would prevent right-click-drag from working and might have other side effects.

Another problem is that your code waits until the right mouse button is released which is not the case with the other rocker gesture.

Some apps, such as Explorer, display the context menu only upon release of the right mouse button. That's why the KeyWait is in there.

dantown
  • Guests
  • Last active:
  • Joined: --
For now I got the ultimate answer, which really rocks :D

In AutoHotkey, define
~LButton & RButton::send {LButton Up}!{right}

In StrokeIt (http://www.tcbmi.com/strokeit/), add under [Global actions] the command "Back [Rocker right-left]" with the gesture "LBUTTON_DOWN" and hotkey "ALT + LEFT".

This gives you perfect forward/backward rocking featuring right-click dragging without the context menu bug.

Chris, you're doing a wonderful job, but I ask myself why it takes StrokeIt for the right-left click rocker gesture to work perfectly.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

...but I ask myself why it takes StrokeIt for the right-left click rocker gesture to work perfectly.

Since mouse buttons already have so many functions, getting them to do more -- especially in combination with other mouse buttons -- is often tricky business. I'm glad you found a solution.

stevo54321
  • Guests
  • Last active:
  • Joined: --
Instead of using the right button i just opted to use the scroll wheel. it's a little more annoying to press, but you don't get the context menu at all... a trade off i guess.

~LButton & MButton::send {LButton Up}!{right}
~MButton & LButton::send {MButton Up}!{left}

helpme
  • Members
  • 41 posts
  • Last active: Nov 24 2019 02:21 PM
  • Joined: 22 Apr 2007
I think I have found one way to get rid of the context windows.

Try the following;
~RButton & LButton::
{
	;send {RButton Up}!{left}
	SendInput !{Right} ;Alt-right (browse forward)
	Sleep 200 ;delay 200ms		
	SendInput {Escape}
	return
}

The code will send the {Escape} key to remove the context window after waiting for 200ms.

I am feeling rather guilty as I have only been asking questions and benefiting from the Gurus here like a parasite without making useful contributions to this forum.

Hope this post will be of use to fellow AutoHotkey users.

chrisb24
  • Guests
  • Last active:
  • Joined: --
Heres the code to make forward and back not interfering with Firefox mouse gesture for same buttons stroke

~RButton & ~LButton::

IfWinActive, ahk_class  CabinetWClass
{

   ;send {RButton Up}!{left}
   SendInput !{Left} ;Alt-right (browse forward)
   Sleep 200 ;delay 200ms      
   SendInput {Escape}
   return
}

return

~LButton & ~RButton::
IfWinActive, ahk_class  CabinetWClass
{

   ;send {RButton Up}!{left}
   SendInput !{Right} ;Alt-right (browse forward)
   Sleep 200 ;delay 200ms      
   SendInput {Escape}
   return
}
Return


barreem
  • Members
  • 9 posts
  • Last active: Nov 08 2011 09:53 AM
  • Joined: 29 Mar 2010
Here is my solution for using both rocker gestures LButton-RButton and RBurron-LButton to close the current tab:

; ROCKER GESTURES FOR FIREFOX
~LButton & RButton::
SetTitleMatchMode, 2
IfWinActive, Mozilla Firefox
{
	Send ^{F4}
}
return

~RButton & LButton::
SetTitleMatchMode, 2
IfWinActive, Mozilla Firefox
{
   Send ^{F4}
   LButtonReleased := 0
   Loop 1000
   {
		GetKeyState, state, LButton, P
		if state = U
			LButtonReleased := 1
		else if state = D
		{
			if LButtonReleased = 1
			{
				Send ^{F4}
				LButtonReleased := 0
			}
		}
		GetKeyState, state, RButton, P
		if state = U
		{
			Send {ESC}
			return
		}
	Sleep, 10
	}
}
return


barreem
  • Members
  • 9 posts
  • Last active: Nov 08 2011 09:53 AM
  • Joined: 29 Mar 2010
slight change to the script

; ROCKER GESTURES FOR FIREFOX
~LButton & RButton::
SetTitleMatchMode, 2
IfWinActive, Mozilla Firefox
{
	Send ^{F4}
}
return

~RButton & LButton::
SetTitleMatchMode, 2
IfWinActive, Mozilla Firefox
{
   Send ^{F4}
   LButtonReleased := 0
   Loop 400
   {
		GetKeyState, state, LButton, P
		if state = U
			LButtonReleased := 1
		else if state = D
		{
			if LButtonReleased = 1
			{
				Send ^{F4}
				LButtonReleased := 0
			}
		}
		GetKeyState, state, RButton, P
		if state = U
		{
			Sleep, 25
			Send {ESC}
			return
		}
	Sleep, 25
	}
}
return