Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Mouse Movement HotKeys - simple mouse gestures


  • Please log in to reply
5 replies to this topic
Zed Gecko
  • Members
  • 149 posts
  • Last active:
  • Joined: 23 Sep 2006
MMHK.ahk - Mouse Movement HotKeys & simple mouse gestures
This include provides (another) easy way to use mouse-movements and simple mouse-gestures as "HotKeys"

MMHK allows you to create hotkey-like labels for mouse movements.
You can assign actions to any combination of
Mouse-Movements (8 directions supported) & Prefix-Key (Win, Ctrl, Alt, Shift) & MouseButton (Left, Middle, Right)

supported "HotKey"-Labels
u can use the Mouse Movement labels (almost) like usual hotkeys:
e.g.:
up:
up_right:
down:
LButton_up:
LButton_up_left:
LButton_RButton_MButton_up:
#up:
!^LButton_up:
#!^+LButton_RButton_MButton_up_left:

basicly all combinations of Movement, Mouse-Button and Modifier-Key will work, but they need to be written in the right order.
The order is: # ! ^ + LButton_ RButton_ MButton_ [direction]
In addition you can use: MMHK_AllOtherMovements: . This Label will be called if there is no Mouse Movement label for the current action.

usefull VARIABLES
MMHK_TriggerLength -> the amount of Pixels the mouse must move to trigger a Mouse Movement HotKey. You can change it´s value to any thing between 3 and 1000, default is 100
MMHK_ThisHotkey -> The Label of the Mouse Movement HotKey that is currently detected, even if not defined
MMHK_PrevHotkey -> The Label of the Mouse Movement HotKey that was detected before the currently detected one.
MMHK_PrePrevHotkey -> The Label of the Mouse Movement HotKey that was detected before MMHK_PrevHotkey
MMHK_PrePrePrevHotkey -> The Label of the Mouse Movement HotKey that was detected before MMHK_PrePrevHotkey
MMHK_PrePrePrePrevHotkey -> The Label of the Mouse Movement HotKey that was detected before MMHK_PrePrePrevHotkey
MMHK_CurrentDirection -> The direction of the current mouse movement. e.g. "up" or "down_left"
MMHK_CurrentVector -> The direction of the current mouse movement in radians. (a float between -pi & +pi. 0 is left, -pi & +pi is right)

Examples:

Example 1: Basic Mouse Movement Hotkeys

DemoText =
(
-- MMHK-Demo 1 --

Hold down Shift and move the mouse in direction up_right to minimize all windows.
Hold down Shift and move the mouse in direction down_left to unminimize all windows.
)

OnExit, MMHK_OnExit
MMHK_Start()
MsgBox, %Demotext%
return
#Include MMHK.ahk

+up_right:
WinMinimizeAll
return

+down_left:
WinMinimizeAllUndo
return
Example 2: context-sensitive Mouse Movement Hotkeys
DemoText =
(
-- MMHK-Demo 2 --

In Firefox:

Hold LButton and move the mouse left, to go to prevoius page
Hold LButton and move the mouse right, to go to next page

Hold Shift and move the mouse up, to zoom in page
Hold Shift and move the mouse down, to zoom out
)

OnExit, MyExitSub
MMHK_Start()
MMHK_TriggerLength := 120
MsgBox, %Demotext%
return
#Include MMHK.ahk

+up:
if WinActive("ahk_class MozillaUIWindowClass") 
	send ^{+}
return

+down:
if WinActive("ahk_class MozillaUIWindowClass") 
	send ^-
return

LButton_right:
if WinActive("ahk_class MozillaUIWindowClass")
	send !{Right}
return

LButton_left:
if WinActive("ahk_class MozillaUIWindowClass")
	send !{Left}
return

MyExitSub:
Tooltip, Byebye
sleep, 1000
MMHK_Stop()
return
Example 3: Simple mouse gestures
DemoText =
(
-- MMHK-Demo 3 --

Move the mouse 
in V-shape \/ 
or U-shape |_| 
(beginning left) to get a MsgBox
)

OnExit, MMHK_OnExit
MMHK_Start()
MsgBox, %Demotext%
return
#Include MMHK.ahk

up_right:
if (MMHK_PrevHotkey = "down_right")
	MsgBox, You drew an "V"
return

up:
if (MMHK_PrevHotkey = "right") && (MMHK_PrePrevHotkey = "down")
	MsgBox, You have drawn an "U"
return
Example 4: Track mouse direction
DemoText =
(
-- MMHK-Demo 4 --

check out the Tooltip!
It displays the current direction of the mouse movement.
)

OnExit, MMHK_OnExit
MMHK_Start()
MMHK_TriggerLength := 3
MsgBox, %Demotext%
return
#Include MMHK.ahk

MMHK_AllOtherMovements:
CoordMode, ToolTip, Screen
ToolTip , Vector: %MMHK_CurrentVector%`nDirection: %MMHK_CurrentDirection%, 5, 5, 2
return


MMHK.ahk
(release 2)
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795


AHK Guest
  • Guests
  • Last active:
  • Joined: --
The "U" in the example doesn't work.

SoggyDog
  • Members
  • 803 posts
  • Last active: Mar 04 2013 06:27 AM
  • Joined: 02 May 2006

The "U" in the example doesn't work.


It works if you don't 'round' the U... Just down, right, up in straight lines.

Zed Gecko
  • Members
  • 149 posts
  • Last active:
  • Joined: 23 Sep 2006

The "U" in the example doesn't work.


It works if you don't 'round' the U... Just down, right, up in straight lines.

Sorry for the poor documentation.
I´ve updated the first post with more infos,examples & an updated version of MMHK.ahk

kenn
  • Members
  • 407 posts
  • Last active: Feb 10 2014 11:02 AM
  • Joined: 11 Oct 2010
Hi Zed Gecko
It's a great script, thanks for sharing. I need it to use in my headmouse ( it's a hand-free software that works by tracking head in webcam)
<!-- m -->http://www.autohotke... ... highlight=<!-- m -->
Headmouse lacks of clicking feature so I want to modify your script to click on the screen, for example; slight left to right move for right click and slight right to left for left clicking. Would you help me about it? Thanks in advance.

TodWulff
  • Members
  • 142 posts
  • Last active: Sep 15 2013 04:16 PM
  • Joined: 29 Dec 2007

code removed due to protest. 
http://www.autohotkey.com/forum/viewtopic.php?t=81795

If anyone has mmhk.ahk, I'd appreciate a copy of it - email to Tod dot Wulff at gmail dot com.

Thanks, in advance.

-t