My script needs a bit of help

Post gaming related scripts
Evil-e
Posts: 146
Joined: 04 Sep 2018, 11:09

My script needs a bit of help

23 Apr 2019, 12:58

The following script enables the use of a single key, to send a second key, after holding it down for 300ms:

Code: Select all

XButton2::TimeG:= A_PriorHotkey = "XButton2" ? TimeG : A_TickCount + 300 ;tap < 300ms
XButton2 Up::Send,% A_TickCount < TimeG ? "XButton2" : "{Esc}" ;sends either "XButton2" or "{Esc}"
Tap> XButton2 and sends itself and the script terminates at that point
HOLD> XButton2 for 300ms and it sends "ESC"

Once I have held the XButton2 for the necessary 300ms, I wish there to be a 3500ms delay PRIOR to the "ESC" key being
triggered.

:morebeard:

PS> This script was given to me by Rohwedder back in December
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)
alclarkey
Posts: 5
Joined: 25 Apr 2019, 15:53

Re: My script needs a bit of help

14 May 2019, 18:01

Code: Select all

XButton2::
buttondown := (A_Sec * 1000) + A_MSec ; The current second * 1000 + the current millisecond
return

XButton2 Up::
buttonup := (A_Sec * 1000) + A_MSec
if (buttonup - buttondown) < 300
       {
        send {XButton2}
        return ; Not sure if this will end the hotkey thread here, or not. If not, you could replace this line with a goto and a label that skips past the "settimer" 
       }
SetTimer, sendesc, 3500
return

sendesc:
send {Esc}
return
alclarkey
Posts: 5
Joined: 25 Apr 2019, 15:53

Re: My script needs a bit of help

14 May 2019, 18:02

There was an attempt made, and you'll have to do some debugging probably, but hopefully this should give you some idea on how to make it work.
imsamuka
Posts: 3
Joined: 04 Feb 2020, 17:46

Re: My script needs a bit of help

05 Feb 2020, 01:59

Code: Select all

once = 1
Loop{
	if (GetKeyState("XButton2"))
		button := A_TickCount
	buttontime := button - button0
	ToolTip, When You Clicked: %button0%`nYour current time:  %button%`nTime passed: %buttontime%`nCurrent Hotkey: %A_ThisHotkey%`nDelete This Tooltip.
}
~XButton2::
if once
	button0 := A_TickCount
once = 0
Return
~XButton2 Up::
once = 1
if (buttontime > 300){
	Sleep, 3500
	Send {Esc}
	button0 := A_TickCount
}
Return
User avatar
Xtra
Posts: 1790
Joined: 02 Oct 2015, 12:15

Re: My script needs a bit of help

05 Feb 2020, 03:19

Code: Select all

XButton2::TimeG:= A_PriorHotkey = "XButton2" ? TimeG : A_TickCount + 300 ;tap < 300ms
XButton2 Up::Send,% A_TickCount < TimeG ? "XButton2" : SendEsc() ;sends either "XButton2" or "{Esc}"

SendEsc() {
    SetTimer, delayedSend, -3500
    return
    delayedSend:
    Send, {Esc}
}
?? HTH

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 4 guests