AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Button presses in a game not working

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Bkid



Joined: 26 Sep 2005
Posts: 44
Location: Hephzibah, GA

PostPosted: Thu Nov 01, 2007 4:48 am    Post subject: Button presses in a game not working Reply with quote

This some code on a script I'm working on to delay the keypresses in a game. Basically what it does it this.

You press the joystick button -> The joystick button tells the AHK script to press a button on the keyboard -> they keyboard button is pressed in-game.

I'm having trouble at the 2nd and 3rd part. If I open a notepad and press buttons on the joystick, the letters they are assigned to come up fine. But if I actually go in-game and try to press the buttons, they will not press at all.


This is only partial code, so some of the variables won't be given values in the following piece of code.

Code:
WatchAxis:
GetKeyState, JoyY, JoyY
KeyToHoldDownPrev = %KeyToHoldDown%
if JoyY > 70
    KeyToHoldDown =
else if JoyY < 30
{
    Sleep, %buttondelay%
    KeyToHoldDown = g
}
else
    KeyToHoldDown =
if KeyToHoldDown = %KeyToHoldDownPrev%
    return
if KeyToHoldDownPrev
    Send, {%KeyToHoldDownPrev% up}
if KeyToHoldDown
    Send, {%KeyToHoldDown% down}
return
Joy1::
Sleep, %buttondelay%
Send z
return
Joy2::
Sleep, %buttondelay%
Send s
return
Joy8::
Sleep, %buttondelay%
Send x
return
Joy3::
Sleep, %buttondelay%
Send d
return
Joy7::
Sleep, %buttondelay%
Send c
return
Joy4::
Sleep, %buttondelay%
Send f
return
Joy6::
Sleep, %buttondelay%
Send v
return
Joy5::
Sleep, %buttondelay%
Send b
return
Joy10::
Sleep, %buttondelay%
Send, {Home}
return
Joy9::
Sleep, %buttondelay%
Send, {Esc}
return

_________________
--Bkid--
Back to top
View user's profile Send private message Visit poster's website AIM Address
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Thu Nov 01, 2007 5:25 am    Post subject: Reply with quote

what game? many games don't respond to just send.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Bkid



Joined: 26 Sep 2005
Posts: 44
Location: Hephzibah, GA

PostPosted: Thu Nov 01, 2007 5:32 am    Post subject: Reply with quote

It's not a common game. The game actually has a config.exe file that you use to set the keys up for the game (by presses buttons on the keyboard or joystick buttons).

Here's an example of config.exe, where I've pressed z s x d c f v g b Home, and Esc (1-9, Test, and Exit, respectively):



But if it doesn't respond to Send, could you give me an example of something that it could possibly respond to? I've tried just about everything I could think of, though..
_________________
--Bkid--
Back to top
View user's profile Send private message Visit poster's website AIM Address
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Thu Nov 01, 2007 6:01 am    Post subject: Reply with quote

controlsend?

there are gaming tutorials in the forum, and examples of different commands to talk to hard to automate programs.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Bkid



Joined: 26 Sep 2005
Posts: 44
Location: Hephzibah, GA

PostPosted: Thu Nov 01, 2007 6:14 am    Post subject: Reply with quote

Man I've tried everything. Send, SendRaw, ControlSend, SendInput, SendPlay. It's ridiculous that it's still not working, but..it's not. Sad
Those numbers in the config.exe box. Those..identifies, so to speak, of each button..Are those able to be "sent" in a sense? If so, then the problem could possibly be solved that way.
_________________
--Bkid--
Back to top
View user's profile Send private message Visit poster's website AIM Address
Ball
Guest





PostPosted: Thu Nov 01, 2007 9:16 am    Post subject: Reply with quote

Try this one. im not sure if its working Laughing

Code:

WatchAxis:
GetKeyState, JoyY, JoyY
KeyToHoldDownPrev = %KeyToHoldDown%
if JoyY > 70
    KeyToHoldDown =
else if JoyY < 30
{
    Sleep, %buttondelay%
    KeyToHoldDown = g
}
else
    KeyToHoldDown =
if KeyToHoldDown = %KeyToHoldDownPrev%
    return
if KeyToHoldDownPrev
    Send, {%KeyToHoldDownPrev% up}
if KeyToHoldDown
    Send, {%KeyToHoldDown% down}
return
Joy1::
Sleep, %buttondelay%
Send {z down}{z up}
return
Joy2::
Sleep, %buttondelay%
Send {s down}{s up}
return
Joy8::
Sleep, %buttondelay%
Send {x down}{x up}
return
Joy3::
Sleep, %buttondelay%
Send {d down}{d up}
return
Joy7::
Sleep, %buttondelay%
Send {c down}{c up}
return
Joy4::
Sleep, %buttondelay%
Send {f down}{f up}
return
Joy6::
Sleep, %buttondelay%
Send {v down}{v up}
return
Joy5::
Sleep, %buttondelay%
Send {b down}{b up}
return
Joy10::
Sleep, %buttondelay%
Send, {Home down}{Home up}
return
Joy9::
Sleep, %buttondelay%
Send, {Esc down}{Esc up}
return
Back to top
Bkid



Joined: 26 Sep 2005
Posts: 44
Location: Hephzibah, GA

PostPosted: Thu Nov 01, 2007 4:11 pm    Post subject: Reply with quote

Well that worked, though I'm not sure how...I used to do send downs and send ups alot in my old scripts, but I just replaced it with plain old send because I thought it would work just as well.

My mistake. Razz
_________________
--Bkid--
Back to top
View user's profile Send private message Visit poster's website AIM Address
Bkid



Joined: 26 Sep 2005
Posts: 44
Location: Hephzibah, GA

PostPosted: Thu Nov 01, 2007 5:07 pm    Post subject: Reply with quote

Now I'm running into something different..The keys seem to delay, and some don't hit at all..I need some way to get the other keys set up like g is (joyy in the beginning of the script). The 3 main things I'm running into right now:

[*]Keys are delaying and sometimes not hitting at all.
[*]Keys aren't being HELD down, just pressed.
[*]If keys WERE to be held down, with keywait for example, two keys can't be pressed simultaneously.

I'm thinking that scripting the other keys kind of like how JoyY is scripted could make it work. I tried it though, and it's pressing the key once and only once..Maybe I didn't something wrong..
_________________
--Bkid--
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group