Now that xemu is better supported, I tried making the following useful ahk scripts for xemu that i think are general enough to be added as default settings (at least i hope so, dont want to accidentally delete them by pressing set to default).
It's my first time writing ahk scripts so feedback would be welcome - i'm a programmer and i found ahk to be so unintuitive to use, am i missing something? 😆
Save state script: Will go to your xemu log file to see what game has been started and then use the monitor window to set a game-specific snapshot. This is necessary because using hotkeys make system wide snapshots (not tied to the running game).
; Define the path to the log file
logFilePath := ".\Emulators\xemu\xemu.log"
; Read the contents of the log file into a string variable
FileRead, logContents, %logFilePath%
; Check if the file was successfully read
if (ErrorLevel)
{
MsgBox, Failed to get the filename! Check the install directory of xemu in the ahk script 'save state script'.
ExitApp
}
; Use regular expression to extract the string between the two delimiters
RegExMatch(logContents, "LaunchBox\\Games\\Microsoft Xbox\\(.*?).iso", extractedString)
; If a match is found, the result will be in extractedString1
if (extractedString)
{
filename := extractedString1 ; The captured match will be in extractedString1
;MsgBox, Extracted filename: %filename%
}
else
{
MsgBox, Could not obtain the filename, check the regex expression in the ahk script 'save state script'.
ExitApp
}
; Send ~ key (tilde key)
Send, {~ 1} ; this adds characters in monitor
Send, {Backspace 2} ;an extra one is sometimes needed..
; Wait a little to ensure the focus is ready
Sleep, 500
; Send the savevm command with the filename
Send, savevm "%filename%"" ; double quote can only be added twice or is not added at all..
Send, {Backspace 1} ;remove the extra double quote
; Send Enter key to execute the command
Send, {Enter}
Send, {~ 1}
Load state script: The same as above but using 'loadvm' instead of 'savevm'
Resume script: I (and many others) use the xbox guide button as pause menu, this will however open the xemu menu. So after resuming, esc is sent to close it. You can still open the xemu menu by pressing select+start. If you use a different way, not using the guide button, to open the pause menu, this hotkey will have not have an impact, it will not close the emulator.
; Send esc key to close the menu
Send, {esc}
Running script (not working): I first tried remapping the guide button to an alternative input which can also open the pause menu (here it is 'appskey'). This path didn't work however.. Any feedback would be welcome because this would prevent the xemu menu from opening in the first place.
;#Persistent ; Keep the script running
; Set up a timer to check if the target app is running
;SetTimer, CheckApp, 500 ; Check every 500ms
;CheckApp:
;if (GetKeyState("Joy11", "P"))
;{
;Remap the Xbox Guide button to send F12
;Send, {AppsKey}
;}