I Need Help Making Multiple Clicks Mean Different Things

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Brenyd
Posts: 3
Joined: 19 Aug 2017, 16:42

I Need Help Making Multiple Clicks Mean Different Things

19 Aug 2017, 16:51

I need a Script that will make it to where if i press XButton2 1 time it enters the number 1 If pressed 2 times it enters 2. 3 times enters 3 ect. i need it to do that up to 9 so if pressed 9 times it enters 9 New to scripting and just cant figure it out for the life of me PLEASE HELP!!!!!!!!!!!
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: I Need Help Making Multiple Clicks Mean Different Things

19 Aug 2017, 17:11

Ultimately depends on what kind of delay you want between each key press. For a double-click, you can use A_TimeSinceThisHotkey. If it's less than, say 100, you can perform a check for that and do something otherwise. For multiple keys, you'll need to keep a counter for each time it's pressed, then reset it every time it completes. You might also be able to make use of SetTimer, re setting the timer each time the hotkey is pressed.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: I Need Help Making Multiple Clicks Mean Different Things

19 Aug 2017, 17:16

I posted something similar earlier today here

this worked for my using Lbutton , try it with xButton2 on your end

Code: Select all

DoubleClick_Time := DllCall("User32\GetDoubleClickTime")
Hotkey, % "$~Lbutton" , ClickHandler, on    ; < replace Lbutton with xButton2
return

ClickHandler:
Accu .= SubStr(A_ThisHotkey, 0)

If (A_TimeSincePriorHotkey < DoubleClick_Time)
	SetTimer, TheBigShebang, % -DoubleClick_Time

If (A_TimeSincePriorHotkey > DoubleClick_Time + 100)
	Accu := SubStr(A_ThisHotkey, 0)
return

TheBigShebang:
If Accu
	Send % StrLen(accu)
return
Brenyd
Posts: 3
Joined: 19 Aug 2017, 16:42

Re: I Need Help Making Multiple Clicks Mean Different Things

19 Aug 2017, 19:35

AlphaBravo It works but wont do the number 1 when clicked once anyway to fix?
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: I Need Help Making Multiple Clicks Mean Different Things

19 Aug 2017, 20:42

Brenyd wrote:AlphaBravo It works but wont do the number 1 when clicked once anyway to fix?
slight change:

Code: Select all

DoubleClick_Time := DllCall("User32\GetDoubleClickTime")
Hotkey, % "$~Lbutton" , ClickHandler, on    ; < replace Lbutton with xButton2
return

ClickHandler:
Accu .= SubStr(A_ThisHotkey, 0)

If (A_TimeSincePriorHotkey < DoubleClick_Time)
	SetTimer, TheBigShebang, % -DoubleClick_Time

If (A_TimeSincePriorHotkey > DoubleClick_Time + 100)
{
	Accu := SubStr(A_ThisHotkey, 0)
	gosub TheBigShebang
}
return

TheBigShebang:
If Accu
	Send % "{End}" StrLen(accu)
return
Brenyd
Posts: 3
Joined: 19 Aug 2017, 16:42

Re: I Need Help Making Multiple Clicks Mean Different Things

19 Aug 2017, 21:13

AlphaBravo wrote:
Brenyd wrote:AlphaBravo It works but wont do the number 1 when clicked once anyway to fix?
slight change:

Code: Select all

DoubleClick_Time := DllCall("User32\GetDoubleClickTime")
Hotkey, % "$~Lbutton" , ClickHandler, on    ; < replace Lbutton with xButton2
return

ClickHandler:
Accu .= SubStr(A_ThisHotkey, 0)

If (A_TimeSincePriorHotkey < DoubleClick_Time)
	SetTimer, TheBigShebang, % -DoubleClick_Time

If (A_TimeSincePriorHotkey > DoubleClick_Time + 100)
{
	Accu := SubStr(A_ThisHotkey, 0)
	gosub TheBigShebang
}
return

TheBigShebang:
If Accu
	Send % "{End}" StrLen(accu)
return
I know im being a pain in your ass but the problem with this script is that it does everything i need it too but in between each number are 1s so if i wanted to type 2 it'd be 112 3 would be 1113 idk if there is any more tweaking you can do to fix it but it would awesome if that is possible
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: I Need Help Making Multiple Clicks Mean Different Things

19 Aug 2017, 22:18

no, it's my bad. ;)
this seems to work now

Code: Select all

DoubleClick_Time := DllCall("User32\GetDoubleClickTime")
Hotkey, LButton, ClickHandler, on
return

ClickHandler:
Accu .= "x"
SetTimer, TheBigShebang, % -DoubleClick_Time
If (A_TimeSincePriorHotkey > DoubleClick_Time+100)
	Accu := "x"
return

TheBigShebang:
send % StrLen(accu)
return
Edited

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, NPerovic and 278 guests