使用 AutoHotkey 在模拟器中启动游戏

Use AutoHotkey to launch a game in an emulator

我想创建一个 .ahk 脚本,用模拟器启动游戏。当模拟器打开时,它应该发送 F10 来加载保存状态,让我直接进入游戏菜单并跳转介绍。这是我到目前为止得到的:

Run, C:\Users\****\Documents\!Others\Emulators\SNES9x\snes9x-x64.exe -fullscreen "E:\Consoles\Nintendo SNES\Goof Troop\Goof Troop.smc"
Sleep, 100
IfWinExist ahk_class Snes9X: WndClass
{
    WinActivate
    WinWaitActive
    IfWinActive ahk_class Snes9X: WndClass
    Send, {F10}
    Return
}

我想确保 F10 在正确的时间发送。脚本应该先等待模拟器打开,我做的对吗?

我不知道该怎么做的另一件事是将 Xinput 转换为键盘,例如当我在游戏中并按 LB + RB + B 时,它会将其转换为 ALT+F4 并关闭 window,我该怎么做?

我的做法是,假设模拟器进程的名字是snes9x-x64.exe,那么

processName := "snes9x-x64.exe"
run %processName%
flag = 0

Loop
{
    WinGetTitle, title, ahk_exe %processName%
    IfWinActive, %title%
    {
        If flag = 0
        {
            Send, {F10}
            flag = 1
        }
    }
}

在这里,一旦模拟器打开,我们将检查 window 是否在循环中处于活动状态,然后发送 F10 并在 window 使用标志处于活动状态后停止循环。

对于 LB + RB + B,您必须使用像 xpadder 这样的键盘模拟器并将键 LB、RB 和 B 映射到键盘键并为其定义快捷方式。