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
gechu
  • Guests
  • Last active:
  • Joined: --
Dammit! Now I have to understand these scripts to be able to change them! :D

/ Script kiddie Erik

Jag02
  • Members
  • 44 posts
  • Last active: Feb 15 2010 08:46 AM
  • Joined: 16 Apr 2008
Is there a way that a gesture can be added that refreshs the page?

Also like in Avant Browser, can diagonal gestures be added?

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

Is there a way that a gesture can be added that refreshs the page?

Use something like this in Gestures.ini:
Gesture_R_D_L = {F5}
(Replace R_D_L with whatever.)

Also like in Avant Browser, can diagonal gestures be added?

Add the following to Gestures.ini (there may already be ;m_ZoneCount = 4):
m_ZoneCount = 8
m_InitialZoneCount = 8
I find it is more effective with only 4 zones, since the script does not try to match to an existing gesture.

Jag02
  • Members
  • 44 posts
  • Last active: Feb 15 2010 08:46 AM
  • Joined: 16 Apr 2008
This command in the Gestures.ini file does not work;

Gesture_L_U = !{Up}

Please help.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
For what purpose does it not work? Are you using the default settings? If you have diagonals enabled, you have to be careful to draw "left, up" rather than "left, up-left, up."

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006
If we would call the current mouse gestures as "global gestures" would it be possible to define also "local gestures" which would layer on top of the global gestures (and disabling their functionality temporarily) dependent on active windows?

e.g. if I would have application A active, it would enable its own set of 8 mouse gestures, then when changing to application B, it would activate its other set of 8 mouse gestures? It should be possible with reloading of Gestures_Default.ahk maybe? Anyone using mouse gestures this way?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Look for the following line:
gesture := c_GesturePrefix ? c_GesturePrefix : "Gesture"
You may change the prefix based on whatever criteria, i.e. the active window, by adding to this section of code.

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006
I have defined my gestures in "Gestures Default.ahk" which starts like

; **** DEFINITIONS ****

; prefix for gesture variables/labels
c_GesturePrefix = Gesture
... (global set of gestures)
So can I add those various "local gestures" into the same "Gestures Default.ahk" below by adding another such section with new definitions, like
; **** DEFINITIONS ****

; prefix for gesture variables/labels
c_GesturePrefix = ApplicationA
... (set of gestures for ApplicationA)
after that again
; **** DEFINITIONS ****

; prefix for gesture variables/labels
c_GesturePrefix = ApplicationB
... (set of gestures for ApplicationB)
?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
No. Only the last definition will be used. Find the line as in my previous post, and assign gesture a different value based on which window is active.

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

No. Only the last definition will be used. Find the line as in my previous post, and assign gesture a different value based on which window is active.

Thanks Lexikos for your hints, I think I got it now... Before I was thinking it would be supported by your Gestures system to define multiple gesture definitions based on prefixes within one single gesture system (Gestures.ahk + Gestures Default.ahk + Gestures.ini) but now I switched my thinking that for multiple gestures definitions based on prefixed I should simply use multiple gesture systems. At least that seems to be the most simplest way? Did I understand everything correctly? If yes, I would want to know how many "gesture systems" others are using simultaniously, just one or also more?

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

Before I was thinking it would be supported by your Gestures system to define multiple gesture definitions based on prefixes within one single gesture system (Gestures.ahk + Gestures Default.ahk + Gestures.ini)

It is. :x
[*:b1blmmcv]Define Prefix1_L, Prefix2_L, Prefix3_L, etc.
[*:b1blmmcv]Find the line mentioned in my previous posts, where the variable named 'gesture' is assigned.
[*:b1blmmcv]Assign 'gesture' whatever prefix value you wish to be active. If you wanted different gestures for the days of the week, you could use:
1_L = Left on Sunday.
2_L = Left on Monday.
3_L = Left on Tuesday.
gesture := A_WDay
The mentioned line may exist in multiple places.

By default, c_GesturePrefix is used. Simply changing its value would change what all of the gestures do. This method is not ideal for window-sensitive gestures, however, since you would need to detect when the active window changes or the mouse changes windows and set c_GesturePrefix accordingly.

If yes, I would want to know how many "gesture systems" others are using simultaniously, just one or also more?

I am using one script, with only the generic "Gesture" prefix. You may notice that several gestures implemented as subroutines in Gestures Default.ahk are already sensitive to which window is active.

pajenn
  • Members
  • 391 posts
  • Last active: Feb 06 2015 07:57 AM
  • Joined: 07 Feb 2009
I've decided to add mouse gestures to my arsenal of shortcuts, but I'm having a few issues with this script:

1. I need to press right-click longer on tray icons (maybe other things too) to get the menu (not a big deal, but if there's an easy fix...)

2. While I agree that trails may get old quickly, I'd like to see them for now. I tried running both Gestures and StrokeIt simultaneously. The latter with all commands disabled just to get the trails from it, but it didn't work. Anyway to enable StrokeIt to run simultaneously? (StrokeIt is another mouse gesture program that draws the symbol on screen when right mouse button is down.)

3. With what can I replace {Launch_App2} in the ini-file to have it launch Firefox instead of the Calculator?

Thanks in advance.

Hardware: fast laptop with SSD
Software: Win 7 Home Premium 64-bit, android for phone and tablet


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

1. I need to press right-click longer on tray icons to get the menu

I'm not sure what to suggest. Does it happen only with specific applications?

Anyway to enable StrokeIt to run simultaneously?

If StrokeIt shows trails only while you hold the button, it probably won't work because this script blocks the physical button-press from other applications. If a timeout is reached or the button is physically released without moving the mouse, the script may then simulate a button-press. Without this behaviour, you could not use gestures over any window on which the gesture button usually has an effect.

3. With what can I replace {Launch_App2} in the ini-file to have it launch Firefox instead of the Calculator?

Gestures.ini can only be used for mapping gestures to keystrokes/text. Try removing this line from Gestures.ini:
Gesture_D = {Launch_App2}
...and adding this subroutine to Gestures Default.ahk:
Gesture_D:
    ifWinExist, Mozilla Firefox ahk_class MozillaUIWindowClass
        WinActivate
    else  ; Replace with a URL of your choice, or the path to Firefox:
        Run http://www.google.com
return
Any gesture which is not defined by Gestures.ini can be scripted in Gestures Default.ahk.

pajenn
  • Members
  • 391 posts
  • Last active: Feb 06 2015 07:57 AM
  • Joined: 07 Feb 2009

1. I need to press right-click longer on tray icons to get the menu

I'm not sure what to suggest. Does it happen only with specific applications?


Actually, it's that sometimes the system misses a right-click when gestures is running. Probably not app specific, may involve my previous rbutton hotkeys that are still running...

Firefox works well now.

Without this behaviour, you could not use gestures over any window on which the gesture button usually has an effect.


I modified a draw-on-screen script by Metaxal, and stripped it down to where it just draws temporary trails when right mouse button is down (and erases them on up), F1 to exit:

edit: I updated the code after first posting (now it's closer to Shimanov version of screen draw) because the previous only worked when gestures was running too.

/*
- F1 quits program, Rbutton to draw
*/
#SingleInstance force
CoordMode, Mouse, Screen
Process, Exist
pid_this := ErrorLevel

hdc_screen := DllCall( "GetDC", "uint", 0 )

hdc_buffer := DllCall( "CreateCompatibleDC", "uint", hdc_screen )
hbm_buffer := DllCall( "CreateCompatibleBitmap", "uint", hdc_screen, "int", A_ScreenWidth, "int", A_ScreenHeight )
DllCall( "SelectObject", "uint", hdc_buffer, "uint", hbm_buffer )

DllCall( "BitBlt", "uint", hdc_buffer, "int", 0, "int", 0, "int", A_ScreenWidth, "int", A_ScreenHeight, "uint", hdc_screen, "int", 0, "int", 0, "uint", 0x00CC0020 )

Gui, +AlwaysOnTop -Caption
Gui, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%

WinGet, hw_canvas, ID, ahk_class AutoHotkeyGUI ahk_pid %pid_this%

hdc_canvas := DllCall( "GetDC", "uint", hw_canvas )

DllCall( "BitBlt", "uint", hdc_canvas, "int", 0, "int", 0, "int", A_ScreenWidth, "int", A_ScreenHeight, "uint", hdc_buffer, "int", 0, "int", 0, "uint", 0x00CC0020 )

color := 0xFF0000 ;blue

width := 6
MouseGetPos, x_last, y_last
mode_draw:= False

WM_MOUSEMOVE = 0x0200
OnMessage( WM_MOUSEMOVE, "HandleMessage" )
return

HandleMessage( p_w, p_l )
{
   global mode_draw, hdc_canvas, hdc_buffer, x_last, y_last, width, color

   x := p_l & 0xFFFF
   y := p_l >> 16

   if ( mode_draw )
      color = 0xFF0000
      
   else
      color := DllCall( "GetPixel", "uint", hdc_buffer, "int", x, "int", y )
   
   drawLine(x_last, y_last, x, y, color, width)
         
   x_last := x
   y_last := y
}
 
/*
Bresenham algorithm
From:
http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html
*/
drawLine(x0, y0, x1, y1, color_ini=0, width=1)
{
   global hdc_canvas, hdc_buffer
   
   color := color_ini
   
   dx := x1 - x0
   dy := y1 - y0
   stepx := 0
   stepy := 0
   if (dx < 0) {
      dx := -dx
      stepx := -1
   } else
      stepx := 1
   if (dy < 0) {
      dy := -dy
      stepy := -1
   } else
      stepy := 1
   
   Loop %width%
   {
      x := x0+A_Index-1
      y := y0
      DllCall( "SetPixel", "uint", hdc_canvas, "int", x, "int", y, "uint", color )
   }
   if (dx > dy) {
      fraction := dy - (dx >> 1)
      Loop
      {
         if (x0 = x1)
            break
         if (fraction >= 0) {
            y0 += stepy
            fraction -= dx
         }
         x0 += stepx
         fraction += dy
         Loop %width%
         {
            x := x0+A_Index-1
            y := y0
            DllCall( "SetPixel", "uint", hdc_canvas, "int", x, "int", y, "uint", color )
         }
      }
   } else {
      fraction = dx - (dy >> 1)
      Loop
      {
         if (y0 = y1)
            break
         if (fraction >= 0) {
            x0 += stepx
            fraction -= dy
         }
         y0 += stepy
         fraction += dx
         Loop %width%
         {
            x := x0+A_Index-1
            y := y0
            DllCall( "SetPixel", "uint", hdc_canvas, "int", x, "int", y, "uint", color )
         }
      }
   }

}


F1::ExitApp

RButton::
   Gui, Restore
   DllCall( "BitBlt", "uint", hdc_canvas, "int", 0, "int", 0, "int", A_ScreenWidth, "int", A_ScreenHeight, "uint", hdc_buffer, "int", 0, "int", 0, "uint", 0x00CC0020 )
   MouseGetPos, x_last, y_last
   mode_draw:= True
Return

RButton Up::
   mode_draw:= False
   Gui, Cancel
Return

Would it be feasible to integrate that script with Gestures? Each right-click click restores a transparent GUI on which the mouse path is drawn. The GUI is canceled upon release of the button.

Hardware: fast laptop with SSD
Software: Win 7 Home Premium 64-bit, android for phone and tablet


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
GestureKey_Down in Gestures.ahk is called when the button is pressed, and GestureKey_Up when it is released. ~RButton and ~RButton Up may be merged with - or turned into regular labels and called from - those two subroutines.