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: Autohotkey + mame + win 7 x64 = SOLVED!  (Read 7519 times)

0 Members and 1 Guest are viewing this topic.

severdhed

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2975
  • Last login:December 14, 2024, 05:01:52 pm
  • RIP Dinosaur Hippo
Autohotkey + mame + win 7 x64 = SOLVED!
« on: October 01, 2013, 11:48:18 pm »
I have an Autohotkey script that it's designed so that when you press a certain key quickly, it sends one key press, but if you hold it for 3 seconds, it sends a different one. This is soi can use a single button for pause and exit. This worked perfectly fine on my old showcase cabinet (win xp) and my upright cabinet (win xp), but will not work on my new cabinet (win 7 64 bit). It is the same script, exact same version of mame( I copied the mame folder from the old cab to the new one). The script works fine outside of mame. It will not work :/ Terri different Windows 7 computers, but yet works on my Windows 8 laptop. Any ideas
« Last Edit: October 03, 2013, 06:48:01 pm by severdhed »
Current Projects:      Zak-Man | TMNT Pedestal | SNES Pi | N64 Odroid
Former Projects:     4 Player Showcase | Donkey Kong | iCade

severdhed

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2975
  • Last login:December 14, 2024, 05:01:52 pm
  • RIP Dinosaur Hippo
Re: Autohotkey + mame + win 7 x64 = help!
« Reply #1 on: October 02, 2013, 03:15:04 pm »
it is really weird how this is works.  The script works fine in notepad, but mame just seems to ignore it entirely.  If i launch mame, and then alt-tab back to the desktop and press the key, it closes the mame executable. i just dont understand why it would work in xp and windows 8, but not windows 7.  I just tested it here on my work pc, which is also windows 7, but it still does not function.

i have two versions of the script, one which sends either the P or Esc command when escape key is either held or pressed, and other which is set to send the p key if p is pressed, or process close mame.exe if it is held....neither work in mame.  with the first one, mame exits immediately if esc is held or pressed.  with the second one, it pauses when p is pressed, but nothing happens when held.  if i alt-tab to the desktop with mame minimized, and hold the p key, it will close the mame executable like it should...just not while it is running.

is there something i'm doing wrong?

here are my scripts: ( i didn't write these, WXFORECASTER here on the forums created the first one for me years ago, i modified it for the second one.




/*
AUTHOR: WXFORECASTER 10/12/10

DESCRIPTION: DESIGN OVERRIDE SUCH THAT A SINGLE KEY PRESS AND KEY HOLD
             GENERATE DIFFERENT FUNCTIONALITY
*/


/*
BEGIN HOLDESCAPE CODE
SET USER DEFINED VARIABLES BELOW
*/
timeToExit := 1.6    ;time in seconds key must be pressed before sending exit (this can be a decimal e.g. 1.5)
emulateKey := "esc"    ;the key we are pressing/emulating
pauseKey :="p"      ;your MAME pause key
exitKey := "esc"         ;your MAME exit key
exitScript := 0      ;0= leave script running, 1= close script when the MAME exit key is fired,

;Make it so the following code only works if MAME is the active window
;#IfWinActive ahk_class MAME

;Establish Hotkey Mapping based on the emulate key above and trigger a chunk of code below (lblPauseExit)
Hotkey, $%emulateKey%, lblPauseExit
return

lblPauseExit:

KeyWait %emulateKey%, T%timeToExit%

      if ErrorLevel = 1 ;timeout was reached...exit MAME
      {
              send {Blind} {%exitKey% downtemp} ;Send MAME Exit
              send {Blind} {%exitKey% up}
                   if (exitScript = 1)
                      ExitApp
      }
      else
      {
         send {Blind} {%pauseKey% downtemp} ;Send MAME pause/unpause
         send {Blind} {%pauseKey% up}
      }     
return





HERE IS THE SECOND SCRIPT:

/*
AUTHOR: WXFORECASTER 10/12/10

DESCRIPTION: DESIGN OVERRIDE SUCH THAT A SINGLE KEY PRESS AND KEY HOLD
             GENERATE DIFFERENT FUNCTIONALITY
*/


/*
BEGIN HOLDESCAPE CODE
SET USER DEFINED VARIABLES BELOW
*/
timeToExit := 1.6    ;time in seconds key must be pressed before sending exit (this can be a decimal e.g. 1.5)
emulateKey := "p"    ;the key we are pressing/emulating
pauseKey :="p"      ;your MAME pause key
exitKey := "esc"         ;your MAME exit key
exitScript := 0      ;0= leave script running, 1= close script when the MAME exit key is fired,

;Make it so the following code only works if MAME is the active window
;#IfWinActive ahk_class MAME

;Establish Hotkey Mapping based on the emulate key above and trigger a chunk of code below (lblPauseExit)
Hotkey, $%emulateKey%, lblPauseExit
return

lblPauseExit:

KeyWait %emulateKey%, T%timeToExit%

      if ErrorLevel = 1 ;timeout was reached...exit MAME
      {
   Process, Close, mame.exe
                   if (exitScript = 1)
                      ExitApp
      }
      else
      {
         send {Blind} {%pauseKey% downtemp} ;Send MAME pause/unpause
         send {Blind} {%pauseKey% up}
      }     
return
Current Projects:      Zak-Man | TMNT Pedestal | SNES Pi | N64 Odroid
Former Projects:     4 Player Showcase | Donkey Kong | iCade

severdhed

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2975
  • Last login:December 14, 2024, 05:01:52 pm
  • RIP Dinosaur Hippo
Re: Autohotkey + mame + win 7 x64 = help!
« Reply #2 on: October 02, 2013, 10:48:00 pm »
Ok, so i guess i was wrong.  I thought for sure that i had it working on my windows 8 64bit machine, but i tested again and it does not work at all with mame, but is fine outside of it.  i know when i did this the first time, i had to recompile mame to use directinput instead of rawinput or something like that. (which i did and it worked fine) do i need to recompile this on a 64bit system?  is there something different with directinput in a 64bit os?

i'm running out of ideas.  i could just install xp on the cabinet, but mk9 on steam doesn't support windows xp, which is something i'd really like to have on this cabinet.

Current Projects:      Zak-Man | TMNT Pedestal | SNES Pi | N64 Odroid
Former Projects:     4 Player Showcase | Donkey Kong | iCade

SgtSlaughter

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 81
  • Last login:March 02, 2021, 10:38:50 am
Re: Autohotkey + mame + win 7 x64 = help!
« Reply #3 on: October 03, 2013, 12:09:36 am »
Just throwing this out there...  Have you tried running under compatibility mode?  Or run mame as an administrator.


Also make sure filter keys is not enabled...  http://windows.microsoft.com/en-ca/windows7/make-the-keyboard-easier-to-use


severdhed

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2975
  • Last login:December 14, 2024, 05:01:52 pm
  • RIP Dinosaur Hippo
Re: Autohotkey + mame + win 7 x64 = help!
« Reply #4 on: October 03, 2013, 12:49:59 pm »
i tried run as administrator, and compatibility mode for xp sp3, but it still does not work with mame.  i made sure filter keys were not enabled.

just for S&Gs, i found an old xp laptop, copied my mame folder and autohotkey scripts to it. installed autohotkey (from the same download i used on the windows 7 pc) and tried it, it worked just fine.  It almost has to be something different with directinput in xp vs windows 7.  This is related to which version of directx is installed, correct? 

do i maybe need to try a newer version of mame? or an older one?  i am running mame 124 right now, i'd like to stick with that if possible, since that is the romset i currently have.


i recompiled mame on my windows 7 pc, still no difference.  i dont know if compiling a 64bit version would help or not, i'm not sure how to do that with this old version of mame.
Current Projects:      Zak-Man | TMNT Pedestal | SNES Pi | N64 Odroid
Former Projects:     4 Player Showcase | Donkey Kong | iCade

severdhed

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2975
  • Last login:December 14, 2024, 05:01:52 pm
  • RIP Dinosaur Hippo
Re: Autohotkey + mame + win 7 x64 = GOT IT WORKING!!!
« Reply #5 on: October 03, 2013, 05:20:11 pm »
Ok, after a bunch  of messing around, i finally got this working!!!

i had to recompile mame, with a different tweak to the source code than i did for xp. 

the first time i did this years ago, it was with the help of nitz on the forums, i followed his instructions and they worked beautifully on xp..here is what i changed to the source code:

Navigate your way to C:\mamesrc\src\osd\windows\. Open the file input.c. If you double-click it, it should just open in notepad, if not, open it with notepad. Now, find the following text:

// initialize RawInput and DirectInput (RawInput first so we can fall back)
rawinput_init(machine);
dinput_init(machine);
win32_init(machine);

and change it to this:

// initialize RawInput and DirectInput (DirectInput first so we can fall back)
dinput_init(machine);
rawinput_init(machine);
win32_init(machine);


then compiled mame, with the hiscore nonag patch.

this DOES NOT WORK WITH WINDOWS 7 or 8 x64.

upon doing some searching, i stumbled across a thread on an xpadder forum, where they said to change a different value instead:

1) Edit \source\src\osd\windows\input.c (this is the first file named "input")
2) Replace the 0 in the following line with 1: #define FORCE_DIRECTINPUT   0


i then compiled it and it works!  i figured while i was at it, i figured out how to compile the 64bit version..so now i have a 64bit version of mame 124 with directinput support that works in 64bit versions of windows.

the only problem i ran into was i had to use a different key in my script..since mame was receiving the actual keypress, as well as the scripted keypress. i have to make it so that i am pressing a key that is not defined in mame, and then it sends one of two other keys, depending on how long it is pressed.

i am so happy about this, i can't wait to get home and try it out tonight.
Current Projects:      Zak-Man | TMNT Pedestal | SNES Pi | N64 Odroid
Former Projects:     4 Player Showcase | Donkey Kong | iCade

SgtSlaughter

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 81
  • Last login:March 02, 2021, 10:38:50 am
Re: Autohotkey + mame + win 7 x64 = SOLVED!
« Reply #6 on: October 03, 2013, 07:51:43 pm »
Glad you got it working.  I haven't built my machine yet, but most definitely will look at using this script, so thanks for posting it!