AHK as assistive technology solution for people with disabilities?

Get help with using AutoHotkey and its commands and hotkeys
MinxiesDev
Posts: 3
Joined: 15 Jun 2019, 06:07

AHK as assistive technology solution for people with disabilities?

15 Jun 2019, 07:04

Dear AHK Community,

As a long time AHK user, I wonder if AHK is the right tool for this job.

For many people, with disabilities, a they are unable to use right click.

This could be caused by some motoneuron disability or simply that they are unable to use a conventional two button mouse. I myself have this issue.

A solution to the above problem is to allow people to right click by simply pressing and holding the left click button.

I wonder if AHK would be the right tool for this?

I have had a look around and found the following two libraries may be useful:

https://github.com/evilC/TapHoldManager (for handling tap/hold events)
https://github.com/evilC/AutoHotInterception (For isolating to a single mouse)

However, I'm unable to put them together into a cohesive package.

There are lots of people with the above problem that I am looking forward to sharing this with, if you think this is possible in AHK?

Thanks and have a blessed day.

James
Kobaltauge
Posts: 235
Joined: 09 Mar 2019, 01:52
GitHub: MassimoCastell
Location: Germany
Contact:

Re: AHK as assistive technology solution for people with disabilities?

15 Jun 2019, 08:34

That is easy. This script checks how log the left mouse button is pressed. If it's longer than 100ms, it sends a right click.

Code: Select all

~LButton::
HowLong = 0
while(getKeyState("LButton","P")){
	HowLong ++
	sleep 10
}
If (HowLong > 100)
	Send, {RButton}
vsub
Posts: 303
Joined: 29 Sep 2015, 03:39

Re: AHK as assistive technology solution for people with disabilities?

15 Jun 2019, 08:48

It's not so easy as you may think
~ will allows the left click to work normally so if for example you want to right click on a link but you left click,when you release the button,the left click will be executed and right click if you hold the button long enough
If you remove the ~ you will not be able to drag files or for example use left click to draw in paint or select text or...tons of other things

Your only option is to also use another hotkey along with left clicking(Ctrl+LButton for example)

Code: Select all

^LButton::
Keywait,LButton,t.5 ; hold the lbutton for half a second
If ErrorLevel
Send,{RButton}
Else
Send,{LButton}
Return
Kobaltauge
Posts: 235
Joined: 09 Mar 2019, 01:52
GitHub: MassimoCastell
Location: Germany
Contact:

Re: AHK as assistive technology solution for people with disabilities?

16 Jun 2019, 06:22

@vsub you're totally right. There are a few things to consider. I didn't test the drag&drop issue at all. Therefore, I would propose that this script is only the beginning to help @MinxiesDev. He's a AHK user and probably knows how to modify or/and upgrade it.

For the drag & drop I added the mouse position. It only triggers the right click if the mouse isn't move more than 50px.

Code: Select all

~LButton::
HowLong = 0
MouseGetPos, X1, Y1
while(getKeyState("LButton","P")){
	HowLong ++
	sleep 10
}
If (HowLong > 100)
{
	MouseGetPos, X2, Y2
	movex := Abs(X1 - X2)
	movey := Abs(Y1 - Y2)
	If (movex <= 50 or movey <= 50)
		Send, {RButton}
}
vsub
Posts: 303
Joined: 29 Sep 2015, 03:39

Re: AHK as assistive technology solution for people with disabilities?

16 Jun 2019, 07:06

Umm,I am going to repeat myself again
The "~" part infront of LButton allows the left click to work the normal way AND will also execute this in the script

If you hold the button long enough,the script will execute right click but when you release the left button,the normal action of left clicking will also be executed

~ allows LButton Down to be sended to the current mouse position and since ~ is not blocking the normal working way of LButton,when you release the button the mouse(hardware)will send LButton Up which windows will accept and execute the left clicking

This also allows right click dragging and it shows a tooltip that RClick is active so you know that when you release the LButton,you will execute right click

Code: Select all

^LButton::
Keywait,LButton,t0.5 ; hold the lbutton for 1 second
If ErrorLevel
{
ToolTip,RButton Active
Send,{RButton Down}
Keywait,LButton
Send,{RButton Up}
ToolTip
}
Else
Send,{LButton}
Return
MinxiesDev
Posts: 3
Joined: 15 Jun 2019, 06:07

Re: AHK as assistive technology solution for people with disabilities?

23 Jun 2019, 20:07

Thanks both. These both great solutions both work great.

I'm actually using @Kobaltauge at the moment. It has a few quirks but really nice solution and functional to the extent where I've been using it on a day-to-day.

@vsub solution is also nice because overall it seems like you get more control with the ctrl key. I think this is the solution that I am going to practice with next with foot pedals.

These two should absolutely do me for now. I'm going to have a further play and manually switch between the two.

Thanks so much for putting in the effort. This should help me along nicely.

I've always thought some kind of switchable state machine would work great in order to switch between the two paradigms (or more). I wonder however if this is beyond the scope of AHK?

Very sorry for the late reply. I use it here and just found out that email notifications are not switched on by default.

I hope you both had great weekends

Best,
James
Kobaltauge
Posts: 235
Joined: 09 Mar 2019, 01:52
GitHub: MassimoCastell
Location: Germany
Contact:

Re: AHK as assistive technology solution for people with disabilities?

25 Jun 2019, 13:13

Sorry @vsub you're completely right. With hyperlinks my solution does not work properly. You can control the behavior of the left mouse button better with an additional key.

@MinxiesDev I realisied this script. Tell me if it's going in the right direction.
When you start it, "my" function of the left mouse button is active. That means, if you press it longer, than a right click will be performed. Unfortunately a left click will be performed too.
When you move the mouse in the upper left corner (coodinates 0,0) and press the left mouse button long, the script switches from "my" behaviour to "vsub's" behaviour or vice versa.
I had to change the script of vsub, because I had issues in AHK Studio with his version and the left double-click. I hope it works the same way.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

lrbutton := true
clrbutton := false

~LButton::
HowLong = 0
MouseGetPos, X1, Y1
while(getKeyState("LButton","P")){
	HowLong ++
	sleep 10
}
If (HowLong > 100)
{
	MouseGetPos, X2, Y2
	if (X2 = 0 and Y2 = 0)
	{
		lrbutton :=! lrbutton
		clrbutton := ! clrbutton
		if (lrbutton)
		{
			MsgBox,,,longpress left click,2
		}
		else
		{
			MsgBox,,,control left click,2
		}
	}
	else if (lrbutton)
	{
		movex = 0 and movey = 0
		movey := Abs(Y1 - Y2)
		If (movex <= 50 or movey <= 50)
			Send, {RButton}
	}
	else
		Return
}

^LButton::
if (clrbutton)
{
	HowLong = 0
	MouseGetPos, X1, Y1
	while(getKeyState("LButton","P")){
		HowLong ++
		sleep 10
	}
	If (HowLong > 100)
		Send, {RButton}
}
MinxiesDev
Posts: 3
Joined: 15 Jun 2019, 06:07

Re: AHK as assistive technology solution for people with disabilities?

26 Jun 2019, 21:56

Firstly, this is just like Christmas. Every time you guys send and you AHK script, it's like I get to open the package and play with a new toy.

Thank you so much for the efforts you have both putting.

On with the script...

This is so advanced, I could never have conceived about writing this myself.

This is perfectly functional. I can think of so many more features for this. but I wouldn't want to burden you with it.

The only improvement that I can think would be to have it automatically right click, once the time lapses. I understand though that this would be a fundamental rearchitechting and I wouldn't want to burden that on you. However I think you may have chosen the path of right click on release for reasons, that I am not fully understanding yet and I'm pretty sure that I'm missing some edge cases that you have seen and I have not.

Over the next couple of days, I will be using this full-time. I may be tweaking the parameters. Be sure to post them back upstream.

Hope you have both have a great and relaxed rest of your day and week.
Kobaltauge
Posts: 235
Joined: 09 Mar 2019, 01:52
GitHub: MassimoCastell
Location: Germany
Contact:

Re: AHK as assistive technology solution for people with disabilities?

27 Jun 2019, 04:20

MinxiesDev wrote:
26 Jun 2019, 21:56
The only improvement that I can think would be to have it automatically right click, once the time lapses.
To calculate the time if you do a "normal" left click or a "long" left click the only chance is to react on the release of the button. It is possible to change the script that it would send a right click after a determined time. But the left button would be still pressed and on release there would be issues to consider.

Check the current version and give feedback after a while.

Return to “Ask For Help”

Who is online

Users browsing this forum: Derpderpingtonishere, eagerahk, LadyGamer, scriptor2016, TAC109, UnknownTragic and 325 guests