Hi ,
In Crysis 1 and Crysis: Warhead, the lean buttons need to be held down to work. I'd like to make these lean buttons able to be toggled to work like Rainbow 6 Siege's - that is, for example: once you press Q, you will lean left until you press Q again to return to neutral, OR until you press E, which will make you lean right and in which case pressing E again will return you to the neutral stance, or pressing Q which returns you to leaning left. So basically, either lean key works the reverse of the other in this fashion.
I am totally unfamiliar with scripting for AHK and generally, and if I thought this was more than a fairly simple request I'd try to learn a enough to pull it off, but as it is the amount of documentation seems rather daunting. If someone could "assist" me with this it would be much appreciated.
Thank you
Make lean buttons able to be toggled
-
- Posts: 74
- Joined: 29 Mar 2017, 01:55
Re: Make lean buttons able to be toggled
try this , you can add #IfWinActive ______ at the top so that it works only on your game.
jumpout = 0
$*q::
if(jumpout = 0)
{
jumpout = 1
SetTimer, LeanLeft, 10
}
else
{
jumpout = 0
SetTimer, LeanLeft, off
}
Return
$*e::
if(jumpout = 0)
{
jumpout = 1
SetTimer, LeanRight, 10
}
else
{
jumpout = 0
SetTimer, LeanRight, off
}
Return
LeanLeft:
Send {q down}
Return
LeanRight:
Send {e down}
Return
jumpout = 0
$*q::
if(jumpout = 0)
{
jumpout = 1
SetTimer, LeanLeft, 10
}
else
{
jumpout = 0
SetTimer, LeanLeft, off
}
Return
$*e::
if(jumpout = 0)
{
jumpout = 1
SetTimer, LeanRight, 10
}
else
{
jumpout = 0
SetTimer, LeanRight, off
}
Return
LeanLeft:
Send {q down}
Return
LeanRight:
Send {e down}
Return
Re: Make lean buttons able to be toggled
Hey bud,
If Q and E are your lean buttons then try this:
( F1 to stop toggling and F2 to close script)
This does not use timers, instead uses {send down} which will give you the opportunity to save resource usage. Cheers!
If Q and E are your lean buttons then try this:
( F1 to stop toggling and F2 to close script)
Code: Select all
#MaxThreadsPerHotkey 2
SendMode Input
*Q::
Send, {E up}
Toggle := !Toggle
if Toggle
Send, {Q down}
else
Send, {Q up}
return
*E::
Send, {Q up}
Toggle := !Toggle
if Toggle
Send, {E down}
else
Send, {E up}
return
F1:: ExitApp
F2:: Suspend, Toggle
I am your average ahk newbie. Just.. a tat more cute.
Re: Make lean buttons able to be toggled
Thank you both for the responses!
However:
bryantan179's broke on my first attempted use It would let me lean once, but then both lean keys stopped responding (acting as if help down I think, as when returning to Windows I get a constant ping until I close the script)
Nwb's works well to toggle leaning, but it doesn't allow me to lean the opposite direction directly/automatically. Rather, pressing the opposite key will return me to neutral . Hopefully you will look into this*!
If all else fails, Nwb's works quite well at what is does despite the behavioural discrepancy. Thanks again.
*Some further info on how the game works:
While leaning e.g. left by holding Q, if I then hold down E, I will return to neutral. Releasing Q while still holding E will then allow me to lean right.
The game doesn't let me lean directly to the other side while both buttons are held down. Perhaps the script requires a sort of "if E pressed while Q while already down, hold E and then release Q"? I don't know, just fleshing out the problem in hopes you can get the script working as preferred is all
However:
bryantan179's broke on my first attempted use It would let me lean once, but then both lean keys stopped responding (acting as if help down I think, as when returning to Windows I get a constant ping until I close the script)
Nwb's works well to toggle leaning, but it doesn't allow me to lean the opposite direction directly/automatically. Rather, pressing the opposite key will return me to neutral . Hopefully you will look into this*!
If all else fails, Nwb's works quite well at what is does despite the behavioural discrepancy. Thanks again.
*Some further info on how the game works:
While leaning e.g. left by holding Q, if I then hold down E, I will return to neutral. Releasing Q while still holding E will then allow me to lean right.
The game doesn't let me lean directly to the other side while both buttons are held down. Perhaps the script requires a sort of "if E pressed while Q while already down, hold E and then release Q"? I don't know, just fleshing out the problem in hopes you can get the script working as preferred is all
Re: Make lean buttons able to be toggled
Try this:chroma008 wrote:Thank you both for the responses!
However:
bryantan179's broke on my first attempted use It would let me lean once, but then both lean keys stopped responding (acting as if help down I think, as when returning to Windows I get a constant ping until I close the script)
Nwb's works well to toggle leaning, but it doesn't allow me to lean the opposite direction directly/automatically. Rather, pressing the opposite key will return me to neutral . Hopefully you will look into this*!
If all else fails, Nwb's works quite well at what is does despite the behavioural discrepancy. Thanks again.
*Some further info on how the game works:
While leaning e.g. left by holding Q, if I then hold down E, I will return to neutral. Releasing Q while still holding E will then allow me to lean right.
The game doesn't let me lean directly to the other side while both buttons are held down. Perhaps the script requires a sort of "if E pressed while Q while already down, hold E and then release Q"? I don't know, just fleshing out the problem in hopes you can get the script working as preferred is all
Code: Select all
*Q::
if not Toggle2
Toggle := !Toggle
Send, {E up}
Toggle := !Toggle
if Toggle
Send, {Q down}
else
Send, {Q up}
return
*E::
if not Toggle
Toggle := !Toggle
Send, {Q up}
Toggle2 := !Toggle2
if Toggle2
Send, {E down}
else
Send, {E up}
return
F1:: ExitApp
F2:: Suspend, Toggle
I am your average ahk newbie. Just.. a tat more cute.
Re: Make lean buttons able to be toggled
The new script is unreliable and broken
It did manage to lean the other direction as desired, but only about 1/25th of the time. Other times pressing a lean key would do nothing regardless of the current stance*, and sometimes behaving like your previous script and returning to neutral from leaning.
My guess is that there's some kind of state that's not being handled correctly? Or it needs to recognise a neutral beginning state? Just guesswork, probably not helpful...
Cheers though, I do appreciate your continued work on this
*For example pressing Q to begin with will NOT do anything, regardless of the number of times it's pressed. Pressing E does work, for some reason. One sequence I can directly change from leaning left (Q) to leaning right (E) from starting the script is: Q (does nothing), E (leans right), Q (returns to neutral), E (does nothing), Q (leans left), E (leans right). I don't think I can lean left from leaning right at all. Not sure if this helps, but there you go
It did manage to lean the other direction as desired, but only about 1/25th of the time. Other times pressing a lean key would do nothing regardless of the current stance*, and sometimes behaving like your previous script and returning to neutral from leaning.
My guess is that there's some kind of state that's not being handled correctly? Or it needs to recognise a neutral beginning state? Just guesswork, probably not helpful...
Cheers though, I do appreciate your continued work on this
*For example pressing Q to begin with will NOT do anything, regardless of the number of times it's pressed. Pressing E does work, for some reason. One sequence I can directly change from leaning left (Q) to leaning right (E) from starting the script is: Q (does nothing), E (leans right), Q (returns to neutral), E (does nothing), Q (leans left), E (leans right). I don't think I can lean left from leaning right at all. Not sure if this helps, but there you go
Re: Make lean buttons able to be toggled
Code: Select all
q::ProcessLean("q")
e::ProcessLean("e")
ProcessLean(key){
static lean_state := 0
if (lean_state != 0){
Send % "{" lean_state " up}"
;~ ToolTip % lean_state " up"
wasRelease := (lean_state == key)
lean_state := 0
if (wasRelease)
return
}
Send % "{" key " down}"
;~ ToolTip % key " down"
lean_state := key
}
^Esc::
ExitApp
Re: Make lean buttons able to be toggled
Unfortunately, that does not work either, at least straight as it is.
While running this script in-game, Q & E work as they do by default. In Windows, Q & E don't seem to register at all.
Not sure what the tooltips are exactly, but I'm not receiving any notification if that was intended, whether in-game or not.
Thanks for looking at it though.
While running this script in-game, Q & E work as they do by default. In Windows, Q & E don't seem to register at all.
Not sure what the tooltips are exactly, but I'm not receiving any notification if that was intended, whether in-game or not.
Thanks for looking at it though.
Re: Make lean buttons able to be toggled
That code was purely meant to demonstrate that the issue still occurs with stacked hotkeys.
If the hotkeys are not triggering in-game, try running the script as admin.
If the game still sees the keys, then you can use my AutoHotInterception library to hook into the keys at a driver level - games have a zero chance of being able to see through that.
If the hotkeys are not triggering in-game, try running the script as admin.
If the game still sees the keys, then you can use my AutoHotInterception library to hook into the keys at a driver level - games have a zero chance of being able to see through that.
Re: Make lean buttons able to be toggled
[quote="evilC"][/quote]
This script works perfectly for me in CoD WWII, however leaning in that game gives next to zero visual feedback so I often forget to undo the lean. I'm still quite new to coding as a whole and this script is going quite a bit over my head, but I would like to add a function that undoes the lean upon pressing another button (shift). Can anyone help with this?
Code: Select all
Code: Select all
q::ProcessLean("q")
e::ProcessLean("e")
ProcessLean(key){
static lean_state := 0
if (lean_state != 0){
Send % "{" lean_state " up}"
;~ ToolTip % lean_state " up"
wasRelease := (lean_state == key)
lean_state := 0
if (wasRelease)
return
}
Send % "{" key " down}"
;~ ToolTip % key " down"
lean_state := key
}
^Esc::
ExitApp
This script works perfectly for me in CoD WWII, however leaning in that game gives next to zero visual feedback so I often forget to undo the lean. I'm still quite new to coding as a whole and this script is going quite a bit over my head, but I would like to add a function that undoes the lean upon pressing another button (shift). Can anyone help with this?
Re: Make lean buttons able to be toggled
Here you go
Code: Select all
$*q::ProcessLean("q")
$*e::ProcessLean("e")
$*Shift::ProcessLean()
ProcessLean(key := -1){
static lean_state := 0
if (key == -1)
key := lean_state
if (lean_state != 0){
Send % "{Blind}{" lean_state " up}"
;~ ToolTip % lean_state " up"
wasRelease := (lean_state == key)
lean_state := 0
if (wasRelease)
return
}
if (key != 0){
Send % "{Blind}{" key " down}"
;~ ToolTip % key " down"
}
lean_state := key
}
Re: Make lean buttons able to be toggled
Hello,
I am trying to do the same.
I want to press q to move to the left and at the same time lean to the left, the same on the d key to move to the right and lean to the right.
do you have an idea ?
I am trying to do the same.
I want to press q to move to the left and at the same time lean to the left, the same on the d key to move to the right and lean to the right.
do you have an idea ?
Who is online
Users browsing this forum: No registered users and 48 guests