Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Anyone with an understanding of AHK mind holding my hand for a minute or two?  (Read 2691 times)

0 Members and 1 Guest are viewing this topic.

Louis Tully

  • Trade Count: (+5)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1800
  • Last login:February 13, 2015, 09:41:03 pm
« Last Edit: February 12, 2015, 05:11:34 am by Louis Tully »

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19428
  • Last login:Today at 01:14:11 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
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.

gonzo90017

  • Trade Count: (+5)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1034
  • Last login:June 23, 2019, 02:41:07 pm
  • I'm a llama!
So what's the issue using Joytokey or Xpadder?

nitz

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 507
  • Last login:November 24, 2015, 07:57:29 pm
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:

Quote
$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.

Louis Tully

  • Trade Count: (+5)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1800
  • Last login:February 13, 2015, 09:41:03 pm
.
« Last Edit: February 12, 2015, 05:11:45 am by Louis Tully »

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
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...

nitz

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 507
  • Last login:November 24, 2015, 07:57:29 pm
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:

Quote
$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.