Jump to content

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

Lex' Mouse Gestures


  • Please log in to reply
131 replies to this topic
Ming
  • Members
  • 4 posts
  • Last active: Feb 10 2013 12:30 AM
  • Joined: 28 May 2009

Hey Lexikos, as you know windows 8 finally integrated some usable multi finger touch interaction via touchpad and touchscreen. Could AHK detect 3 finger touch gestures? It would be great to add 3 finger touch as gesture trigger (like Rbutton on your scrip), both on the touchpad and on the screen

 

It is nice to scroll and zoom pages with 2 fingers, but unless it is possible to play with multi finger gestures the same way it is possible to play with keystrokes in ahk, i am afraid that the 90% of the potential of "touch" would be unexploited.

 



Roel
  • Members
  • 1 posts
  • Last active: Oct 26 2013 01:07 PM
  • Joined: 26 Oct 2013

Thanks a lot for sharing this great script!

 

I found it a bit counter-intuitive that actions (e.g. closing a tab) aren't sent to the window where I make the gesture, if the window isn't active. It can be made active by making a small change to gestres.ahk, from line 370 onward. Find the ID of the window, and make it active when a gesture is drawn:

        else ; get current mouse position
            MouseGetPos, x, y, WinUMID ; find window where gesture is drawn

        offsetX := x - lastX
        offsetY := y - lastY

        ; Check if mouse has moved.
        if (offsetX!=0 || offsetY!=0)
        {
              WinActivate, ahk_id %WinUMID% ; make window where gesture is drawn active


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Thanks.

I prefer it the way it is, because I don't pay attention to where the mouse cursor is.

think
  • Members
  • 119 posts
  • Last active: Nov 01 2015 11:37 PM
  • Joined: 23 May 2013

Thanks for this great script!

 

I have a small issue and maybe someone could help: I tried to combine gestures together with my code into one single script. The script contains a contextmenu which is called by pressing a right mouse button on a ListView, like this:

GuiContextMenu: 
if A_GuiControl = MyList
	Menu, CMenu, Show, %A_GuiX%,%A_GuiY% 
Return 

However, as right press is captured by gestures, the context menu does not work as expected - nothing happens until the mouse is moved.

 

Is there a simple solution to keep both in the same script? Thanks.



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

This script uses the default GUI (GUI 1) to display gesture trails (when enabled).  Your added code looks like it also uses GUI 1.  Make sure trails are disabled (m_PenWidth is blank or 0), or change either one to use a different GUI number/name.

 

However, as right press is captured by gestures, the context menu does not work as expected - nothing happens until the mouse is moved.

 

I'm not really sure what you mean.  When I test it with trails disabled (and a basic GUI with a ListView), the context menu works as expected most of the time.  Sometimes a kind of deadlock occurs, where the script sends its own ListView a right-click-down and the ListView enters selection mode.  While in selection mode, it won't return control to the script, and since the script doesn't have control, it can't send the right-click-up which would end selection mode.

 

The easiest solution is to simply not combine the scripts.  You can have one script start the other using Run, and stop it on exit using OnExit and the following:

DetectHiddenWindows On
SetTitleMatchMode 2
WinClose script.ahk ahk_class AutoHotkey
Replace script.ahk with the filename.

think
  • Members
  • 119 posts
  • Last active: Nov 01 2015 11:37 PM
  • Joined: 23 May 2013

Thank you Lexikos, you are right, the main problem was in gui number (and some other minor issues).

 

I enjoy the script very much with 4 zone recognition, however with 8 zones it is too difficult and not reliable for me with default settings. Thanks again for a great work!



think
  • Members
  • 119 posts
  • Last active: Nov 01 2015 11:37 PM
  • Joined: 23 May 2013

Hm, I did some tests and got another issue. If in parallel I run another script with a hotstring than context menu doesn't work as expected.

 

I did the following: I added a following code at the beginning on Lex's Gestures script:

gosub Gest

Gui, 2:Default
Gui, 2:add, listview, vMyList, Surname|Name
LV_Add("", "One", "First")
LV_Add("", "Two", "Second")
Gui, 2:show
Menu, CMenu, Add, Edit, MyEdit
Gui, Default
return 

2GuiContextMenu: 
if A_GuiControl = MyList
	Menu, CMenu, Show, %A_GuiX%,%A_GuiY% 
Return 

MyEdit:
msgbox EDIT
return

Gest:
/*
  Lex' Mouse Gestures
  by Lexikos (Steve Gray)
*/
... Lex's Gestures script follows...

and it works well, no problems with a right click to get context menu.

 

Then I run the following script (another ahk file):

::kr::kind regards

...and the context menu behavior in the first script changes - right mouse click doesn't show a menu until cursor is also moved. This then happens after any left mouse click...

 

I would still want to keep gestures and listview in one script. Any ideas what might be wrong? Thanks.



think
  • Members
  • 119 posts
  • Last active: Nov 01 2015 11:37 PM
  • Joined: 23 May 2013

Any ideas about the behavior mentioned above?



Baal
  • Members
  • 81 posts
  • Last active: Apr 15 2016 04:38 PM
  • Joined: 04 Jun 2014
Does anyone know how can i make gestures work with "#IfWinActive" commands in "Gestures_User" file? They seem to interfere with each other. Example: If i have "#IfWinActive, ahk_class MozillaWindowClass" command mapping XButton1, gestures stop working on Firefox.

Lexicos
  • Members
  • 20 posts
  • Last active:
  • Joined: 05 Jan 2009

Are you sure?  I would expect gestures to stop working everywhere else.

 

Use #IfWinActive with no parameters at any point after your XButton1 hotkey if you want the gesture hotkey to be global.



Baal
  • Members
  • 81 posts
  • Last active: Apr 15 2016 04:38 PM
  • Joined: 04 Jun 2014
Thanks Lexicos!! One more question it seems gestures don't work if i try to set them using "#IfWinActive". Example: #IfWinActive, ahk class moziilla Gesture_D:: Winclose............. Is there anyway around?

Baal
  • Members
  • 81 posts
  • Last active: Apr 15 2016 04:38 PM
  • Joined: 04 Jun 2014
Anyone can tell me how to exclude window from restoring using default gesture script?