Build Your Own Arcade Controls Forum
Main => Software Forum => Topic started by: Louis Tully on December 13, 2011, 08:51:05 am
-
.
-
My ahk is a little rusty, so you'll excuse me if I don't use the proper syntax, but probably the way I would do it would be to setup some variables to hold the state of joy7 and joy8. I would then add a function in the main program loop to check if both of these variables are "1" and if they are, send the alt f4 keys.
-
So what's the issue using Joytokey or Xpadder?
-
If and only when Joy7 is down, Joy8 sends the !{F4} command. But only if Joy7 is down. Otherwise Joy7 is Joy7 and Joy8 is Joy8.
This is untested as I don't have a gamepad handy, but try this:
$Joy8::
GetKeyState, OutPutVar, Joy7
If (OutPutVar = "U")
{
send {Joy8}
}
If (OutPutVar = "D")
{
send !{F4}
}
return
This should work, I tried it with keyboard keys and it worked like a charm, but sometimes stuff with a gamepad is a little different.
-
.
-
Interesting. Yeah, AHK is pretty powerful. I'm using it now in the jukebox build I'm working on to independently track 3 mice and make each control something different (the mouse wheels will be connected mechanically to knobs on the cabinet).
Anyway, from the docs on the site....
$
This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. The exact behavior of the $ prefix varies depending on operating system:
On Windows NT4/2k/XP or later: The $ prefix forces the keyboard hook to be used to implement this hotkey, which as a side-effect prevents the Send command from triggering it. The $ prefix is equivalent to having specified #UseHook somewhere above the definition of this hotkey.
On Windows 95/98/Me: The hotkey is disabled during the execution of its thread and re-enabled afterward. As a side-effect, if #MaxThreadsPerHotkey is set higher than 1, it will behave as though set to 1 for such hotkeys.
So, since you want to send the Joy8 input in response to the same joy8 input, you'd need to use this to prevent the hotkey from triggering itself.
I didn't know about this trick...
-
Thanks, nitz. :cheers:
Sure thing, ahk is pretty awesome, I always enjoy solving a problem with it for practice sake. Here's an alternative to the script above:
$Joy8::
GetKeyState, OutPutVar, Joy7
If (OutPutVar = "D")
{
send !{F4}
return
}
send {Joy8}
return
It has the same functionality, is a bit shorter, and will also allow Joy8 to work even if the keystate of Joy7 could not be determined, wheras the other script simply wouldn't do anything in that case (although I think it's pretty rare to have that problem). This is the way I would go if I were making the script for myself, though the one I posted before is probably easier to understand for someone just learning ahk.