Main > Software Forum
Atari Jaguar I need an ESC Cab friendly emu hack Jcrouse or any one else?
<< < (2/3) > >>
Havok:

--- Quote from: headkaze on September 25, 2006, 09:48:57 pm ---Try this AutoIt script. I just wrote it so it's untested but it should work okay. Just replace emu.exe with the executable name of the Jaguar emulator, compile the script and place it into your emu's folder and run it instead of your emu's exe.


--- Code: ---; Basic AutoIt script to close an emulator using ESC

; Run the Emulator
Run(@ScriptDir & "\emu.exe");

; Define Kill Key
HotKeySet ("{ESCAPE}", "close_emu")

; Kill the Emulator
Func close_emu ()
ProcessClose ("emu.exe")
Exit
EndFunc

; Main Loop
While 1
Sleep (500)
If ProcessExists ('emu.exe') = 0 Then Exit
WEnd

Exit
--- End code ---

--- End quote ---

AutoIT - love it, use it all the time. Once I switched over to a company that wouldn't buy Winbatch for me, I switched over...
headkaze:
Ok thanks to our resident AutoIt expert Nologic over at the GameEx forums, he has revised my script to include a safer way of killing the emulator using the methods described by Howard as well as making use of variables to make it more readable. Thanks Nologic! :)


--- Code: ---; Basic AutoIt script to close an emulator using ESC

$Emu = 'Emu.exe'    ; EMU Executable
$Key = '{ESCAPE}'    ; Kill Key

; Run the Emulator
$pid = Run( @ScriptDir & '\' & $emu )

HotKeySet ( $Key , 'close_emu' )

; Kill the Emulator
Func close_emu ()
    If ProcessExists ( $pid ) = 0 Then Exit
    Send ( '{ALTDOWN}{F4}{ALTUP}' )
    Sleep (500)
    If ProcessExists ( $pid ) = 0 Then Exit
    WinClose ( $title )
    Sleep (500)
    If ProcessExists ( $pid ) = 0 Then Exit
    ProcessClose ( $pid )
    Exit
EndFunc

; Main Loop
While 1
    $title = WinGetTitle('')
    If ProcessExists ( $pid ) = 0 Then Exit
    Sleep (500)
WEnd

; EOF
--- End code ---
Howard_Casto:
Nice....

If I can figure out how to get autoit/ahk to read settings from text files I might start writing my wrappers in script form.  They can be compiled to exes and they don't need any dependancies, meaning they are a lot slimmer than anything you can do in a visual studio language.
Nologic:
Howard AutoIt can read from text files with no problem...tho I tend to use INI files. Any ways here is an old ZiNc wrapper that shows the basic reading from an INI file, and the reading of an INI thats been passed via commandline.


--- Code: ---#include <process.au3>

; Read ROM Pathing
$roms = IniRead( @ScriptDir & "\settings.ini", "ROMS", "PATH", @ScriptDir & "\ROMS\" )

; Read Game Related Settings
$ini_01 = IniRead( $CmdLine[1] , "GAM" , "Number" , "1" )
$ini_02 = IniRead( $CmdLine[1] , "CFG" , "Config" , "./Zinc.cfg" )
$ini_03 = IniRead( $CmdLine[1] , "CFG" , "Renderer" , "./renderer.cfg" )
$ini_04 = IniRead( $CmdLine[1] , "CFG" , "Controller" , "./controller.cfg" )
$ini_05 = IniRead( $CmdLine[1] , "GFX" , "Rotate" , "0" )
$ini_06 = IniRead( $CmdLine[1] , "GFX" , "Geometry" , "yes" )
$ini_07 = IniRead( $CmdLine[1] , "PLG" , "Controller" , "./controller.znc" )
$ini_08 = IniRead( $CmdLine[1] , "PLG" , "Renderer" , "./renderer.znc" )
$ini_09 = IniRead( $CmdLine[1] , "SND" , "Use" , "yes" )
$ini_10 = IniRead( $CmdLine[1] , "SND" , "Filter-Enable" , "yes" )
$ini_11 = IniRead( $CmdLine[1] , "SND" , "Filter-CutOff" , "44100" )
$ini_12 = IniRead( $CmdLine[1] , "SND" , "Lite-Enable" , "yes" )
$ini_13 = IniRead( $CmdLine[1] , "SND" , "Lite-Multiplier" , "40" )
$ini_14 = IniRead( $CmdLine[1] , "SND" , "Stereo-Exciter" , "yes" )
               

; Kill Emulator
Func end_session ()
ProcessClose( "ZiNc.exe" )
Exit
EndFunc

$game = @ScriptDir & '\ZiNc.exe ' & $ini_01 & _
' --roms-directory=' & $roms & _
' --controller=' & $ini_07 & _
' --renderer=' & $ini_08 & _
' --use-config-file=' & $ini_02 & _
' --use-renderer-cfg-file=' & $ini_03 & _
' --use-controller-cfg-file=' & $ini_04 & _
' --rotate=' & $ini_05 & _
' --use-slow-geometry=' & $ini_06 & _
' --use-sound=' & $ini_09 & _
' --sound-filter-enable=' & $ini_10 & _
' --sound-filter-cutoff=' & $ini_11 & _
' --sound-surround-lite-enable=' & $ini_12 & _
' --sound-surround-lite-multiplier=' & $ini_13 & _
' --sound-stereo-exciter=' & $ini_14

; Define Kill Key
HotKeySet( "{BACKSPACE}" , "end_session" )

; Launch Emulator
_RunDos ( $game )

; Time just keeps on slipping into the future :)
While 1
If ProcessExists ( 'ZiNc.exe' ) = 0 Then Exit
Sleep ( 500 )
WEnd

; EOF
--- End code ---
Howard_Casto:
I use ini files myself, so that works better actually.  Thanks for the snippet. 
Navigation
Message Index
Next page
Previous page

Go to full version