So in this game im moving my charachter with the WASD keys, but if i hold down the A and D key at the same time,
the game register that as a forward movement (W key) so the charachter starts to move forward instead of the strafe actions.
So i need a code which is prevents the A and D key simultaneous pressing.
I tried a lot of Send / Down, Up codes but i just cant figure it out any ideas?
THX anyway
Disable/Block a Key with another Key while its pressed and held down.
-
- Posts: 216
- Joined: 30 Jun 2016, 06:01
Re: Disable/Block a Key with another Key while its pressed and held down.
So you want A and D to override W, if W is already pressed? If so, this should work (untested).
Code: Select all
$a::
If (CheckKey("w"))
{
Send {w up}
While (GetKeyState("a", "p"))
{
Send {a down}
}
Send {w down}
} Else {
Send {a down}
}
Return
$d::
If (CheckKey("w"))
{
Send {w up}
While (GetKeyState("d", "p"))
{
Send {d down}
}
Send {w down}
} Else {
Send {d down}
}
Return
CheckKey(key)
{
If (GetKeyState(key, "p"))
Return 1
}
Re: Disable/Block a Key with another Key while its pressed and held down.
Hey! Thx for the fast reply!
BUT
I want A and D override each other (Im not using the W key), because if i hit both A and D at the same time my character moves forward, not like this \ /
and i want to avoid the forward movements.
I want insantly changed fast Left \ and Right / strafing only.
So i need a code only for the A and D!
BUT
I want A and D override each other (Im not using the W key), because if i hit both A and D at the same time my character moves forward, not like this \ /
and i want to avoid the forward movements.
I want insantly changed fast Left \ and Right / strafing only.
So i need a code only for the A and D!
Last edited by Bubyoz on 23 May 2017, 01:27, edited 1 time in total.
-
- Posts: 216
- Joined: 30 Jun 2016, 06:01
Re: Disable/Block a Key with another Key while its pressed and held down.
That's a little easier. Does this work?
Code: Select all
~a::
If (GetKeyState("d", "p")
{
Send {d up}
}
Return
~d::
If (GetKeyState("a", "p")
{
Send {a up}
}
Return
Re: Disable/Block a Key with another Key while its pressed and held down.
We are getting closer, cause its working basicly, but not continuously. It Stops after 1 direction change.
It does change directions from left to right or right to left perfectly while holding down both keys without moving forward.
BUT i cant change directions again, without letting the keys go.
for example: i hold down the A key for any time (charachter is strafing left), while im holding down the A key i hit the D key too
so it starts to strafe right but when i let the D key go it starts to move left again (Im still holding the A key).
SO basicly i want movement all the time if i hold down any of the 2 keys.
It does change directions from left to right or right to left perfectly while holding down both keys without moving forward.
BUT i cant change directions again, without letting the keys go.
for example: i hold down the A key for any time (charachter is strafing left), while im holding down the A key i hit the D key too
so it starts to strafe right but when i let the D key go it starts to move left again (Im still holding the A key).
SO basicly i want movement all the time if i hold down any of the 2 keys.
- Attachments
-
- Untitled-1.gif (22.08 KiB) Viewed 3875 times
-
- Posts: 216
- Joined: 30 Jun 2016, 06:01
Re: Disable/Block a Key with another Key while its pressed and held down.
Sorry, I'm totally lost. I can't figure out how to make it work.
Re: Disable/Block a Key with another Key while its pressed and held down.
my first question is do you fully understand my "Gibberish" ?
or
do you know someone? who can manage this somehow? its kinda important for competitive game training for me...
i even pay for it a few buck trough paypal if thats needed.
Dont leave me here im getting saaad
or
do you know someone? who can manage this somehow? its kinda important for competitive game training for me...
i even pay for it a few buck trough paypal if thats needed.
Dont leave me here im getting saaad
-
- Posts: 216
- Joined: 30 Jun 2016, 06:01
Re: Disable/Block a Key with another Key while its pressed and held down.
Yeah, I know what you want, I just can't figure out how to make it work. I've tried several different methods. I hope somebody else can figure this out because I hate not being able to.
This is the closest I got. Might help somebody.
This is the closest I got. Might help somebody.
Code: Select all
~a::
If (GetKeyState("d", "p"))
{
Send {d up}
d = 1
}
Return
~d::
If (GetKeyState("a", "p"))
{
Send {a up}
a = 1
}
Return
a up::
If (d)
{
Send {d down}
d = 0
}
Return
d up::
If (a)
{
Send {a down}
a = 0
}
Return
Last edited by neomulemi6 on 22 May 2017, 23:52, edited 1 time in total.
Re: Disable/Block a Key with another Key while its pressed and held down.
Okay man! thx for all the care! topic is open lets hope
and dont give up who knows maybe in the next couple of days ur gonna figure it out!
and dont give up who knows maybe in the next couple of days ur gonna figure it out!
Re: Disable/Block a Key with another Key while its pressed and held down.
hey i tested this code ingame. now its working! when i hold down any of the 2 keys the charachter change its direction.
BUT
after the few direction changes one of the keys are became toggled every time. like its getting hold down even when i dont press it. any idea?
good work btw!
BUT
after the few direction changes one of the keys are became toggled every time. like its getting hold down even when i dont press it. any idea?
good work btw!
Re: Disable/Block a Key with another Key while its pressed and held down.
not sure if this works but give it a go rofl
Code: Select all
$~a::
suspend on
main:
while (getkeystate("a","P") = 1)
{
if (getkeystate("d","P") = 1)
{
while (getkeystate("d","P") = 1)
{
send {d down}
sleep 10
if (getkeystate("a","p") = 0)
{
keyheld := 1
goto main
}
}
send {d up}
}
send {a down}
}
send {a up}
if keyheld = 1
{
while (getkeystate("d","P") = 1)
{
send {d down}
sleep 10
}
keyheld := 0
}
suspend off
return
$~d::
suspend on
main2:
while (getkeystate("d","P") = 1)
{
if (getkeystate("a","P") = 1)
{
while (getkeystate("a","P") = 1)
{
send {a down}
sleep 10
if (getkeystate("d","p") = 0)
{
keyheld := 1
goto main2
}
}
send {a up}
}
send {d down}
}
send {d up}
if keyheld = 1
{
while (getkeystate("a","P") = 1)
{
send {a down}
sleep 10
}
keyheld := 0
}
suspend off
return
Re: Disable/Block a Key with another Key while its pressed and held down.
hey nice looking code there!
i tested and its not working!
@neomulemi6's idea is better cause A and D blocking each other, but in ure code they r not. at least not ingame or not like his! looks good tho
i tested and its not working!
@neomulemi6's idea is better cause A and D blocking each other, but in ure code they r not. at least not ingame or not like his! looks good tho
Re: Disable/Block a Key with another Key while its pressed and held down.
working with this code?
Code: Select all
~a & d::
~d & a::
Send, {a up}
key := "d"
SetTimer, pressdown, 10
return
~d::key := "d"
~a::key := "a"
~a up::key := "d"
~d up::key := "a"
pressdown:
if GetKeyState(key, "p")
{
SendInput, {%key% down}
SetTimer, pressdown, 30
}
else {
SetTimer, pressdown, Off
SendInput, {%key% up}
}
return
Who is online
Users browsing this forum: mikeyww and 56 guests