Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;This program will monitor mame64.exe title window to match the game name and run Ultimarcs joytray.exe to set either 4 way or 8 way controls
- ;;It also will kill mame64.exe after 3 min of inactivity
- ;;This was meant to be used in conjuction with launchbox/bigbox.
- ;;joycontrol.txt should be formatted like this line by line:
- ;;gamename,X
- ;;I.E: simpsons,8
- ;;Game name does not need to be exact, program will look for keywords. X should be either 4 or 8 to denote 4 or 8 way respectively
- ;;"C:\Programfiles\JoyTray whatever and where ever it installs to" from ultimarc should be set in windows PATH.
- #include <MsgBoxConstants.au3>
- #include <FileConstants.au3>
- #include <WinAPIFiles.au3>
- #include <File.au3>
- #include <Timers.au3>
- Opt("TrayAutoPause", 0)
- $file = "joycontrol.txt"
- FileOpen($file, 0)
- Local $iLength
- Local $set = 0
- While 1
- Local $hWnd = ("[CLASS:MAME]")
- Local $iPID = WinGetProcess($hWnd)
- Local $iIdleTime = _Timer_GetIdleTime()
- If $iIdleTime > 180000 And ProcessExists("mame64.exe") Then
- ProcessClose($iPID)
- EndIf
- If ProcessExists("mame64.exe") and $set = 0 Then
- $sMameWindowTitle = WinGetTitle('[CLASS:MAME]')
- SetMode()
- EndIf
- If Not ProcessExists("mame64.exe") Then
- HotKeySet("{ESC}", "disable_esc")
- $set = 0
- ConsoleWrite("Setting mode as unset" & @CRLF)
- Else
- HotKeySet("{ESC}")
- EndIf
- WEnd
- Func SetMode()
- For $i = 1 to _FileCountLines($file)
- $line = FileReadLine($file, $i)
- Local $iLength = StringLen($line)
- $sMameWindowTitleTrim = StringTrimRight($line, 2)
- $sSearch = StringinStr($sMameWindowTitle, $sMameWindowTitleTrim)
- if $sSearch > 0 Then
- Local $iLength = StringLen($line)
- $sRom = FileReadLine ($file, $i)
- Local $sMode = StringTrimLeft($sRom, ($iLength - 1))
- $set = 1
- ConsoleWrite("Setting mode as: " & $sMode)
- If $sMode = 4 Then
- Run(@ComSpec & ' /k ' & 'JoyTray.exe -servo joy4way',"",@SW_HIDE)
- EndIf
- If $sMode = 8 Then
- Run(@ComSpec & ' /k ' & 'JoyTray.exe -servo joy8way',"",@SW_HIDE)
- EndIf
- ExitLoop
- EndIf
- Next
- EndFunc
- func disable_esc()
- Send("")
- Sleep(100)
- EndFunc
- ;;True programmers don't comment their code
- ;;If it was hard to write, then it should be hard to read.
- ;;Also I'm lazy.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement