Need help Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Need help

16 Mar 2019, 03:41

Hello, i have this script for when I double click left button to press "k"

#UseHook

LButton::
if (A_TickCount - LButton_Tick <= 250) AND (LButton_Tick >= 1)
Send {k}
else
Send {LButton}
LButton_Tick := A_TickCount
return


The problem is I can't hold Left button now. It's just click can't hold.
Can someone fix that?
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Need help

16 Mar 2019, 04:36

HI SonGokuBg,

You're telling your script to :

Code: Select all

if you double click within a certain timeframe
Send a "k"
or else
Send only one mouse click
you need to create another condition "else if" which allows you to validate that condition so that your script knows to hold it down instead of just sending one single left mouse click
-TL
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Re: Need help

16 Mar 2019, 04:57

Tigerlily wrote:
16 Mar 2019, 04:36
HI SonGokuBg,

You're telling your script to :

Code: Select all

if you double click within a certain timeframe
Send a "k"
or else
Send only one mouse click
you need to create another condition "else if" which allows you to validate that condition so that your script knows to hold it down instead of just sending one single left mouse click
I am very amateur :roll: Can You do it for me?
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Need help  Topic is solved

16 Mar 2019, 05:40

This worked for me - it was a funny tricky problem. I adjusted your LButton_Tick <=250 to <=350 because it seemed to make the double click for Send "k' more reliable. There's probably a better way to do this.. but this is a solution :P

I used SetTimer:

Code: Select all

#NoEnv
#SingleInstance, force
SendMode, Input
#UseHook

LButton::
if (A_TickCount - LButton_Tick <= 350) AND (LButton_Tick >= 1)
	Send {k}
else
{
	Send {LButton down}
}
SetTimer, ClickBackUp, -1
LButton_Tick := A_TickCount
return	

ClickBackUp:
if !(GetKeyState("LButton" , "P"))
	Send {LButton up}
else
	SetTimer, ClickBackUp, -1
return
EDIT: the previous code that I posted had some issues with it when typing, so I fixed it ;)
Last edited by Tigerlily on 16 Mar 2019, 06:06, edited 4 times in total.
-TL
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: Need help

16 Mar 2019, 05:53

how about to use 'tild' prefix ~ to keep its native function
and
I guess, you have to consider drag functionality of mouse too
SonGokuBg
Posts: 72
Joined: 27 Aug 2017, 12:40

Re: Need help

16 Mar 2019, 07:02

Tigerlily wrote:
16 Mar 2019, 05:40
This worked for me - it was a funny tricky problem. I adjusted your LButton_Tick <=250 to <=350 because it seemed to make the double click for Send "k' more reliable. There's probably a better way to do this.. but this is a solution :P

I used SetTimer:

Code: Select all

#NoEnv
#SingleInstance, force
SendMode, Input
#UseHook

LButton::
if (A_TickCount - LButton_Tick <= 350) AND (LButton_Tick >= 1)
	Send {k}
else
{
	Send {LButton down}
}
SetTimer, ClickBackUp, -1
LButton_Tick := A_TickCount
return	

ClickBackUp:
if !(GetKeyState("LButton" , "P"))
	Send {LButton up}
else
	SetTimer, ClickBackUp, -1
return
EDIT: the previous code that I posted had some issues with it when typing, so I fixed it ;)
I love You!
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Need help

18 Mar 2019, 09:20

SonGokuBg wrote:
16 Mar 2019, 07:02
Happy I could help :D Welcome to the forums.
-TL

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], mikeyww and 362 guests