 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
AndaleTheGreat Guest
|
Posted: Tue Jul 01, 2008 6:03 am Post subject: Joystick buttons |
|
|
I just really really wanna be able to set a hotkey for a joystick button, mostly to create a turbo. I think I could set the button to press a key that is mapped in my emulator to that buttons place but I apparently (according to the help file) cannot use 2 joystick buttons at once as a hotkey so i'd have to either sacrifice a second button or reach for the keyboard everytime.
So, yah. more joystick function maybe |
|
| Back to top |
|
 |
AndaleTheGreat Guest
|
Posted: Tue Jul 01, 2008 6:48 am Post subject: even more confused |
|
|
see, this is what i don't get. is it really that hard to send a button press relayed falsely as an existing joystick?
also, I wonder if anyone can find a way around a small issue.
my idea is simple:
______________
1joy3::send {z down}{z up}
1joy7::send {z down}{z up}(then i repeat this about thirty times)
return
______________
The current failure is these 'z's just add up and keep pressing until they've run out, i wondered if i could shorten the time but i seem to be misunderstanding the format for placing the sleep command.
how can i set it to keep doing that only while the button is pressed, i can't seem to get the loop command to work for me and i think the answer lies there. I've used these scripts for a long time now, my first one was for starcraft but i can't believe how hard it is to just make a repeated button press. |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 732 Location: The Interwebs
|
Posted: Tue Jul 01, 2008 7:05 am Post subject: |
|
|
| Code: | 1joy7::
JoyUp:=False
Loop,
{
Send {z down}
Sleep 50 ;milliseconds, increase/decrease as desired
Send {z up}
Sleep 50 ;milliseconds, increase/decrease as desired
If (JoyUp = True)
Break
}
Return
1joy7 up::JoyUp:=True |
| Quote: | | is it really that hard to send a button press relayed falsely as an existing joystick? | Don't really know what you're trying to say here...
| Quote: | | I just really really wanna be able to set a hotkey for a joystick button, mostly to create a turbo. | Also don't know what you're trying to say here, since you demonstrate in your next post how to use a joystick button as a hotkey.. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Tue Jul 01, 2008 7:15 am Post subject: |
|
|
there is no built-in way to simulate joystick input with AHK. You can try to interface PPJoy with AHK, as linked from the joystick help page. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Jul 01, 2008 7:19 am Post subject: Re: even more confused |
|
|
| AndaleTheGreat wrote: | | ...but i seem to be misunderstanding the format for placing the sleep command. |
...well I can't see what you tried, but this don't currently work...
| Code: | | 1joy3::send {z down}{sleep 119}{z up} |
...well it works but not as "Sleep"...(again I said that DON'T work {as in it don't Sleep/delay the script, it presses the computer's Sleep button 119 times})...
| AndaleTheGreat wrote: | | how can i set it to keep doing that only while the button is pressed |
..."keep doing" = Loop (or SetTimer)..."only while the button is pressed" = GetKeyState...
| AndaleTheGreat wrote: | | ...i can't seem to get the loop command to work for me |
...you should've posted exactly how you tried to get loop to work...
Note I don't have a Joystick to test with...but...try this...
| Code: | ;//*** NOTE *** for multi-line hotkeys put the 1st line BELOW the hotkey label AND put return after the last line that should be part of that hotkey...
1joy3::
Send, {z Down}
;//*** NOTE *** this is where you Sleep if needed...(it's commented out right now)...
;//Sleep, 119
Send, {z Up}
return
;//*** NOTE *** again...multi-line hotkey = 1st line below hotkey label...plus return at end...
1joy7::
;//*** NOTE *** "keep doing" = Loop
Loop {
;//*** NOTE *** if you want 1joy7 to always do what 1joy3 does (but faster, looped), then you can Gosub & not have to copy the code here
Gosub, 1joy3
if (!GetKeyState(A_ThisHotkey)) {
break
}
}
return |
...also if you really want 1joy7 to modify other keys, like 1joy3, try this...
| Code: | 1joy3::
Loop {
Send, {z Down}
;//*** NOTE *** this is where you Sleep if needed...(it's commented out right now)...
;//Sleep, 119
Send, {z Up}
if (!GetKeyState("1joy7")) {
break
}
}
return |
|
|
| Back to top |
|
 |
AndaleTheGreat Guest
|
Posted: Tue Jul 01, 2008 3:17 pm Post subject: Re: even more confused |
|
|
Firstly, thanks everybody. Way more response than I expected and very quickly, from now on I'll try better to be more detailed and clear.
| Krogdor wrote: | *CODE REMOVED*
| Quote: | | is it really that hard to send a button press relayed falsely as an existing joystick? | Don't really know what you're trying to say here... |
Ok, sorry, your code had no repeat to it, I couldn't tell you why. I tried a few changes but none of them worked.
I meant what 'engunneer' says above. The program won't send joystick presses, ie; z::send {1joy3}. Sorry, the way i said it was dumb.
| Krogdor wrote: | | Quote: | | I just really really wanna be able to set a hotkey for a joystick button, mostly to create a turbo. | Also don't know what you're trying to say here, since you demonstrate in your next post how to use a joystick button as a hotkey.. |
Same complaint as the first, poorly worded, I meant as the response to a hotkey.
| Anonymous wrote: | | Quote: | | ...but i seem to be misunderstanding the format for placing the sleep command. |
...well I can't see what you tried, but this don't currently work...
| Code: | | 1joy3::send {z down}{sleep 119}{z up} |
...well it works but not as "Sleep"...(again I said that DON'T work {as in it don't Sleep/delay the script, it presses the computer's Sleep button 119 times})... |
Yeah, I basically tried that, jamming sleep in random places, even on the next line, it would just end up sending the text repeatedly.
| Anonymous wrote: |
| Quote: | | how can i set it to keep doing that only while the button is pressed |
..."keep doing" = Loop (or SetTimer)..."only while the button is pressed" = GetKeyState...
Note I don't have a Joystick to test with...but...try this...
| Code: | ;//*** NOTE *** for multi-line hotkeys put the 1st line BELOW the hotkey label AND put return after the last line that should be part of that hotkey...
1joy3::
Send, {z Down}
;//*** NOTE *** this is where you Sleep if needed...(it's commented out right now)...
;//Sleep, 119
Send, {z Up}
return
;//*** NOTE *** again...multi-line hotkey = 1st line below hotkey label...plus return at end...
1joy7::
;//*** NOTE *** "keep doing" = Loop
Loop {
;//*** NOTE *** if you want 1joy7 to always do what 1joy3 does (but faster, looped), then you can Gosub & not have to copy the code here
Gosub, 1joy3
if (!GetKeyState(A_ThisHotkey)) {
break
}
}
return |
|
Even without a joystick you not only got it right but fantastically right. I kept trying with loop but the formats kept seeming to not work. I'll have to reread the help file, work on some simple stuff. I learned alot of these commands in qbasic and have a tendency to fall back to their formats which don't work here.
Thanks everyone! |
|
| Back to top |
|
 |
AndaleTheGreat Guest
|
Posted: Tue Jul 01, 2008 3:46 pm Post subject: "1 more thing" as grandpa would say |
|
|
as it's for a video game there were some considerations to make.
| Code: | ;//*** NOTE *** for multi-line hotkeys put the 1st line BELOW the hotkey label AND put return after the
last line that should be part of that hotkey...
1joy3::
Send, {z Down}
;//*** NOTE *** this is where you Sleep if needed...(it's commented out right now)...
;//Sleep, 10
Loop {
if (!GetKeyState("1joy3")) {
break
}
}
Send, {z Up}
return
;//*** NOTE *** again...multi-line hotkey = 1st line below hotkey label...plus return at end...
1joy7::
;//*** NOTE *** "keep doing" = Loop
Loop {
;//*** NOTE *** if you want 1joy7 to always do what 1joy3 does (but faster, looped), then you can
Gosub & not have to copy the code here
Gosub, 1joy3
if (!GetKeyState(A_ThisHotkey)) {
break
}
}
return |
added a loop to keep it pressing 'x' until i let go. (btw, 1joy3 is the x button)
needed this for several games that require holing a button, but also because i'm playing legend of dragoon and holding 'x' passes the text by faster.
I don't think there's anything else to do for it really. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|