Need a double click script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
busymind
Posts: 12
Joined: 12 Apr 2024, 01:32

Need a double click script

Post by busymind » 20 May 2024, 06:54

Hi.
I need a script that keeps double-clicking as long as I'm holding down the Mouse's forward AND backward buttons at the same time.
Can anyone please give me a script that does that?
I really need that and I couldn't put more time into making it, it kept not working the way I wanted, I gave up cause I'm really noob at ahk.
Thanks.

Rohwedder
Posts: 7735
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need a double click script

Post by Rohwedder » 20 May 2024, 10:37

Hallo,
perhaps?:

Code: Select all

#Persistent
#InstallMouseHook
SetTimer, double_clicking, 200
double_clicking:
If GetKeyState("XButton1","P") And GetKeyState("XButton2","P")
	Click 2
Return

User avatar
busymind
Posts: 12
Joined: 12 Apr 2024, 01:32

Re: Need a double click script

Post by busymind » 20 May 2024, 11:59

Rohwedder wrote:
20 May 2024, 10:37
Hallo,
perhaps?:

Code: Select all

#Persistent
#InstallMouseHook
SetTimer, double_clicking, 200
double_clicking:
If GetKeyState("XButton1","P") And GetKeyState("XButton2","P")
	Click 2
Return
I actually did mix up some pieces of code and made a script really similar to what you posted, and it works fine, BUT not everywhere, it's really weird and I didn't know how to fix it, I'll try to show it in a gif:
Image
As you can see it works fine in the text editor app, but not in the other app, it doesn't change the pages... There was also another app which this script couldn't work but I don't remember where it was...
Things I've tried but didn't work:
Increasing the SetTimers delay to 1000ms or decreasing it to 100ms or even 1ms.
Changing the "Click 2" to "ClicK".
Changing the "Click 2" to "Send {LButton}".
By not working, I mean it worked like shown in the gif... it worked in the text editor but not in that other PDF viewer app...
Attachments
DoubleClick.gif
DoubleClick.gif (945.9 KiB) Viewed 787 times

User avatar
CoffeeChaton
Posts: 37
Joined: 11 May 2024, 10:50

Re: Need a double click script

Post by CoffeeChaton » 20 May 2024, 19:10

Try running the script with administrator rights?

User avatar
busymind
Posts: 12
Joined: 12 Apr 2024, 01:32

Re: Need a double click script

Post by busymind » 20 May 2024, 22:52

CoffeeChaton wrote:
20 May 2024, 19:10
Try running the script with administrator rights?
Didn't work.

Rohwedder
Posts: 7735
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need a double click script

Post by Rohwedder » 21 May 2024, 00:21

Maybe this the other app doesn't like that the XButton1+2 are pressed?
Try:

Code: Select all

#Persistent
#InstallMouseHook
SetTimer, double_clicking, 200
double_clicking:
If GetKeyState("XButton1","P") And GetKeyState("XButton2","P")
{
	Send,% GetKeyState("XButton1")?"{Blind}{XButton1 Up}{XButton2 Up}":""
	Click 2
}
Return

User avatar
busymind
Posts: 12
Joined: 12 Apr 2024, 01:32

Re: Need a double click script

Post by busymind » 21 May 2024, 01:25

Rohwedder wrote:
21 May 2024, 00:21
Maybe this the other app doesn't like that the XButton1+2 are pressed?
Try:

Code: Select all

#Persistent
#InstallMouseHook
SetTimer, double_clicking, 200
double_clicking:
If GetKeyState("XButton1","P") And GetKeyState("XButton2","P")
{
	Send, {Blind}{XButton1 Up}{XButton2 Up}
	Click 2
}
Return
Yep, this one works in that PDF viewer app too. But I don't need any delay between the clicks, I want it to behave exactly like a physical double-click button on the mouse (Which my new mouse lacks and I thought it was not that needed but I was a bit wrong...), I tried setting the delay to 0ms and use Click 3 instead of Click 2, but it accumulates all the clicks when I hold it for a few seconds... and keeps clicking... which is kinda bad. This doesn't happen with a physical button, it stops when you stop holding it down...
Can you fix that? Thanks a lot.

Rohwedder
Posts: 7735
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need a double click script

Post by Rohwedder » 21 May 2024, 04:14

I don't know the behavior of a physical double-click mouse button, but I assume it doesn't continuously send double-clicks when held down:
Try:

Code: Select all

#Persistent
#InstallMouseHook
#IF GetKeyState("XButton1","P")
*XButton2::Send, {Blind}{XButton1 Up}{LButton 2}
#IF GetKeyState("XButton2","P")
*XButton1::Send, {Blind}{XButton2 Up}{LButton 2}
#IF

User avatar
busymind
Posts: 12
Joined: 12 Apr 2024, 01:32

Re: Need a double click script

Post by busymind » 21 May 2024, 06:54

Rohwedder wrote:
21 May 2024, 04:14
I don't know the behavior of a physical double-click mouse button, but I assume it doesn't continuously send double-clicks when held down:
Try:

Code: Select all

#Persistent
#InstallMouseHook
#IF GetKeyState("XButton1","P")
*XButton2::Send, {Blind}{XButton1 Up}{LButton 2}
#IF GetKeyState("XButton2","P")
*XButton1::Send, {Blind}{XButton2 Up}{LButton 2}
#IF
Sorry, I think I was a bit unclear. The previous script works fine. I wanted it to work exactly like that. I want to hold both forward & backward keys and it should send clicks continuously... (Not necessarily double clicks, what I need is a way to click fast repeatedly...) The problem that I mentioned in my previous comment, was that when I wanted to increase the speed of clicks, I increased the number from 2 to 3, and I decreased the delay to 0ms. By the accumulation of clicks, I meant that if I hold down the forward & backward buttons for a few seconds (8~10 seconds) then I think because it sends a huge number of click commands, it doesn't stop clicking even when I release the forward & backward buttons and it keeps clicking until all the sent click commands get finished... That's the problem. I think I was really unclear in my previous comment since I didn't mention that it keeps clicking even after releasing the forward & backward buttons. I don't know if there's a way to fix that, the previous script works well enough right now with 2 clicks...
it stops clicking right after I release the forward & backward buttons...
But the problem that I described is a point of improvement if you wanted to make the script work correctly even with more number of clicks like 3 and above...

User avatar
busymind
Posts: 12
Joined: 12 Apr 2024, 01:32

Re: Need a double click script

Post by busymind » 21 May 2024, 07:15

Rohwedder wrote:
21 May 2024, 04:14
I don't know the behavior of a physical double-click mouse button, but I assume it doesn't continuously send double-clicks when held down.
It does continuously send double-clicks. At least my previous mouse worked like that, which is what I need...

Rohwedder
Posts: 7735
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need a double click script  Topic is solved

Post by Rohwedder » 21 May 2024, 08:43

Then:

Code: Select all

#InstallMouseHook
#IF GetKeyState("XButton1","P")
*XButton2::
#IF GetKeyState("XButton2","P")
*XButton1::
#IF
Send, {Blind}{XButton1 Up}{XButton2 Up}
SetTimer, double_clicking, 200
double_clicking:
If GetKeyState("XButton1","P") And GetKeyState("XButton2","P")
	Click 2
Else SetTimer, double_clicking, Off
Return

User avatar
busymind
Posts: 12
Joined: 12 Apr 2024, 01:32

Re: Need a double click script

Post by busymind » 21 May 2024, 10:02

Rohwedder wrote:
21 May 2024, 08:43
Then:

Code: Select all

#InstallMouseHook
#IF GetKeyState("XButton1","P")
*XButton2::
#IF GetKeyState("XButton2","P")
*XButton1::
#IF
Send, {Blind}{XButton1 Up}{XButton2 Up}
SetTimer, double_clicking, 200
double_clicking:
If GetKeyState("XButton1","P") And GetKeyState("XButton2","P")
	Click 2
Else SetTimer, double_clicking, Off
Return
Yep, this one works better even with more mouse clicks. Thank you so much. :D

Post Reply

Return to “Ask for Help (v1)”