Post subject: Here is a ahk script to Launch Snes9xrr with a lua script
Joined: 2/5/2014
Posts: 28
Since you guys have been helping me out so much I thought I better at least post something useful. The following auto hot key script (crudely) will launch snes9xrr, load up the script you specify and go to fullscreen. The command line options are as follows: snes9xlauncher.ahk "c:\path\to\rom\rom.zip" ".\script.lua" The paths MUST be in quotes and there shouldn't be any extra spaces.
IniWrite, FALSE, snes9x.cfg, Display\Win, Fullscreen:Enabled ;Ensure fullscreen is off
IniWrite,%2%, snes9x.cfg, Settings\Script, LastScriptFile ;Write to the ini file the lua script name

Run, snes9x.exe "%1%",,, PID ;Launch snes9x
WinWait ahk_pid %PID% ;Wait until emulator loads
sleep, 50
WinMenuSelectItem, ahk_class Snes9X: WndClass, , File, Lua Scripting, New Lua Script Window... ;Open lua dialog box
WinWait ahk_class #32770 ;Wait for the dialog to load

sleep 50

ControlClick, Run, Lua Script,,,, NA  ;Press the Run Button

 

sleep 50

WinMenuSelectItem, ahk_class Snes9X: WndClass, , Config, Video, Full Screen  ;Go to Full Screen mode

WinWaitClose ahk_pid %PID% ;Wait for exit.

IniWrite, FALSE, snes9x.cfg, Display\Win, Fullscreen:Enabled ;Set the fullscreen mode back to false.
Note that the script is designed to only work if you specify a lua script and the lua path must use lua-style path syntax if you are using a relative path. I hope someone finds this useful, and remember, 1.51 is the last revision of snes9xrr with proper lua implementation.
Former player
Joined: 2/19/2007
Posts: 424
Location: UK
On the linux version of snes9xrr, launching lua scripts directly from the command line is supported. There one does
snes9x rom -loadlua foo.lua
It also supports specifying a movie to play using the -autodemo argument, and one can also specify a maximum number of frames to run, and tell it to dump video and audio (-dumpstreams). This makes it suitable for automatic encodes, though some work is needed to get around it not supporting running headless (it needs to open up a graphical window). I fix that with Xvfb, which creates a fake graphical environment for snes9x to put its window in. With that in place (and a database mapping CRC to rom), encoding a smv file to h264 in mkv is as simple as doing "smvenc foo.smv foo.mkv". Not having a proper command line interface makes it difficult to automate things like that, so I hope that gets added to the windows version eventually. Especially since the linux version has its own slew of problems. In the absence of a built-in command line interface, your auto hot key script is a nice workaround. And it's surprisingly compact.
Joined: 2/5/2014
Posts: 28
Yeah it's not perfect though. Sometimes it doesn't quite hit the run button. I think I need to see if I can do that via a post message call, which would work regardless of the mouse. snes9x in general, not just the rr versions needs some work. It hasn't had a major overhaul in years. I think it's being phased out by bsnes and some of the newer ones, but it's a shame because I've been using it for almost a decade now. I'm actually having to use 1.51, because the windows version of 1.52 breaks a bunch of the lua calls. I thought of just submitting new source, but I really don't have the kind of time to setup the compile environment atm and I think the build is sort of dead atm anyway.
Joined: 2/5/2014
Posts: 28
Ok this version is slightly improved. I switched to using post message which in theory works better. I also increased the delays slightly. I've found getting these right is crucial to getting the Run button pressed properly. It's a balance really. With a long enough delay it'll work 100% of the time, but how long are you willing to wait?


IniWrite, FALSE, snes9x.cfg, Display\Win, Fullscreen:Enabled ;Ensure fullscreen is off
IniWrite,%2%, snes9x.cfg, Settings\Script, LastScriptFile ;Write to the ini file the lua script name

Run, snes9x.exe "%1%",,, PID ;Launch snes9x
WinWait ahk_pid %PID% ;Wait until emulator loads
sleep, 50
WinMenuSelectItem, ahk_class Snes9X: WndClass, , File, Lua Scripting, New Lua Script Window... ;Open lua dialog box
WinWait ahk_class #32770 ;Wait for the dialog to load

sleep 100



p := 5 << 16 | (5 & 0xffff)

PostMessage, 0x201 , 1, p,Run,Lua Script ; Click down on the Run Button
sleep 100
PostMessage, 0x202 , 1, p,Run,Lua Script
  ;Release the Run Button 
sleep 50

WinMenuSelectItem, ahk_class Snes9X: WndClass, , Config, Video, Full Screen  ;Go to Full Screen mode
WinWaitClose ahk_pid %PID% ;Wait for exit.

IniWrite, FALSE, snes9x.cfg, Display\Win, Fullscreen:Enabled ;Set the fullscreen mode back to false.