MouseGestureL

Post your working scripts, libraries and tools for AHK v1.1 and older
hellen_dorandt89
Posts: 25
Joined: 05 Jan 2022, 08:25

Re: MouseGestureL

11 Apr 2023, 14:25

@Pyonkichi
I see.

I use MGL in a much more involved way, for example I dont use MG_Edit unless I am debugging a issue. I work with MG_Config directly.
I include allot of libraries from there and use allot of Expression syntax.

I can suffer the awfull AHK V1 expression syntax but my biggest concern is, overtime that libararies I use with MGL will be left behind by their V2 counter parts. As well as upcoming AVK 2 features/commands not being available in V1. Which will limit what the user can do in a MGL Action scripts


I can appreciate, writting the entire MGL in V2 is no small task though. I will wait for when you think the timing would be right. :thumbup:
I just appreciate that you actively maintain this amazing tool. Thanks!
Ralf_Reddings200244
Posts: 121
Joined: 11 Mar 2023, 14:16

Re: MouseGestureL

11 Jun 2023, 07:18

@Pyonkichi


Pyonkichi If I may ask you, how to click with left mouse button while this gesure is active?

After I have activated the gesture MG_Gesture_F2_8LB_ and I am now holding Tab I would like to be able to click with the left button (Lbutton). As if no AHK/MouseGestureL was running.

The problem I think is that I have Lbutton declared as a sub trigger in MGL, LB.

Code: Select all

MG_Gesture_F2_8LB_:
	MG_StopTrail()
	If (MG_IsMaya__()) {
	SendInput, {tab down}
	KeyWait, f2
	SendInput, {tab up}
	}
The above works Tab is held down so long as F2 is also held down but because MGL is still active I cannot use mouse left click.
I have tried using MG_Abort() like the following, but even then I cannot click with left button while Tab/F2 is down:

Code: Select all

MG_Gesture_F2_8LB_:
	MG_StopTrail()
	If (MG_IsMaya__()) {
	MG_Abort()
	SendInput, {tab down}
	KeyWait, f2
	SendInput, {tab up}
	}
I also tried this:

Code: Select all

MG_Gesture_F2_8LB_:
	MG_StopTrail()
	If (MG_IsMaya__()) {
	if (MG_Active) {
		MG_Executed:=1
		MG_Aborted:=1
	}
	SendInput, {tab down}
	KeyWait, f2
	SendInput, {tab up}
	}
And also this:

Code: Select all

MG_Gesture_F2_8LB_:
	If (MG_IsMaya__()) {
	MG_Abort()
	GoSub, test
	}
...
...
...
test:
SendInput, {tab down}
KeyWait, f2
SendInput, {tab up}
I am essentially looking for a way to temporarily (for example after a MGL gesture has been fired) disable a MGL trigger/sub trigger or just a means to make MGL go back to being inactive while something like Keywait, F2 is engaged.

Thanks for any help.
User avatar
Pyonkichi
Posts: 113
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

12 Jun 2023, 19:36

@Ralf_Reddings200244, Try this.

Code: Select all

SendInput, {tab down}
MG_Click("LB")
SendInput, {tab up}
Ralf_Reddings200244
Posts: 121
Joined: 11 Mar 2023, 14:16

Re: MouseGestureL

13 Jun 2023, 14:55

@PyonKichi

It works. So simple and eloquent!
Its amazing how many functions there exists in MGL that are unpublished, perhaps they are for internal use by MGL.
Thank you for this.
GGGarikkk
Posts: 6
Joined: 15 Oct 2022, 02:59

Question related to MGL

18 Jun 2023, 02:50

@Pyonkichi
Hello. I wonder if you could help me.
Is it possible to:
1. Use a SetTimer to launch a subroutine when a particular gesture is executed
2. Set off the same timer if the same gesture is triggered before the timer got to launch a subroutine

The global goal from which the question derives is to implement double press recognition.
E.g. When I use a combination MB+C (Middle button + "C" key pressed) a particular action A is executed, but when the "C" pressed twice (MB+C+C) within the interval of, say, 300 milliseconds I want another action B to be performed.
In order to calculate intervals between presses I write to the registry current time when the combination is first pressed. When it is pressed the second time I read from the registry the previous time, subtract it from the current time, which will give me the interval.
But the problem is that when the first time the combination is pressed I need either to
a) Execute action A if 300 milliseconds have passed and the "C" was not pressed second time
b) Execute action B if "C" was pressed the second time
For the a) I may use SetTimer to launch the subroutine for the single press when 300 milliseconds have passed. And if "C" is pressed twice I will disable the timer and process the combination as the double click
Basically, here is the code that I want to integrate into MGL:

Code: Select all

$h::
    RegRead, hPressedBefore, HKEY_CURRENT_USER\Software\AutoHotkey, hPressedBefore
    if (hPressedBefore = "true") { ;Double press
        SetTimer, CheckDoublePress, Off ; Turn off the timer

        RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\AutoHotkey, hPressedBefore, false
        RegRead, prevHTime, HKEY_CURRENT_USER\Software\AutoHotkey, h_interval

        interval := A_TickCount - prevHTime
        MsgBox, h pressed twice with interval %interval% milliseconds
    } else {
        ;Single press or the first press in the combination
        RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\AutoHotkey, hPressedBefore, true
        RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\AutoHotkey, h_interval, %A_TickCount%
        SetTimer, CheckDoublePress, -300 ; Set a timer which when 300 milliseconds pass will execute single press action
    }
Return

CheckDoublePress:
    RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\AutoHotkey, hPressedBefore, false
    MsgBox, Single press detected
Return
User avatar
Pyonkichi
Posts: 113
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

18 Jun 2023, 20:27

@GGGarikkk,
Use the following. They are described in "Execute After Waiting" of the action template "Script Control" category.

Action script for MB_C__:

Code: Select all

;Execute After Waiting
if (MG_Timer(-200)) {
	;Action to be performed immediately after the gesture has been entered.
}
else {
	;Action to be performed when the waiting time has elapsed.
	MsgBox, Single
}
Action script for MB_C__C__:

Code: Select all

MsgBox, Double
Ralf_Reddings200244
Posts: 121
Joined: 11 Mar 2023, 14:16

Re: MouseGestureL

29 Jun 2023, 12:26

@Pyonkichi

If I may ask, how can I stop Mouse Gesture L from blocking Standard AHK Hotkeys that use the same trigger?

I am currently in the process of integrating MouseGestureL into my main script, so that function outputs, objects, variables, state/conditions etc etc are always shared. I especially want to be able to know the state of MGL.

I am not achieving this "integration" through fancy means, just through the #Include directive:

Code: Select all

                                  
#singleinstance, force
#NoEnv
#MaxHotkeysPerInterval 500
#Persistent
#Include, C:\Users\User1\Documents\AutoHotkey\MouseGestureL\MouseGestureL.ahk
return
~Rbutton::
ToolTip, Rbutton is Pressed!
The above is a reproducible example. My script is more complicated but it actually works, MGL works just fine and all data is merged and shared.

The problem I am having is that MGL MG_Gesture_RB_8_: seems to consume Rbutton all for itself, ~Rbutton:: never fires, despite the prefix ~ being in place in the MG_Config file for RB, the only partial fix I have found is the following:

Code: Select all

MG_Triggers=MD
;MG_Triggers=MR_MD
Of course that disables RB in MGL altogether.

I am essentially looking to achieve the following but in a single script file. This is how I have been using MGL in parallel with my main script,
C:\Users\User1\Documents\AutoHotkey\Master.ahk :

Code: Select all

#SingleInstance, Force
#NoEnv
Return

~Rbutton::
ToolTip, Master: Rbutton is Pressed!
Return
C:\Users\User1\Documents\AutoHotkey\MouseGestureL\MouseGestureL.ahk :

Code: Select all

MG_Gesture_RB_8_:
If(!MG_IsExDefault())        
	Tooltip, MGL: Rbutton and Up!
return
Both scripts work in parallel, One script does not "consume" the right click button all for itself thus both scripts are able to use the same button. I have been able to achieve this by adding ~ to the following lines in MG_Config.ahk:

Code: Select all

...
Hotkey, ~RButton, MG_RB_DownHotkey, On
Hotkey, ~RButton up, MG_RB_UpHotkey, On
...
Hotkey, ~RButton, MG_RB_DownHotkey, Off
Hotkey, ~RButton up, MG_RB_UpHotkey, Off
...
`
I know MGL can do a single tap of right click with no mouse movement, even double taps. But I really need this functionality
Any help would be most welcome.
JackRaider
Posts: 7
Joined: 07 Sep 2023, 13:03

Re: MouseGestureL

26 Nov 2023, 15:58

Thankyou for creating this script, it's really amazing!
A couple of questions and a suggestion.

Let's say I'm using two different versions of a program and they both share the same .exe filename, is there a way to create different mouse gestures for both versions of the apps separately? If so, how? I tried to do that and it didn't work out. If this functionality is not there, I hope maybe in a future version, we get this functionality included.

Secondly, I hope you will consider increasing the horizontal size of the GUI (MouseGestureL Configuration GUI/Window) that appears, sometimes I want to read the full name of a Gesture and that proves to be really troublesome because the Config Window is too small horizontally.

Thank you!
User avatar
Pyonkichi
Posts: 113
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

28 Nov 2023, 01:24

@JackRaider, You can define separate targets using different path names.

Target 1 (Custom Condition):

Code: Select all

MG_GetExeName(MG_HWND, true)="c:\aaa\foo.exe"
Target 2 (Custom Condition):

Code: Select all

MG_GetExeName(MG_HWND, true)="c:\bbb\foo.exe"
The size of the list can be customized by overriding the following variables in MG_User.ahk.

Code: Select all

ME_ListH	:= 486		; Height of Lists
ME_TListW1	:= 200		; [P.1] Width  of Target List
ME_GListW1	:= 500		; [P.1] Width  of Gesture List
ME_GListH	:= 185		; [P.1] Height of Gesture List
ME_GListR	:= 35		; [P.1] Ratio  of Gesture Column Width of Gesture List (%)
ME_TListW2	:= 200		; [P.2] Width  of Target List
ME_RListR	:= 35		; [P.2] Ratio  of Type Column Width of Rule List (%)
ME_GListW2	:= 150		; [P.3] Width  of Gesture List
ME_GListW3	:= 250		; [P.3] Width  of Gesture Pattern List
ME_AListR	:= 50		; [P.3] Ratio  of Target Column Width of Action List (%)
ME_ListPad	:= 8		; Padding
This method does not change the entire window size.
JackRaider
Posts: 7
Joined: 07 Sep 2023, 13:03

Re: MouseGestureL

28 Nov 2023, 10:20

Pyonkichi wrote:
28 Nov 2023, 01:24
@JackRaider, You can define separate targets using different path names.

Target 1 (Custom Condition):

Code: Select all

MG_GetExeName(MG_HWND, true)="c:\aaa\foo.exe"
Target 2 (Custom Condition):

Code: Select all

MG_GetExeName(MG_HWND, true)="c:\bbb\foo.exe"
The size of the list can be customized by overriding the following variables in MG_User.ahk.

Code: Select all

ME_ListH	:= 486		; Height of Lists
ME_TListW1	:= 200		; [P.1] Width  of Target List
ME_GListW1	:= 500		; [P.1] Width  of Gesture List
ME_GListH	:= 185		; [P.1] Height of Gesture List
ME_GListR	:= 35		; [P.1] Ratio  of Gesture Column Width of Gesture List (%)
ME_TListW2	:= 200		; [P.2] Width  of Target List
ME_RListR	:= 35		; [P.2] Ratio  of Type Column Width of Rule List (%)
ME_GListW2	:= 150		; [P.3] Width  of Gesture List
ME_GListW3	:= 250		; [P.3] Width  of Gesture Pattern List
ME_AListR	:= 50		; [P.3] Ratio  of Target Column Width of Action List (%)
ME_ListPad	:= 8		; Padding
This method does not change the entire window size.
Where am I supposed to put the MG_GetExeName code that you've given?

When I go into the target window section, I create a new target and in the judgement conditions section, I choose custom condition and in the value, I put the exact path of the program and I get hit up this error when I hit the ok button.

https://i.imgur.com/lNv2Fcg.png
randy_798
Posts: 2
Joined: 08 Jan 2024, 13:42

Re: MouseGestureL

08 Jan 2024, 13:54

@Pyonkichi

I am trying to implement a single tap and a double tap of Rbutton.
  • RB__ print Single
  • RB__RB__ print Double

I followed the solution presented on HERE:

My code:

Code: Select all

MG_Gesture_RB__:
	if (!MG_IsExDefault()) {
		;Execute After Waiting
		if (!MG_Timer(-2000)) {
			;Action to be run when the waiting time has elapsed.
			tooltip Single
		}
		;This processing can be added from "Execute After Waiting" in the action template list.
	}
return

MG_Gesture_RB__RB__:
	if (!MG_IsExDefault()) {
		tooltip double
	}
return
It works but it has a glaring issue. The -2000 value will be demonstrate it. If I fire the RB__ gesture, "single" does get printed. But then right after that, if I also fire RB__ instead of starting a new MG_Timer(-2000) timer and then firing RB__ again, it will fire RB__RB__ and print "double".

I am expecting that when RB__ is fired, MG_Timer(-2000) to be reset, the next time I trigger RB__ then MG_Timer(-2000) should start counting from scratch.

Right now with the way it is, after performing and triggering the RB__ action, performing RB__ again triggers RB__RB__, which is not ideal.

How can I get MG_Timer(-2000) to be reset when RB__ is fired?

Thank you.
User avatar
Pyonkichi
Posts: 113
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

15 Jan 2024, 04:02

@randy_798, The following code changes may be the solution.

Code: Select all

MG_Gesture_RB__:
	if (!MG_IsExDefault()) {
		;Execute After Waiting
		if (!MG_Timer(-2000)) {
			;Action to be run when the waiting time has elapsed.
			MG_WaitNext:=0	; <- Added
			tooltip Single
		}
		;This processing can be added from "Execute After Waiting" in the action template list.
	}
return
randy_798
Posts: 2
Joined: 08 Jan 2024, 13:42

Re: MouseGestureL

15 Jan 2024, 17:28

@Pyonkichi

I can confirm that worked. It was very helpfull to know this fix. I thank you.
Gary-Atlan82
Posts: 74
Joined: 07 Mar 2023, 05:20

Re: MouseGestureL

24 Feb 2024, 17:39

Hello, I am trying to implement a single and a double tap of left click while holding right click, following your guide here, I created the following gestures
  • RB__
  • RB_LB__
  • RB_LB__LB__
The gestures RB__ and RB_LB__LB__ work as expected but RB_LB__ is giving me a issue I have not been able to solve

The issue is, If I press Left click once while holding down right click, once the timer expires and the action script for RB_LB__ fires, without releasing right click, left clicking again fires the action script for RB_LB__LB__, this happens if I wait 200 milliseconds or 10 seconds.

I recorded a small demonstration.

Image


I am expecting that once the timer expires, left clicking (while holding right click) again to fire the action script for RB_LB__.

I tried placing MG_abort(), MG_Cancell() in various places and your solution here but none of them worked for me.

I am using MGL 1.40 and AHK 1.1.37.01. The following is a screenshot of how I have the three gestures set up.

Image


I would appreciate any insight or solution.
User avatar
Pyonkichi
Posts: 113
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

27 Feb 2024, 01:27

@Gary-Atlan82, Try this.

RB__:

Code: Select all

if (MG_IsFirstAction()) {
	ToolTip, RB__
}

RB_LB__:

Code: Select all

if (MG_Timer(-200)==0) {
	MG_Gesture := MG_CurTriggers
	MG_WaitNext := 0
	ToolTip, Single
}

RB_LB__LB__:

Code: Select all

MG_Abort()
ToolTip, Double
Gary-Atlan82
Posts: 74
Joined: 07 Mar 2023, 05:20

Re: MouseGestureL

27 Feb 2024, 18:00

That did it, you make it look so easy. Cheers for this!
badbob001
Posts: 6
Joined: 29 Jan 2020, 19:23

Re: MouseGestureL

04 Apr 2024, 08:40

Does this support detecting gestures from Windows Precision Touchpad protocol? I'm using an Apple magic trackpad on win10 via a driver that uses Windows Precision Touchpad protocol.

Looking for:
  • Detect touchpad scroll to activate window under mouse.
  • Use modifier key (eg: Shift) with three/four finger swipes.
User avatar
GollyJer
Posts: 71
Joined: 19 Sep 2015, 19:33
Contact:

Re: MouseGestureL

24 Apr 2024, 13:45

Hi. I'm trying to scroll to the top or bottom with the RB_U and RB_D gestures. But I can't seem to get the gesture to apply to the control under the mouse, only the window.

Here's what is working only halfway.

Code: Select all

;Jump to Top
; MouseGetPos, xpos, ypos, WinID
; ControlSend, , {Ctrl Down}{Home}{Ctrl Up}, ahk_id %WinID%

WinActivate, ahk_id %WinID%
Sleep, 50
Send,{Ctrl Down}{Home}{Ctrl Up}
MouseGetPos and ControlSend are commented out. I thought they would be the way, but it is very inconsistent.
I would like RB_U and RB_D to behave just like the setting in Windows "Scroll the inactive windows when hovering over them". That setting allows the scrolling of controls just by putting the mouse in the right place and spinning the scroll wheel.

Thanks for any help!
Azona77
Posts: 3
Joined: 02 Sep 2023, 10:17

Re: MouseGestureL

26 Apr 2024, 10:37

Hi, I've been using MouseGestureL for quite a while, but there are still two minor pain points:
- After launching on startup, the MouseGestureL icon sometimes fails to show up in the task bar. I'm not sure if it is due to ahk itself?
- How do I merge custom scripts into MouseGestureL? I have some v1 scripts like this:
-

Code: Select all

<!d::send, #d
- I tried creating an ahk file with content above into the plugin folder, but that just make MouseGestureL not working. Am I missing something?
- I want to merge them so that I can suspend all ahk process at the same time.
User avatar
Pyonkichi
Posts: 113
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

27 Apr 2024, 03:30

@GollyJer, Specify ahk_parent as the 1st param.
You can use MG_HWND as the target window handle.

Code: Select all

ControlSend, ahk_parent, {Ctrl Down}{Home}{Ctrl Up}, ahk_id %MG_HWND%

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: submeg and 101 guests