MouseGestureL

Post your working scripts, libraries and tools for AHK v1.1 and older
Netmano
Posts: 58
Joined: 17 Jun 2020, 16:24

Re: MouseGestureL

Post by Netmano » 14 Jul 2020, 10:54

@Pyonkichi
Hey I've been trying to combine everything you shared with me so far into Right click with no stroke movment.
the issue am having is the if(!MG_Timer(-300)) for double gesture and if (MG_Executed==1) fix for scrollwheel in same action script for RB__

I have tried combinations of if, else, and else but both if (MG_Executed==1) and if(!MG_Timer(-300)) always trigger one after the other.

Here is my layout and code.
for "RB__"

Code: Select all

if (MG_Executed==1) 
	{
		; Fix for Right click  and Scrollwheel
		Send, ^n
	}

Return

if(!MG_Timer(-300))
	{
	;Action to be run when the waiting time has elapsed.
	TrayTip,, Single
	}
and for "RB__RB__"

Code: Select all

	TrayTip,, Double

User avatar
Pyonkichi
Posts: 109
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

Post by Pyonkichi » 14 Jul 2020, 19:56

@Netmano, Here you go.

for "RB__"

Code: Select all

;Execute After Waiting
if (!MG_Timer(-300)) {
	;Action to be run immediately after the gesture.
	TrayTip,, Single
}
for "RB__RB__"

Code: Select all

TrayTip,, Double
for "RB_WU_"

Code: Select all

Send, ^{tab}
MG_Abort()
By the way, I will implement new function to prevent context menu for the actions that use MG_Timer in next version.

Netmano
Posts: 58
Joined: 17 Jun 2020, 16:24

Re: MouseGestureL

Post by Netmano » 15 Jul 2020, 13:46

Your code above solved the issue and now its working as expected. I am looking forward to the update.


Can targets be duplicated or copied and still contain the gestures and action script as the source target?
I tried duplicating targets but its always empty inside, Maybe its my copy of MGL. please let me know. This is a must feature fo MGL. would cut down set up for new programs and generic windo controlls that most programs use.

User avatar
Pyonkichi
Posts: 109
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

Post by Pyonkichi » 15 Jul 2020, 21:52

@Netmano, There is no feature as you want. I'm considering to implement it.

Netmano
Posts: 58
Joined: 17 Jun 2020, 16:24

Re: MouseGestureL

Post by Netmano » 16 Jul 2020, 08:24

@Pyonkichi
I look forward to it!

User avatar
Previz
Posts: 28
Joined: 01 May 2020, 19:28

Re: MouseGestureL

Post by Previz » 17 Jul 2020, 11:27

Does MGL support holding and releasing a key through a gesture?
I have this software, where I need to hold down [ and move the mouse up or down to change brush size.
I know gestures can tap a button, for examples. RB_8_: send, {[}
but what about RB_8_ , holding down [ and letting me manually move the mouse up or down and when I finish to release [.

User avatar
Pyonkichi
Posts: 109
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

Post by Pyonkichi » 17 Jul 2020, 21:22

@Previz, Assign the following action to "RB_".

Code: Select all

;Execute After Button Up
if (!MG_Hold()) {
	;Action to be performed immediately after the gesture has been entered.
	Send, {[ Down}
} else {
	;Action to be performed when a button has been released.
	Send, {[ Up}
}
;This processing can be added from "Execute After Button Up" in the action template list.

User avatar
Previz
Posts: 28
Joined: 01 May 2020, 19:28

Re: MouseGestureL

Post by Previz » 18 Jul 2020, 08:11

Code: Select all

;Stop Gesture Trail
MG_StopTrail()
Adding the above turns of the trails for one time.

I just discovered there is a whole list of functions like the above neatlly organised into categories.
Is there anything this software cannot do? To think mere mortals sat down and programmed this.

User avatar
Previz
Posts: 28
Joined: 01 May 2020, 19:28

Re: MouseGestureL

Post by Previz » 19 Jul 2020, 16:26

Pyonkichi wrote:
17 Jul 2020, 21:22
@Previz, Assign the following action to "RB_".

Code: Select all

;Execute After Button Up
if (!MG_Hold()) {
	;Action to be performed immediately after the gesture has been entered.
	Send, {[ Down}
} else {
	;Action to be performed when a button has been released.
	Send, {[ Up}
}
;This processing can be added from "Execute After Button Up" in the action template list.



I just realised something. While your code above lets me do exactly what I asked for, but now its not possible me for to get to gestures like RB_8_ RB_2_ RB_6_ RB_4_ because RB_ executes its action script as soon as I hold down right button. Is it possible for RB_ to act as [ but also other times to be able to trigger a gesture like RB_8 ?


I experimented with some of the functions but didnt manage to get anything working. :?

User avatar
Pyonkichi
Posts: 109
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

Post by Pyonkichi » 19 Jul 2020, 22:04

@Previz, That is logically impossible. Both operations, pressing right button down, moving cursor up and releasing a button, are exactly same. The script cannot differentiate which action do you want if both gestures are assigned to the same target.

User avatar
Previz
Posts: 28
Joined: 01 May 2020, 19:28

Re: MouseGestureL

Post by Previz » 20 Jul 2020, 08:41

Pyonkichi wrote:
19 Jul 2020, 22:04
@Previz, That is logically impossible. Both operations, pressing right button down, moving cursor up and releasing a button, are exactly same. The script cannot differentiate which action do you want if both gestures are assigned to the same target.
I appreciate your patience and help man.

I didnt think of that.
I am just trying to come up with a pattern that would allow for button taping and button holding. It would free me up from so many clunky specialised hardware for video editing and color grading.

If you have any better idea of achieving what I explained below, please feel free to suggest them to me :)



So what about using release of right button and then followed by a hold of Right button?
RB_8_RB_
RB_2_RB_
RB_6_RB_
RB_4_RB_


So gestures like the above can perform button holding action script such as this code example:

Code: Select all

{
	send, {[ Down}
} 

else 

{
	send, {[ Up}
}

While its also possible to execute gesture such as these through Right button:
RB_8_
RB_2_
RB_6_
RB_4_

Netmano
Posts: 58
Joined: 17 Jun 2020, 16:24

Re: MouseGestureL

Post by Netmano » 20 Jul 2020, 10:22

@Previz

Previz, this is an idea I have been thinking about as well. Getting MGL to emulate keyboard like key behaviour as much as possbile. Escpecially Tap/release and Tap and Hold behaviour that keyboards can do with the same key while also being able to access all defined gestures.


The script cannot differentiate which action do you want
What about using a waiting time? So that if the user draws a gesture and waits for a defined amount of time a Tap and Hold is triggered but if he releases trigger key before waiting can expire then Tap/release is triggered.
test.png
test.png (12.95 KiB) Viewed 6478 times



You gave me a solution to a similar problem a few days ago. The logic is the same but MGL deffrentiates it by using if (!MG_Timer(-300))
Pyonkichi wrote: for "RB_8_":

Code: Select all

;Execute After Waiting
if (!MG_Timer(-300)) {
	;Action to be run when the waiting time has elapsed.
	TrayTip,, Single
}
;This processing can be added from "Execute After Waiting" in the action template list.
for "RB_8_RB_8_":

Code: Select all

TrayTip,, Double

User avatar
Pyonkichi
Posts: 109
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

Post by Pyonkichi » 21 Jul 2020, 05:10

@Netmano, Thanks for suggestion.

@Previz, Below are my idea.
When you press R button twice and move up cursor while holding the button "[" will be sent. If you move up cursor after single pressing down the button another action will be performed.

for RB__

Code: Select all

MG_Wait(500)
for RB__RB_

Code: Select all

Send, {[ Down}
MG_Wait(500)
for RB__RB_8_

Code: Select all

Send, {[ Up}
for RB_8_

Code: Select all

TrayTip,, RB_8_

User avatar
Previz
Posts: 28
Joined: 01 May 2020, 19:28

Re: MouseGestureL

Post by Previz » 21 Jul 2020, 18:05

I am convinced the best part about MGL, is you :bravo: you are a gentleman and a scholar. Also thank you Netmano.

I tested your idea for sometime, it works as a fix for holding just the [ key but not as a standard that works for other gestures as well. Your idea was brilliant though so I repurpossed it. I also re-used the function you used MG_Wait(500) and using the code you gave to user Netmano sometime ago, I was able to achieve my goal.

Now I am able to have more than a hundred Hold/Release Gestures, while still keeping the same amount of Tap gestures as before. I reprogrammed my mouse right click to F1. So I can use Modifiers such as CTRL+F1 SHIFT+F1 etc etc


I will document the idea, just incase it proves to be helpfull to someone else.
F1__

Code: Select all

if (!MG_Timer(-100)) 
{
	;Action to be run when the waiting time has elapsed.
		send, {rbutton}
}
F1_8

Code: Select all

if (!MG_Hold()) 
{
	Tooltip, Hold Up
}
else 
{
	Tooltip, Release Up
}
;Abort Current Gesture
MG_Abort()
F1__F1__
Tooltip, Double Tap
F1__F1_8_

Code: Select all

Tooltip, Tap Up
;Abort Current Gesture
MG_Abort()

User avatar
Previz
Posts: 28
Joined: 01 May 2020, 19:28

Re: MouseGestureL

Post by Previz » 24 Jul 2020, 21:27

@Pyonkichi


Hi Pyonkichi, I think I may have found a bug in MGL. Some gestures cause MGL to get stuck in stroke drawing mode until you quit MGL. You are then forced to track down which gesture is causing this issue by deleting every gesture one by one until you find the gesture casing the problem.

I have created, an MGL example to document the issue for you. the forum only accepts 2MB file size, so used Dropbox.
Here is the link: https www.dropbox.com/sh/cqwp2vsprdbdfwb/AAA2e95ISylgmVAwmAqeDeK3a?dl=0
(If you would like me to upload it elsewhere for you, please let me know.)

In the example, there are 5 gestures defined in total. Try to trigger a gesture with SHIFT and F2. MGL gest stuck in gesture drawing mode, stroke trail does not go of, even when you release keys.

Then try to delete gesture F2__ and the issue goes away. Its happenned a few other times and I just delete that gesture and not create it again but now I really need this gesture.

Can you please, take a look and see what it might be down to?

User avatar
Pyonkichi
Posts: 109
Joined: 16 May 2017, 20:40
Contact:

Re: MouseGestureL

Post by Pyonkichi » 25 Jul 2020, 22:13

@Previz, Thanks for reporting the issue. You need change the code inside F2.ahk and restart MGL.

Components\Buttons\F2.ahk
Current:

Code: Select all

MG_F2_Enable:
	Hotkey,*F2,MG_F2_DownHotkey,On
	Hotkey,*F2 up,MG_F2_UpHotkey,On
return

MG_F2_Disable:
	Hotkey,*F2,MG_F2_DownHotkey,Off
	Hotkey,*F2 up,MG_F2_UpHotkey,Off
return
To solve the problem, remove the asterisks:

Code: Select all

MG_F2_Enable:
	Hotkey,F2,MG_F2_DownHotkey,On
	Hotkey,F2 up,MG_F2_UpHotkey,On
return

MG_F2_Disable:
	Hotkey,F2,MG_F2_DownHotkey,Off
	Hotkey,F2 up,MG_F2_UpHotkey,Off
return
I will fix this issue in the next version.

User avatar
Previz
Posts: 28
Joined: 01 May 2020, 19:28

Re: MouseGestureL

Post by Previz » 26 Jul 2020, 09:27

@Pyonkichi

Sweet! thanks so much for that.
I did apply your solution to F2.ahk file, but it was not enough. I also had to do the same to SHIFTF2.ahk which is for SHIFT+F2 trigger. Now its working again! :D

I look forward to version v1.34 successor. The upcoming right click function and a native fix for this issue are gonna be awesome.

User avatar
submeg
Posts: 326
Joined: 14 Apr 2017, 20:39
Contact:

Re: MouseGestureL

Post by submeg » 26 Jul 2020, 15:21

Glad to see that others are discovering how amazing this is @Pyonkichi. I showed a couple people over a Teams meeting the other day and they loved it! Hopefully more people will recognise the amazing work you did on this; I use it every day now, fantastic work! Your responses and willingness to help people out are outstanding.

I owe you a coffee!
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:

Netmano
Posts: 58
Joined: 17 Jun 2020, 16:24

Re: MouseGestureL

Post by Netmano » 26 Jul 2020, 16:14

I set up an MGL envoiroment that is impossible to break for my little sister. She was getting frustrated with her computer not working like her iPad. I've calibrated the gesture recognition so that its impossible to make the wrong stroke. This way its always working and I never get bothered by her.

I have say its quite possibly the best AHK library I have so far found. I know of many. Well done for your efforts!

Avastgard
Posts: 133
Joined: 30 Sep 2016, 21:54

Re: MouseGestureL

Post by Avastgard » 27 Jul 2020, 07:20

I have configured a gesture that works like this: hold RButton and move mouse to "southwest" will send #d, wich alternates between desktop view and restores all windows to the previous position.

It has been working quite well for that purpose, but after using that gesture I almost always find out that a window gets stuck on top of all the others and there is no way to restore it. I still haven't figured out what is the logic of this bug (what window gets stuck on top and if it can always be reproduced) and if it really is caused by this script or by this specific gesture.

What I do know is that I have another script running that has the specific purpose of locking a window always on top, but that one is activated by Alt + Q, so I don't see how MouseGestureL could be affecting it. I have tried exiting the "window on top" script after the bug occurs, but it doesn't fix the stuck window.

Do you have any idea of what could be causing this?

Post Reply

Return to “Scripts and Functions (v1)”