First post, by Stretch
Any ideas why this AutoIT script works properly with Dosbox and Doom2, but not Duke3d?
The script simulates keyboard presses, which I am using to record FM OPL to DRO files.
If I modify the script for Duke3d, ingame none of the keypresses register.
I tried Duke3d with Dos4/GW and Dos32a.
AutoIT script
#include <MsgBoxConstants.au3>Global $dosboxPath = "C:\Program Files (x86)\DOSBox-0.74\DOSBox.exe"; doom2.conf runs a batch file called d2vgm.batGlobal $dosboxConfig = "C:\temp\doom2.conf"; Length of each level in secondsGlobal $audioTrackLength = "C:\temp\audioTrackLength.txt"; Exit if required files not foundGlobal $fNameCheckDependency($dosboxPath)CheckDependency($dosboxConfig)CheckDependency($audioTrackLength); Run DosboxRun('"' & $dosboxPath & '"' & ' -conf ' & '"' & $dosboxConfig & '"'); Wait 3 seconds for Dosbox to loadGlobal $hWnd = WinWait("[CLASS:Dosbox]", "", 3)Sleep(3000); The main part of the scriptReadTextFile(); Quit if required files are not found; https://www.autoitscript.com/autoit3/docs/functions/FileExists.htmFunc CheckDependency($fName)Local $iFileExists = FileExists($fName)If Not $iFileExists ThenMsgBox($MB_SYSTEMMODAL, "", "The file " & $fName & " doesn't exist." & @CRLF & "FileExist returned: " & $iFileExists)Exit 1EndIfEndFunc; https://www.autoitscript.com/forum/topic/111408-read-text-file-line-by-line/; Script from user MHzFunc ReadTextFile(); open file to read and store the handle$handle_read = FileOpen($audioTrackLength, 0); check the handle is validIf $handle_read = -1 Then; show warning and exit with code 1MsgBox(0, @ScriptName, 'failed to open handle to read the file')Exit 1EndIf; loop through each line of the fileWhile 1; read each line from a file$line_read = FileReadLine($handle_read); exit the loop if end of fileIf @error Then ExitLoop; Add 5 seconds; And multiply by 1000 for Sleep functionIf $line_read > 1 ThenLocal $strTrackLength = Number(($line_read + 5) * 1000)ElseContinueLoopEndIf
; Activate the Dosbox window using the handle returned by WinWait.WinActivate($hWnd)Sleep(200); Begin VGM RecordingSend("^!{F7}")Sleep(2000); Exit pause command in batch fileSend("ENTER"); Wait for level to loadSleep(8000); God mode idkfa; change to dnkroz for duke3dSend("idkfa"); Sleep for the length of the track read from fileSleep($strTrackLength); Exit Doom - Escape, Up, Enter, ySend("{ESCAPE}")Sleep(1000)Send("{UP}")Sleep(1000)Send("{ENTER}")Sleep(1000)Send("y"); Uncomment for Duke3d; Sleep(2000);; Send("{ENTER}"); Wait for game to exit to command promptSleep(4000); End VGM RecordingSend("^!{F7}")Sleep(2000)WEnd; close the file handle for readFileClose($handle_read)EndFunc
d2vgm.bat
@echo offREM For WAD games like Doom and Doom2SET DMXOPTION=-opl3-phaseREM DOOM.exe -opl3 -phase -warp 1 1 -nomonsters -nosfxREM DOOM2.EXE -opl3 -phase -warp 01 -nomonsters -nosfxREM duke3d.exe /m /ns /v1 /l1pauseDOOM2.EXE -opl3 -phase -warp 01 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 02 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 03 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 04 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 05 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 06 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 07 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 08 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 09 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 10 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 18 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 20 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 23 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 25 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 28 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 30 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 31 -nomonsters -nosfxpauseDOOM2.EXE -opl3 -phase -warp 32 -nomonsters -nosfxREM FreeDOS sleepsleep.exe 5exit
AudioTrackLength.txt doom2
230292230155259417257300279263306279991152822797279
d3dvgm.bat
@echo offpauseduke3d.exe /m /ns /v1 /l1pauseduke3d.exe /m /ns /v1 /l2pauseduke3d.exe /m /ns /v1 /l3pauseduke3d.exe /m /ns /v1 /l4pauseduke3d.exe /m /ns /v1 /l5pauseduke3d.exe /m /ns /v1 /l6pauseduke3d.exe /m /ns /v1 /l7pauseduke3d.exe /m /ns /v2 /l1pauseduke3d.exe /m /ns /v2 /l2pauseduke3d.exe /m /ns /v2 /l3pauseduke3d.exe /m /ns /v2 /l4pauseduke3d.exe /m /ns /v2 /l5pauseduke3d.exe /m /ns /v2 /l6pauseduke3d.exe /m /ns /v2 /l7pauseduke3d.exe /m /ns /v2 /l8pauseduke3d.exe /m /ns /v2 /l9pauseduke3d.exe /m /ns /v2 /l10pauseduke3d.exe /m /ns /v2 /l11pauseduke3d.exe /m /ns /v3 /l1pauseduke3d.exe /m /ns /v3 /l2pauseduke3d.exe /m /ns /v3 /l3pauseduke3d.exe /m /ns /v3 /l4pauseduke3d.exe /m /ns /v3 /l5pauseduke3d.exe /m /ns /v3 /l6pauseduke3d.exe /m /ns /v3 /l7pauseduke3d.exe /m /ns /v3 /l8pauseduke3d.exe /m /ns /v3 /l9pauseduke3d.exe /m /ns /v3 /l10pauseduke3d.exe /m /ns /v3 /l11
pauseduke3d.exe /m /ns /v4 /l1pauseduke3d.exe /m /ns /v4 /l2pauseduke3d.exe /m /ns /v4 /l3pauseduke3d.exe /m /ns /v4 /l4pauseduke3d.exe /m /ns /v4 /l5pauseduke3d.exe /m /ns /v4 /l6pauseduke3d.exe /m /ns /v4 /l7pauseduke3d.exe /m /ns /v4 /l8pauseduke3d.exe /m /ns /v4 /l9pauseduke3d.exe /m /ns /v4 /l10pauseduke3d.exe /m /ns /v4 /l11sleep.exe 5exit
audiotracklength.txt duke3d
164242359353353376103201315232146185311195147184153165246254334394289158401379161251220179190130217185212213193281200172
Win 11 - Intel i7-1360p - 32 GB - Intel Iris Xe - Cubilux 7.1 USB