Help converting a toggle script to hold down script Topic is solved

Ask gaming related questions (AHK v1.1 and older)
User avatar
hyperspeed
Posts: 6
Joined: 12 Oct 2017, 20:56

Help converting a toggle script to hold down script

12 Oct 2017, 21:08

Hello everyone 1st time here I'm having a hard time to make this script work only when I hold shift, can someone help me to convert this script for The Evil Within 2, currently when I press shift it starts to press a and d but for disable it i have to press shift again, I would like to hold shift and make it stop when i'm not holding it.

Code: Select all

shift::
 {
   toggle := !toggle
   if (toggle)
    {
      settimer, one, 100
      sleep, 50
      settimer, two, 100
    }
   else
    {
      settimer, one, off
      settimer, two, off
    }
 }
return

one:
 {
   sendinput, a
 }
return

two:
 {
   sendinput, d
 }
return

*o up::
var := false
Send {Blind}{o up}
return
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help converting a toggle script to hold down script

13 Oct 2017, 00:54

Hallo,
the hotkey Shift:: fires upon release https://autohotkey.com/docs/KeyList.htm
So I took LShift:: and RShift:: instead.
Try:

Code: Select all

LShift::
RShift::
  settimer, one, 100
  sleep, 50
  settimer, two, 100
  KeyWait, Shift
  settimer, one, off
  settimer, two, off
return

one:
   sendinput, a
return

two:
   sendinput, d
return

*o up::
var := false
Send {Blind}{o up}
return
User avatar
hyperspeed
Posts: 6
Joined: 12 Oct 2017, 20:56

Re: Help converting a toggle script to hold down script

14 Oct 2017, 00:12

Thank you very much. *o*
User avatar
hyperspeed
Posts: 6
Joined: 12 Oct 2017, 20:56

Re: Help converting a toggle script to hold down script

15 Oct 2017, 14:11

The script works great but I dunno why it doesn't accept Xpadder and Controller Companion keys is there anyway to make this work with Xpadder or Controller Companion?

If I press Shift on my keyboard it works fine however if I set shift to one of my x360 button via Xpadder or Controller Companion, it won't work.

The following script is what I use to skip QTE that have to press "A" faster, it works with Xppader, Controler Comp. and with keyboard too, I mean if i map the p button on xpadder or controller comp. and press with the x360 button that I mapped on it works.

Code: Select all

*p::
SetKeyDelay -1
var := true
sleep_var := 1
if(!chat)
{
	while(var)
	{	
		Send {Blind}{space DownTemp}{space DownTemp}
		Sleep sleep_var
		Send {Blind}{space up}{space up}
		Sleep sleep_var
	}
}
else
{
	Send {Blind}{p DownTemp}
}

return

*p up::
var := false
Send {Blind}{p up}
return
So I changed the shift button to k and I tried to make it to look more like the p script, and like with the shift it works only when I press the button via the keyboard it still doesn't works via Xpadder, and Controller Comp. :

Code: Select all

*k::
SetKeyDelay -1
var := true
sleep_var := 1
  settimer, one, 100
  sleep, 50
  settimer, two, 100
  KeyWait, k
  settimer, one, off
  settimer, two, off
return

one:
   sendinput, a
return

two:
   sendinput, d
return

*k up::
var := false
Send {Blind}{k up}
return
So, is there anyway to make the "k" button work on Xpadder etc just like the "p" button works?
This is how my script is looking right now:

Code: Select all

#UseHook
#MaxHotkeysPerInterval 200  ;example from Help file

*k::
SetKeyDelay -1
var := true
sleep_var := 1
  settimer, one, 100
  sleep, 50
  settimer, two, 100
  KeyWait, k
  settimer, one, off
  settimer, two, off
return

one:
   sendinput, a
return

two:
   sendinput, d
return

*k up::
var := false
Send {Blind}{k up}
return

*p::
SetKeyDelay -1
var := true
sleep_var := 1
if(!chat)
{
	while(var)
	{	
		Send {Blind}{space DownTemp}{space DownTemp}
		Sleep sleep_var
		Send {Blind}{space up}{space up}
		Sleep sleep_var
	}
}
else
{
	Send {Blind}{p DownTemp}
}

return

*p up::
var := false
Send {Blind}{p up}
return

End::ExitApp
return
btw: sorry for the double post.
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help converting a toggle script to hold down script

16 Oct 2017, 02:05

Hallo,
why Xpadder if you have Autohotkey?
I never used it, so I do not know its side effects.
But I know, "KeyWait, k" does not work with a mapped "k".
What kind of Autohotkey do you use?
With my version (1.1.26.01) something like this: "Send {space DownTemp}" don't work.
The numeric value of DownTemp is always zero.
If DownTemp is a variable, it would have to be "Send {space %DownTemp%}".
User avatar
hyperspeed
Posts: 6
Joined: 12 Oct 2017, 20:56

Re: Help converting a toggle script to hold down script

16 Oct 2017, 11:24

I dunno how can I check my version but I downloaded it in 2016, and the rar file says this "AutoHotkey112401_x64"

So yeah it might be an old ver.

hmm, so the keywait makes it doesn't work with mapped buttons, maybe I can remove that, i like to use Xpadder and Controler Companion becuase I can customize something like, hold LB and press RB = p and xpadder can add things like, two keys in one button, example: if I just press start = t but if I hold start for 1.5sec it will be = r.

But for evil within 2 I would like to put it like this, I press LB and then LT to be = k or just hold a button like B (from x360) for 0.25sec to be = k

Is it possible to do some of those combinations via AHK?

Edit: If I remove the keywait it doesn't work any more, maybe if i could put a x360 button there it would work.
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help converting a toggle script to hold down script

17 Oct 2017, 10:51

Hallo,
I have no Xbox 360, but I found in https://autohotkey.com/board/topic/8018 ... er-for-pc/
Joy1 == Green/Button A
Joy2 == Red/Button B
Joy3 == Blue/Button X
Joy4 == Yellow/Button Y
Joy5 == Button LB
Joy6 == Button RB
Joy7 == Button Back
Joy8 == Button Start
Joy9 == Button Left thumb stick
Joy10 == Button Right thumb stick

e.g. Joy1 try:

Code: Select all

Joy1::
  settimer, one, 100
  sleep, 50
  settimer, two, 100
  KeyWait, Joy1
  settimer, one, off
  settimer, two, off
return
User avatar
hyperspeed
Posts: 6
Joined: 12 Oct 2017, 20:56

Re: Help converting a toggle script to hold down script

18 Oct 2017, 13:13

Unfortunate it doesn't work.

Edit:

Code: Select all

k::
 {
   toggle := !toggle
   if (toggle)
    {
      settimer, one, 100
      sleep, 50
      settimer, two, 100
    }
   else
    {
      settimer, one, off
      settimer, two, off
    }
 }
return

one:
 {
   sendinput, a
 }
return

two:
 {
   sendinput, d
 }
return
Since this version works with controllers is there anyway to make this toggle automaticaly turn off after 3 seconds?
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help converting a toggle script to hold down script  Topic is solved

20 Oct 2017, 01:58

Hallo,
try:

Code: Select all

k::
   toggle := !toggle
   if (toggle)
    {
      settimer, one, 100
      sleep, 50
      settimer, two, 100
	  settimer, Toggle_Off, -3000
    }
   else
    {
      settimer, one, off
      settimer, two, off
    }
return

Toggle_Off:
	toggle := False
	settimer, one, off
    settimer, two, off
return	

one:
   sendinput, a
return

two:
   sendinput, d
return
User avatar
hyperspeed
Posts: 6
Joined: 12 Oct 2017, 20:56

Re: Help converting a toggle script to hold down script

21 Oct 2017, 08:49

It works thank you very much @Rohwedder. *o*

If anyone else is interested on this QTE script I will leave it here, it works on both The Evil Within 1 and 2, since TEW1 uses space for all QTE xD:

"k" key will skip the "a" and "d" (rotate stick in controllers) when enemies grab you,
"p" key will skip all press "A" faster QTE both TEW1 and TEW2, except one in TEW2 that appears when you are fighting the chainsaw guy.

Code: Select all

#UseHook
#MaxHotkeysPerInterval 200  ;example from Help file

k::
   toggle := !toggle
   if (toggle)
    {
      settimer, one, 100
      sleep, 50
      settimer, two, 100
	  settimer, Toggle_Off, -3000
    }
   else
    {
      settimer, one, off
      settimer, two, off
    }
return

Toggle_Off:
	toggle := False
	settimer, one, off
    settimer, two, off
return	

one:
   sendinput, a
return

two:
   sendinput, d
return

*p::
SetKeyDelay -1
var := true
sleep_var := 1
if(!chat)
{
	while(var)
	{	
		Send {Blind}{space DownTemp}{space DownTemp}
		Sleep sleep_var
		Send {Blind}{space up}{space up}
		Sleep sleep_var
	}
}
else
{
	Send {Blind}{p DownTemp}
}

return

*p up::
var := false
Send {Blind}{p up}
return

End::ExitApp
return
Also make sure to leave those highlighted keys like the following img:
Image

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 77 guests