Jump to content
LaunchBox Community Forums

Windowcast RetroArch core configuration?


Recommended Posts

Posted

This core: https://forums.libretro.com/t/official-release-thread-for-windowcast-core/40464

So basically it allows any standalone game and emulators to work within RA, so you can use its shaders.

In my setup on LB, I used RA on emulator, path to .txt and the game as an addition app to start before RA.

It kind of works, but the game window starts on top of RA and I cound't find a way to exit both by pressing esc. I think it would be ideal to have a bit of delay to start RA. So, any suggestions?

  • 5 months later...
Posted

I've been playing with this a couple times now and it's rather experimental as the dev says. Awesome idea, but still very much a WIP. They have mostly great notes on how to setup and use it, but for the life of me why the hell they didn't include the oh so mandatory setting of making Retroarch not pause when the window is not active in these notes is beyond me! I had to read through the libretro thread to find others talking about it. Makes sense, obviously, that it is req, but that was something that slipped through the cracks.

My main gripe is it doesn't seem to work with putting Retroarch in fullscreen. Doesn't matter if it's exclusive or windowed fullscreen or if I used the software or vulkan version. When you use the CTRL+ALT+T shortcut it plops the game window ON TOP of Retroarch. When in fullscreen if the game window is not on top, inputs will not be detected at all. So I must resort to only using Retroarch in a window and this is not desirable, at all. You are stuck seeing the title menu and file menu and Windows system tray on the display.

 

Started farting around with an AHK script tonight to change the window style of Retoarch, removing the title and file menu, it's borders, resizing the window , and hiding the system tray. This works as I hoped it would and doesn't mess up behavior with this core! But I'm just not getting how some other users say fullscreen works fine.....seems "YMMV" kinda thing. I'm one of the unlucky ones who cannot use fullscreen. They are aware of the issue, but seem to think it's just a Nvidia issue as they advise on changing a setting in the Nvidia control panel. I'm on an AMD card so not sure if that is why I have the problem. There is no equivalent setting in Radeon Settings for me to change.....or so I thought. (as I type this....I search for the equivalent setting with google) I found this thread and seemed hopeful but I didn't find any difference when toggling this setting "OpenGL Triple Buffering" and thought I was out of luck.....or so I thought again! I found a workaround thanks to this response from one of the AMD team

Quote

"Currently, DXGI support for Vulkan is enabled by default for specific features. However, end-users are not allowed to control this functionality. It will be enabled by default eventually.

Users can turn it on by enabling the OS HDR mode with a HDR capable display."

https://community.amd.com/t5/opengl-vulkan/dxgi-swapchain-on-opengl-and-vulkan-games/m-p/578792

 

LMAO holy cow! TURNING ON HDR ALLOWS ME TO USE FULLSCREEN PROPERLY WITH THIS CORE! This must be one of the weirdest workarounds I've stumbled onto. I know this will not help users without a HDR capable display but it's an option to try if you have the means. Little weird it's working like this as another post from them implies these settings about "DXGI support" should be enabled by default, but it sure isn't working for me without enabling HDR. Though I see their post date is from 12/7/23 and my AMD GPU drivers are v23.8.2 so I will need to update to the latest 24.4.1 version and see if that makes a difference! Fingers crossed!🤞

 

Then I just need to automate the LB/BB launching process. Once I iron it all out, I can share my experience and methods to get all this working.

Posted (edited)

Gloomy rainy Sunday here in my neck of the woods. Perfect time to tackle this project. Unfortunately updating to latest AMD GPU drivers did not help me one way or the other. I still cannot use WindowCast core and put Retroarch in fullscreen unless I have HDR enabled in Windows Display Settings. So I played with a script that can handle launching it both ways, with or w/o HDR enabled

Since I assume users would be like me and already have games imported, I wanted to design a script to work with everything configured as it currently is. No need to edit game entries and the like. I tested mainly with native Windows games, those being Streets of Rage 4, Raiden III, Dead Cells, Ninja Gaiden Sigma 2, Andro Dunos II, and Natsuki Chronicles. Tried some other emulators like Dolphin and Yuzu and didn't find a different experience there. Same things went good or poor.

The bad part is more I use this the more I run into random issues. Stuff that results in it just booting to white screen and do nothing. Or maybe Retoarch opens to the point you see its taskbar icon but then no window appears. Playing a video in VLC or just having Firefox open results in funny business like that. I know that is not a normal use case, but I usually have other stuff going on as I test stuff like this so that's how that came about. Randomly I'll get some weird artifacting and inputs will not be recognized. But this all seems on par with something experimental and in progress. I didn't really notice any lag or stuttering or FPS loss. That stuff only seems to get introduced depending on how crazy you go with implementing Mega Bezels which I assume is why anyone would want to use this core in the first place. And that's really the shader's fault, not the core.

On the good side, when it works, it works well. Every game and emulator I tried worked. A couple games needed additional means to work well and I'll mention that later. Lots of great shader options out there to use, I didn't run into issue trying any certain one. They all seemed to work as expected.

Some bits I notice is the text file is interpreted as case insensitive and I did test every game I tried with both their window title and exe file name. Only one did not work with the exe file name, that was Streets of Rage 4. Booted, but just a white screen (made sure it was not due to above bug of having other stuff open). If I use its window title it works fine. So that was an outlier. With that in mind I thought I would design my scripts to be case insensitive too in order for it to properly use this file for window or exe file names.

 

Here is what I come up for me launching with HDR enabled. This will launch Retroarch into fullscreen. Users copying this will need to adjust RetroarchEXE and WindowCastFile variables to the correct path where they are stored on your system. Optionally you could also adjust TimeOutDelay, RunRetroarchDelay, and FocusHotkeyDelay if needed.

It's going to make use of the file you put the window title or game exe name in. When the script starts it's looking for one of these windows or processes to exist before continuing. If it takes too long (10 secs), it will timeout and a message box will pop up to tell you script is terminating.  Once the window is found it's going to launch Retroarch and then use the CTRL+ALT+T hotkey to push focus to the game so inputs are detected. Then it's going to wait for the game/emulator to close before closing Retroarch and exiting the script. Escape is also a hotkey to close Retroarch.

Spoiler
SetWorkingDir, % A_ScriptDir
SetTitleMatchMode, RegEx    ; seems to work like mode 2 (partial match) but allows for use of expressions
RetroarchWinTitle := "ahk_exe retroarch.exe"
RetroarchEXE := "..\..\..\Emulators\Retroarch\retroarch.exe"
WindowCastFile := "..\..\..\ROMS\WindowCast\WindowCast.txt"
WindowCastListArray := []
TimeOutDelay := 10000       ; close script if game/emulator window is not found in X seconds
RunRetroarchDelay := 1500   ; delay between finding game/emulator window and then opening Retroarch
FocusHotkeyDelay := 2000    ; delay between launching Retroarch and sending hotkey to grab focus of game/emulator window. *HDR/Fullscreen method ONLY*

; Read WindowCast window list file and parse into array
FileRead, WindowCastList, %WindowCastFile%
Loop, Parse, WindowCastList, `r, `r`n 
{
    If (InStr(A_LoopField, "#"))
        Continue
    WindowCastListArray.Push(A_LoopField)
}

; Loop through list to check which window exists
InitialTime := A_TickCount
WindowCheck:
Loop, % WindowCastListArray.Count() {
    ; Check if entry is an exe
    If (InStr(WindowCastListArray[A_Index], ".exe")) {
        If (WinExist("ahk_exe " . "i)" . WindowCastListArray[A_Index])) {
            ExistingWindow := WindowCastListArray[A_Index]
            Break
        }    
    }
    ; If entry is not an exe, it is a window title
    Else If (WinExist("i)" . WindowCastListArray[A_Index])) {
        ExistingWindow := WindowCastListArray[A_Index]
        Break
    }
    DurationTime := A_TickCount - InitialTime
    If (DurationTime >= TimeOutDelay) {
        MsgBox, 4096, Window Check Timeout, Couldn't find existing window. Exiting script!
        ExitApp
    }
}
If (ExistingWindow = "")
    Goto, WindowCheck

Sleep, RunRetroarchDelay
Run, %RetroarchEXE% -L wgc_libretro.dll %WindowCastFile% -f
WinWait, % RetroarchWinTitle
Sleep, % FocusHotkeyDelay
; Sends hotkey to give focus to game window so inputs are detected
Send {LCtrl down}{LAlt down}{t down}{t up}{LAlt up}{LCtrl up}
If (InStr(ExistingWindow, ".exe")) 
    WinWaitClose, % "ahk_exe" . "i)" . ExistingWindow
Else
    WinWaitClose, % "i)" . ExistingWindow
WinClose, % RetroarchWinTitle
ExitApp

; Hotkey to exit Retroarch and terminate script
$Esc:: ; keyboard modifier ($) is needed so input isn't "eaten" by the game
WinClose, % RetroarchWinTitle
ExitApp

 

 

 

 

 

Same thing but this is how I first had to think about stuff if I am in SDR mode. If you have issues like me with putting Retroarch into fullscreen with this core and do not have the option of using HDR then you will want to use this version. What is different here is changing window style of Retroarch so it takes up your whole screen without the system thinking it's in fullscreen mode.

Spoiler
SetWorkingDir, % A_ScriptDir
SetTitleMatchMode, RegEx    ; seems to work like mode 2 (partial match) but allows for use of expressions
RetroarchWinTitle := "ahk_exe retroarch.exe"
RetroarchEXE := "..\..\..\Emulators\Retroarch\retroarch.exe"
WindowCastFile := "..\..\..\ROMS\WindowCast\WindowCast.txt"
WindowCastListArray := []
TimeOutDelay := 10000       ; close script if game/emulator window is not found in X seconds
RunRetroarchDelay := 1500   ; delay between finding game/emulator window and then opening Retroarch

; Read WindowCast window list file and parse into array
FileRead, WindowCastList, %WindowCastFile%
Loop, Parse, WindowCastList, `r, `r`n 
{
    If (InStr(A_LoopField, "#"))
        Continue
    WindowCastListArray.Push(A_LoopField)
}

; Loop through list to check which window exists
InitialTime := A_TickCount
WindowCheck:
Loop, % WindowCastListArray.Count() {
    ; Check if entry is an exe
    If (InStr(WindowCastListArray[A_Index], ".exe")) {
        If (WinExist("ahk_exe " . "i)" . WindowCastListArray[A_Index])) {
            ExistingWindow := WindowCastListArray[A_Index]
            Break
        }    
    }
    ; If entry is not an exe, it is a window title
    Else If (WinExist("i)" . WindowCastListArray[A_Index])) {
        ExistingWindow := WindowCastListArray[A_Index]
        Break
    }
    DurationTime := A_TickCount - InitialTime
    If (DurationTime >= TimeOutDelay) {
        MsgBox, 4096, Window Check Timeout, Couldn't find existing window. Exiting script!
        ExitApp
    }
}
If (ExistingWindow = "")
    Goto, WindowCheck

Else {
    Sleep, % RunRetroarchDelay
    Run, %RetroarchEXE% -L wgc_libretro.dll %WindowCastFile%
    WinWait, % RetroarchWinTitle
    WinSet, Style, -0x40000, %RetroarchWinTitle%                    ; removes sizing borders
    WinSet, Style, -0xC00000, %RetroarchWinTitle%                   ; removes title bar
    DllCall("SetMenu", uint, WinActive(RetroarchWinTitle), uint, 0) ; removes file menu bar
    WinHide, ahk_class Shell_TrayWnd                                ; hides system tray
    ; cannot use exact screen dimensions or else it acts just like normal fullscreen
    ; normal fullscreen can make the game image freeze in Retroarch
    ; add +1 to width so it is not considered true fullscreen
    WinMove, %RetroarchWinTitle%, , 0, 0, % A_ScreenWidth + 1, %A_ScreenHeight%
}
; Sends hotkey to give focus to game window so inputs are detected
Send {LCtrl down}{LAlt down}{t down}{t up}{LAlt up}{LCtrl up}
If (InStr(ExistingWindow, ".exe")) 
    WinWaitClose, % "ahk_exe" . "i)" . ExistingWindow
Else
    WinWaitClose, % "i)" . ExistingWindow
WinClose, % RetroarchWinTitle
WinShow, ahk_class Shell_TrayWnd
ExitApp

; Hotkey to exit Retroarch, show Windows system tray, and terminate script
$Esc:: ; keyboard modifier ($) is needed so input isn't "eaten" by the game
WinClose, % RetroarchWinTitle
WinShow, ahk_class Shell_TrayWnd
ExitApp

 

 

 

 

For anyone who wants to automate that, here is what I'm employing in a single script. It's detecting if HDR is enabled or not. You will need to get the proper registry address yourself which is going to be specific to your system's display.  I have a main system in my computer room and a HTPC in the living room so this is why I have a line checking which computer is running but I haven't bothered to get the address for the other display yet.

Spoiler
SetWorkingDir, % A_ScriptDir
SetTitleMatchMode, RegEx    ; seems to work like mode 2 (partial match) but allows for use of expressions
RetroarchWinTitle := "ahk_exe retroarch.exe"
RetroarchEXE := "..\..\..\Emulators\Retroarch\retroarch.exe"
WindowCastFile := "..\..\..\ROMS\WindowCast\WindowCast.txt"
WindowCastListArray := []
TimeOutDelay := 10000       ; close script if game/emulator window is not found in X seconds
RunRetroarchDelay := 1500   ; delay between finding game/emulator window and then opening Retroarch
FocusHotkeyDelay := 2000    ; delay between launching Retroarch and sending hotkey to grab focus of game/emulator window. *HDR/Fullscreen method ONLY*

; Read WindowCast window list file and parse into array
FileRead, WindowCastList, %WindowCastFile%
Loop, Parse, WindowCastList, `r, `r`n 
{
    If (InStr(A_LoopField, "#"))
        Continue
    WindowCastListArray.Push(A_LoopField)
}

; Loop through list to check which window exists
InitialTime := A_TickCount
WindowCheck:
Loop, % WindowCastListArray.Count() {
    ; Check if entry is an exe
    If (InStr(WindowCastListArray[A_Index], ".exe")) {
        If (WinExist("ahk_exe " . "i)" . WindowCastListArray[A_Index])) {
            ExistingWindow := WindowCastListArray[A_Index]
            Break
        }    
    }
    ; If entry is not an exe, it is a window title
    Else If (WinExist("i)" . WindowCastListArray[A_Index])) {
        ExistingWindow := WindowCastListArray[A_Index]
        Break
    }
    DurationTime := A_TickCount - InitialTime
    If (DurationTime >= TimeOutDelay) {
        MsgBox, 4096, Window Check Timeout, Couldn't find existing window. Exiting script!
        ExitApp
    }
}
If (ExistingWindow = "")
    Goto, WindowCheck

; Check if HDR is enabled
; Read HDR status in registry
If (A_ComputerName = "DESKTOP-Z390") {
    RegRead, REG_DWORD, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\MonitorDataStore\SAM713F16780800_01_07E5_37, AdvancedColorEnabled
}
Else If (A_ComputerName = "DESKTOP-B760") {
    ; NEED TO GET PROPER REGISTRY ADDRESS FOR HTPC DISPLAY!
    ; RegRead, REG_DWORD, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\MonitorDataStore\SAM713F16780800_01_07E5_37, AdvancedColorEnabled
}

; #########################################################################################
; HDR VERSION: Runs in Retroarch fullscreen mode
; #########################################################################################
If (REG_DWORD = 1) {
    Sleep, RunRetroarchDelay
    Run, %RetroarchEXE% -L wgc_libretro.dll %WindowCastFile% -f
    WinWait, % RetroarchWinTitle
    Sleep, % FocusHotkeyDelay
}
; #########################################################################################
; SDR VERSION: Runs Retroarch in window mode, change its window style, and hide system tray
; #########################################################################################
Else {
    Sleep, % RunRetroarchDelay
    Run, %RetroarchEXE% -L wgc_libretro.dll %WindowCastFile%
    WinWait, % RetroarchWinTitle
    WinSet, Style, -0x40000, %RetroarchWinTitle%                    ; removes sizing borders
    WinSet, Style, -0xC00000, %RetroarchWinTitle%                   ; removes title bar
    DllCall("SetMenu", uint, WinActive(RetroarchWinTitle), uint, 0) ; removes file menu bar
    WinHide, ahk_class Shell_TrayWnd                                ; hides system tray
    ; cannot use exact screen dimensions or else it acts just like normal fullscreen
    ; normal fullscreen can make the game image freeze in Retroarch
    ; add +1 to width so it is not considered true fullscreen
    WinMove, %RetroarchWinTitle%, , 0, 0, % A_ScreenWidth + 1, %A_ScreenHeight%
}
; Sends hotkey to give focus to game window so inputs are detected
Send {LCtrl down}{LAlt down}{t down}{t up}{LAlt up}{LCtrl up}
If (InStr(ExistingWindow, ".exe")) 
    WinWaitClose, % "ahk_exe" . "i)" . ExistingWindow
Else
    WinWaitClose, % "i)" . ExistingWindow
WinClose, % RetroarchWinTitle
WinShow, ahk_class Shell_TrayWnd
ExitApp

; Hotkey to exit Retroarch, show Windows system tray, and terminate script
$Esc:: ; keyboard modifier ($) is needed so input isn't "eaten" by the game
WinClose, % RetroarchWinTitle
WinShow, ahk_class Shell_TrayWnd
ExitApp

 

 

 

For emulators I put in the Running Script field a Run command for this WindowCast script. For ex

Run, ..\..\Utilities\Scripts\WindowCast\WindowCast.ahk

 

For native Windows games I mainly use scripts to launch them, so in those scripts I can add a line to run the WindowCast script (basically same as above) or you can add the WindowCast script as an Additional Application and check Automatically Run Before Main Application

 

 

 

When testing Andro Dunos II this game forcefully runs in fullscreen mode much like a game from it's original era, ya know the 90's. So I just used DxWnd for the first time to force it into a window mode and that was a super easy experience. The included help files by means of a local html files helps explained how to use it perfectly. I had to use this program in order to make use of WindowCast with Andro Dunos II.

Another one that needed (maybe subjective) unique care was Streets of Rage 4. When in window mode it defaults to a small window and does not remember its window size between launches. It looks way too pixelated at this small window size all scaled up to 4K so I had to get a better image quality here. Simply maximizing the game window still leaves letter boxing because for whatever reason they didn't make window size default to a 16:9 aspect ratio but the game itself maintains aspect ratio...hence black bars will appear if it's not exact 16:9. I figure using WinMove commands would help and they do move and resize it just fine, but the game doesn't seem to actually update it's render output unless you adjust the window via its borders. As in you must grab the borders via the mouse to get resolution to change. So I had to add a bit for this game to make the game window always on top and then automate moving the mouse to click and drag the window size to be bigger, then immediately tell it to not always be on top. So the launching looks a little goofy seeing the window for a split sec and it grows at that too but the end result is a much better looking game! In the end I had to make a special script with a few extra lines in it just for this one game due to this. Here is that extra bit

Spoiler
; Resize game window via mouse grabbing the border
; Using maximize button still leaves letter boxing
; Using WinMove commands or WinMaximize commands does not update rendering resolution
Sleep, % ResizeDelay
WinHide, ahk_class Shell_TrayWnd                            ; hides system tray
WinSet, Style, -0xC00000, % "i)" . ExistingWindow           ; removes title bar
WinMove, % "i)" . ExistingWindow, , 0, 0                    ; moves game window to top left corner
WinSet, AlwaysOnTop, On, % "i)" . ExistingWindow            ; put game window on top in order to resize with the mouse
MouseClickDrag, Left, 810, 515, 3760, 2115                  ; resize for higher resolution and specific coordinates are to maintain 16:9 aspect ratio
WinSet, AlwaysOnTop, Off, % "i)" . ExistingWindow

 

 

One thing I left less than optimized was I couldn't get rid of all the file menu and bottom message center in Yuzu's UI. So I instead opt to crop that portion off with the shader used in Retroarch. I will try and play with stuff like this more to see if I cannot get that removed. Title bar (yellow highlight) removes OK, as do the borders, but file menu doesn't and who knows about the bottom one.

Yuzu.thumb.PNG.e733c8c5934bf4e45aee03ba05302b87.PNG

 

 

 

Here are some examples of the final result in action! I got some mods going in in NGS2 so it works more like the original version with dismembering limbs and all the bloody gore that was taken out so it could run on the PS3. I'm running the Master Collection version on Steam.

SOR4.thumb.png.ea571d32f996bc4425b022a1e89690f6.png

NinjaGaidenSigmaII.thumb.png.fc46f390afd9865ec9f4a37b699be789.png

AndroDunosII.thumb.png.3adb499284f0fef3aaa567b1078072b6.png

NatsukiChronicles.thumb.png.c9d76bce35ac600a015098d0cf7f0b10.png

You have no idea how hard it is to take a screen shot in a shoot 'em up and not die lol

Edited by skizzosjt
  • 11 months later...
Posted (edited)

Hey man,

I'm trying to get this ahk working in Launchbox. I copied your script in a txt document and saved it as WindowCast.ahk. I added my paths like so:

RetroarchEXE := "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe"
WindowCastFile := "M:\WindowCast\WindowCast.txt"

I put the file in M:\Launchbox\Utilities\Scripts\WindowCast and in Manage Emulators for Xemu I added in the running script section: Run, M:\Launchbox\Utilities\Scripts\WindowCast\WindowCast.ahk

However when I launch a game, Xemu starts like normal, but Retroarch never launches. So Am I doing something wrong here? (I of course tried WindowCast before from Retroarch and it works fine there.)

Can you help me?


EDIT: When first trying this, Windows asked me which program I wanted to use for .ahk files. I chose M:\Launchbox\ThirdParty\AutoHotkey\AutoHotkey.exe

I assume this was correct?

 

Edited by SiriusVI
Posted
8 hours ago, SiriusVI said:

Hey man,

I'm trying to get this ahk working in Launchbox. I copied your script in a txt document and saved it as WindowCast.ahk. I added my paths like so:

RetroarchEXE := "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe"
WindowCastFile := "M:\WindowCast\WindowCast.txt"

I put the file in M:\Launchbox\Utilities\Scripts\WindowCast and in Manage Emulators for Xemu I added in the running script section: Run, M:\Launchbox\Utilities\Scripts\WindowCast\WindowCast.ahk

However when I launch a game, Xemu starts like normal, but Retroarch never launches. So Am I doing something wrong here? (I of course tried WindowCast before from Retroarch and it works fine there.)

Can you help me?


EDIT: When first trying this, Windows asked me which program I wanted to use for .ahk files. I chose M:\Launchbox\ThirdParty\AutoHotkey\AutoHotkey.exe

I assume this was correct?

 

 

sure thing mang

Xemu might be some funny business here. I didn't previously test it. I did get it to work right now but it wasn't very automated. I had to use keyboard/mouse to ALT+TAB to the actual emulator window, mouse click into the emulator window, and then ALT+TAB back to the Retroarch window, and THEN use the CTRL+ALT+T hotkey (the WindowCast specific hotkey to change window/control focus) to get the darn window to focus for controls to work. Also seems how this emulator renders affects how a shader would be applied. for ex, I'm not sure why the heck there are black bars on the side here. It's effectively cropping the image used for the shader as this image is 16:9 ratio so should cover edge to edge. aspect ratio is correct, but it's getting cropped. First emulator I've seen do this to me.

 

*further testing proves the keyboard is not sufficient to get proper window and controls focus. for ex, I can launch the game/emulator and then the script and I get no controls in game. I can still see the mouse cursor so I do a normal left mouse click where I know the actually emulator window is and now I have controls. so, seems like Xemu doesn't give controls unless it is first put into focus that way.....would require different methods to make this wholly automated

 

image.thumb.png.5010f5d7230fd5f66fce4cd0bcd73da9.png

 

Doesn't sound like you did any redflag wrong moves. for the AHK question that is what Windows calls file extension association. You must have never opened an .ahk straight from Windows Explorer so it didn't know what program to use to open it. It needed to be directed to the main AutoHotkey.exe file in order to run .ahk files. You got that right. Doesn't matter if you use the exe included with LB or if you setup AHK yourself and placed it wherever you wanted. It will remember that going forward so should be a set it and forget it thing

 

clarify for me, this works for you if you launch an Xemu game manually, and then launch Retroarch manually and load the WindowCast core manually? if so, we at least know you got the WindowCast.txt file with proper name in there

 

Note the game/emulator window should be a window rather than fullscreen. Actual window, not a borderless fullscreen window.  I do not have the full screen command used for Xemu here.

image.thumb.png.47ddf7f60b8080903d46ca98307209db.png

 

Running the script should be first line in the running script field to make sure it executes. if you put it below something like a hotkey or a WinWait command it may never make it to the Run command line. I wonder if this is the issue for you?

image.thumb.png.71564030a87491e727f7856a334839f6.png

 

further testing if you're still getting stuck.....

launch Xemu manually. from what I can tell the last loaded game should boot up automatically. so at this point you should be running Xemu and booted into a game and it should be in a window mode

next, manually run the WindowCast.ahk script from Windows Explorer. it should work fine like this. if it doesn't it could be something is not configured right in the script for you

 

 

if it's not working at this point you should check the AHK tray icon and review the lines of code that have been executed. I would suspect either the script is exiting too soon for some currently unknown reason or some configuration or typo kinda issue. reviewing the lines executed will let us know what ran and where it's stuck if it is stuck. post an image of that window if needed

 

 

 

 

come back with how you make out and we'll go from there!

Posted (edited)
4 hours ago, skizzosjt said:

 

sure thing mang

Xemu might be some funny business here. I didn't previously test it. I did get it to work right now but it wasn't very automated. I had to use keyboard/mouse to ALT+TAB to the actual emulator window, mouse click into the emulator window, and then ALT+TAB back to the Retroarch window, and THEN use the CTRL+ALT+T hotkey (the WindowCast specific hotkey to change window/control focus) to get the darn window to focus for controls to work. Also seems how this emulator renders affects how a shader would be applied. for ex, I'm not sure why the heck there are black bars on the side here. It's effectively cropping the image used for the shader as this image is 16:9 ratio so should cover edge to edge. aspect ratio is correct, but it's getting cropped. First emulator I've seen do this to me.

 

*further testing proves the keyboard is not sufficient to get proper window and controls focus. for ex, I can launch the game/emulator and then the script and I get no controls in game. I can still see the mouse cursor so I do a normal left mouse click where I know the actually emulator window is and now I have controls. so, seems like Xemu doesn't give controls unless it is first put into focus that way.....would require different methods to make this wholly automated

 

image.thumb.png.5010f5d7230fd5f66fce4cd0bcd73da9.png

 

Doesn't sound like you did any redflag wrong moves. for the AHK question that is what Windows calls file extension association. You must have never opened an .ahk straight from Windows Explorer so it didn't know what program to use to open it. It needed to be directed to the main AutoHotkey.exe file in order to run .ahk files. You got that right. Doesn't matter if you use the exe included with LB or if you setup AHK yourself and placed it wherever you wanted. It will remember that going forward so should be a set it and forget it thing

 

clarify for me, this works for you if you launch an Xemu game manually, and then launch Retroarch manually and load the WindowCast core manually? if so, we at least know you got the WindowCast.txt file with proper name in there

 

Note the game/emulator window should be a window rather than fullscreen. Actual window, not a borderless fullscreen window.  I do not have the full screen command used for Xemu here.

image.thumb.png.47ddf7f60b8080903d46ca98307209db.png

 

Running the script should be first line in the running script field to make sure it executes. if you put it below something like a hotkey or a WinWait command it may never make it to the Run command line. I wonder if this is the issue for you?

image.thumb.png.71564030a87491e727f7856a334839f6.png

 

further testing if you're still getting stuck.....

launch Xemu manually. from what I can tell the last loaded game should boot up automatically. so at this point you should be running Xemu and booted into a game and it should be in a window mode

next, manually run the WindowCast.ahk script from Windows Explorer. it should work fine like this. if it doesn't it could be something is not configured right in the script for you

 

 

if it's not working at this point you should check the AHK tray icon and review the lines of code that have been executed. I would suspect either the script is exiting too soon for some currently unknown reason or some configuration or typo kinda issue. reviewing the lines executed will let us know what ran and where it's stuck if it is stuck. post an image of that window if needed

 

 

 

 

come back with how you make out and we'll go from there!

Hey thx for replying. Did some further testing:

Manually starting Xemu and then manually launching WindowCast works.

Launching this ahk script also launches retroarch:  Run, "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe"

This ahk script just freezes retroarch and I have to terminate the process: Run, "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe" -L wgc_libretro.dll "M:\WindowCast\WindowCast.txt"

I also get the freeze when just trying to launch this via CMD. I can see that WindowCast is trying to capture the Xemu window (yellow outlines aroundthe game window), but Retroarch crashes. Same behavior with Dolphin. 

Again, running windowcast manually works perfectly.

EDIT:

I think I got it. It's Gsync. If Gsync is enabled in RetroArch, CMD and AHK crash Retroarch during the window capture. If it's disabled it works.

But again, when manaully starting WindowCast, it works fine, even wuth Gsync enabled.

Edited by SiriusVI
  • Game On 1
Posted
5 hours ago, SiriusVI said:

Hey thx for replying. Did some further testing:

Manually starting Xemu and then manually launching WindowCast works.

Launching this ahk script also launches retroarch:  Run, "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe"

This ahk script just freezes retroarch and I have to terminate the process: Run, "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe" -L wgc_libretro.dll "M:\WindowCast\WindowCast.txt"

I also get the freeze when just trying to launch this via CMD. I can see that WindowCast is trying to capture the Xemu window (yellow outlines aroundthe game window), but Retroarch crashes. Same behavior with Dolphin. 

Again, running windowcast manually works perfectly.

EDIT:

I think I got it. It's Gsync. If Gsync is enabled in RetroArch, CMD and AHK crash Retroarch during the window capture. If it's disabled it works.

But again, when manaully starting WindowCast, it works fine, even wuth Gsync enabled.

Ahh ok so that's good news, and bad news lol

Good news is the script "works", it is finding the emulator window, it is launching Retroarch. So good so far

Bad news is the core is buggy and finicky.

For ex, I am now launching Ninja Gaiden Black again and.....it works perfectly. Every. Single. Time. didn't change a damn thing from this morning lol. The window is getting focused appropriately via the script making it all automated as intended. I guess I'd rather be lucky than good because I have no idea why it wasn't working earlier, and why it is now

I'm on an AMD GPU but I had found many scenarios of weird with this core. No windows with "windowcast" in its title can exist.....I find that out from testing with this thread open. If minimized it can capture Firefox's minimized window and makes it look like Retroarch launched but froze before a window even appears. In reality what happened is it literally captured a minimized window lol. I then restore the Firefox window and that gets captured in Retroarch🤦‍♂️. Doesn't make much sense given there is nothing in the WindowCast.txt file that would make that window get captured hence why I think it is some bug with the core.

There is some discussion about GPU settings scattered in that link in the first post. There might be some hidden hints in there for you.

Alternatively, if you are using that very first version of the script I posted, you might be having challenges like I did for some scenarios where launching Retroarch into fullscreen was the issue. If you're using the first one, try the 2nd version instead, the "SDR" version. It will make Retroarch more of less a borderless fullscreen window and I found this as a workaround. It is always consistent unlike directly launching into fullscreen. YMMV though

So overall sounds like the script is doing what it was set out to do but something specific is causing a challenge on your system. And sounds like you found the potential culprit as Gsync. I'd believe it, there have been weirder things impacting my experience with this core!

Posted (edited)
12 hours ago, skizzosjt said:

Ahh ok so that's good news, and bad news lol

Good news is the script "works", it is finding the emulator window, it is launching Retroarch. So good so far

Bad news is the core is buggy and finicky.

For ex, I am now launching Ninja Gaiden Black again and.....it works perfectly. Every. Single. Time. didn't change a damn thing from this morning lol. The window is getting focused appropriately via the script making it all automated as intended. I guess I'd rather be lucky than good because I have no idea why it wasn't working earlier, and why it is now

I'm on an AMD GPU but I had found many scenarios of weird with this core. No windows with "windowcast" in its title can exist.....I find that out from testing with this thread open. If minimized it can capture Firefox's minimized window and makes it look like Retroarch launched but froze before a window even appears. In reality what happened is it literally captured a minimized window lol. I then restore the Firefox window and that gets captured in Retroarch🤦‍♂️. Doesn't make much sense given there is nothing in the WindowCast.txt file that would make that window get captured hence why I think it is some bug with the core.

There is some discussion about GPU settings scattered in that link in the first post. There might be some hidden hints in there for you.

Alternatively, if you are using that very first version of the script I posted, you might be having challenges like I did for some scenarios where launching Retroarch into fullscreen was the issue. If you're using the first one, try the 2nd version instead, the "SDR" version. It will make Retroarch more of less a borderless fullscreen window and I found this as a workaround. It is always consistent unlike directly launching into fullscreen. YMMV though

So overall sounds like the script is doing what it was set out to do but something specific is causing a challenge on your system. And sounds like you found the potential culprit as Gsync. I'd believe it, there have been weirder things impacting my experience with this core!

Well it's not working , yet sadly. This ahk script now works, as in it launches WindowCast and successfully captures Xemu:

    Run, "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe" -L wgc_libretro.dll "M:\WindowCast\WindowCast.txt"

However, the rest of the script does not work. In fact it does nothing, when I try to launch it. Retroarch doesn't even launch =/

EDIT:

I tried some stuff and shortening the script to just this now also works:

 

SetWorkingDir, % A_ScriptDir
SetTitleMatchMode, RegEx    ; seems to work like mode 2 (partial match) but allows for use of expressions
RetroarchWinTitle := "ahk_exe retroarch.exe"
RetroarchEXE := "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe"
WindowCastFile := "M:\WindowCast\WindowCast.txt"
WindowCastListArray := []


    Run, %RetroarchEXE% -L wgc_libretro.dll %WindowCastFile%

However, this does of course not send CTRL + ALT + T which is needed for the inputs to work.

I'm at a loss as to why the whole script won't work for me.

Edited by SiriusVI
Posted (edited)

Will need you to provide the info I asked for and then some more. There is some unknown challenge on your end we're trying to figure out.

 

On 4/26/2025 at 1:23 PM, skizzosjt said:

if it's not working at this point you should check the AHK tray icon and review the lines of code that have been executed. I would suspect either the script is exiting too soon for some currently unknown reason or some configuration or typo kinda issue. reviewing the lines executed will let us know what ran and where it's stuck if it is stuck. post an image of that window if needed

so, you need to post an image of the most recent executed lines when the script is allegedly stuck. for ex, here is what it should look like once you're fully booted into a game. use the full version rather than the shorter version you posted just now.

click on the AHK script's tray icon to bring up this window and post a screen shot, for ex

image.thumb.png.13952a54c55ef51dc9e450bc954f6b69.png

 

 

I'll need the whole script you're using. So, you need to post the script you are using with your edits in its entirety (the full version rather than what you posted just now that is shorter). use the code tag button (<>) when posting code.

 

Additionally lets cover all bases here, please post (upload the file - do NOT just paste the contents) the WindowCast.txt file you are using.

 


When you say the full script doesn't work, do you consistently get this message box?

image.png.d49e3904178d51c160f3609388ab6d10.png

Edited by skizzosjt
Posted (edited)

OK got it, so this is how it starts:

image.thumb.png.dfe915e1675bb61ce61160a5677dec05.png

 

Once I scroll down to the end, it looks like this:

image.thumb.png.15b786c71fb0332ca94015cb4075d096.png

Again for reference, I use this script now:

 

SetWorkingDir, % A_ScriptDir
SetTitleMatchMode, RegEx    ; seems to work like mode 2 (partial match) but allows for use of expressions
RetroarchWinTitle := "ahk_exe retroarch.exe"
RetroarchEXE := "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe"
WindowCastFile := "M:\WindowCast\WindowCast.txt"
WindowCastListArray := []
TimeOutDelay := 10000       ; close script if game/emulator window is not found in X seconds
RunRetroarchDelay := 1500   ; delay between finding game/emulator window and then opening Retroarch
FocusHotkeyDelay := 2000    ; delay between launching Retroarch and sending hotkey to grab focus of game/emulator window. *HDR/Fullscreen method ONLY*

; Read WindowCast window list file and parse into array
FileRead, WindowCastList, %WindowCastFile%
Loop, Parse, WindowCastList, `r, `r`n 
{
    If (InStr(A_LoopField, "#"))
        Continue
    WindowCastListArray.Push(A_LoopField)
}

; Loop through list to check which window exists
InitialTime := A_TickCount
WindowCheck:
Loop, % WindowCastListArray.Count() {
    ; Check if entry is an exe
    If (InStr(WindowCastListArray[A_Index], ".exe")) {
        If (WinExist("ahk_exe " . "i)" . WindowCastListArray[A_Index])) {
            ExistingWindow := WindowCastListArray[A_Index]
            Break
        }    
    }
    ; If entry is not an exe, it is a window title
    Else If (WinExist("i)" . WindowCastListArray[A_Index])) {
        ExistingWindow := WindowCastListArray[A_Index]
        Break
    }
    DurationTime := A_TickCount - InitialTime
    If (DurationTime >= TimeOutDelay) {
        MsgBox, 4096, Window Check Timeout, Couldn't find existing window. Exiting script!
        ExitApp
    }
}
If (ExistingWindow = "")
    Goto, WindowCheck

Sleep, RunRetroarchDelay
Run, %RetroarchEXE% -L wgc_libretro.dll %WindowCastFile% -f
WinWait, % RetroarchWinTitle
Sleep, % FocusHotkeyDelay
; Sends hotkey to give focus to game window so inputs are detected
Send {LCtrl down}{LAlt down}{t down}{t up}{LAlt up}{LCtrl up}
If (InStr(ExistingWindow, ".exe")) 
    WinWaitClose, % "ahk_exe" . "i)" . ExistingWindow
Else
    WinWaitClose, % "i)" . ExistingWindow
WinClose, % RetroarchWinTitle
ExitApp

; Hotkey to exit Retroarch and terminate script
$Esc:: ; keyboard modifier ($) is needed so input isn't "eaten" by the game
WinClose, % RetroarchWinTitle
ExitApp


I'll attach the file here as well.

I do not get the message box you mentionied. It's just that nothing happens when I double click the script. Except that AutoHotKey appears in my task bar with the contents that I uploaded above.

WindowCast.ahk

Edited by SiriusVI
Posted
21 hours ago, SiriusVI said:

OK got it, so this is how it starts:

image.thumb.png.dfe915e1675bb61ce61160a5677dec05.png

 

Once I scroll down to the end, it looks like this:

image.thumb.png.15b786c71fb0332ca94015cb4075d096.png

Again for reference, I use this script now:

 

SetWorkingDir, % A_ScriptDir
SetTitleMatchMode, RegEx    ; seems to work like mode 2 (partial match) but allows for use of expressions
RetroarchWinTitle := "ahk_exe retroarch.exe"
RetroarchEXE := "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe"
WindowCastFile := "M:\WindowCast\WindowCast.txt"
WindowCastListArray := []
TimeOutDelay := 10000       ; close script if game/emulator window is not found in X seconds
RunRetroarchDelay := 1500   ; delay between finding game/emulator window and then opening Retroarch
FocusHotkeyDelay := 2000    ; delay between launching Retroarch and sending hotkey to grab focus of game/emulator window. *HDR/Fullscreen method ONLY*

; Read WindowCast window list file and parse into array
FileRead, WindowCastList, %WindowCastFile%
Loop, Parse, WindowCastList, `r, `r`n 
{
    If (InStr(A_LoopField, "#"))
        Continue
    WindowCastListArray.Push(A_LoopField)
}

; Loop through list to check which window exists
InitialTime := A_TickCount
WindowCheck:
Loop, % WindowCastListArray.Count() {
    ; Check if entry is an exe
    If (InStr(WindowCastListArray[A_Index], ".exe")) {
        If (WinExist("ahk_exe " . "i)" . WindowCastListArray[A_Index])) {
            ExistingWindow := WindowCastListArray[A_Index]
            Break
        }    
    }
    ; If entry is not an exe, it is a window title
    Else If (WinExist("i)" . WindowCastListArray[A_Index])) {
        ExistingWindow := WindowCastListArray[A_Index]
        Break
    }
    DurationTime := A_TickCount - InitialTime
    If (DurationTime >= TimeOutDelay) {
        MsgBox, 4096, Window Check Timeout, Couldn't find existing window. Exiting script!
        ExitApp
    }
}
If (ExistingWindow = "")
    Goto, WindowCheck

Sleep, RunRetroarchDelay
Run, %RetroarchEXE% -L wgc_libretro.dll %WindowCastFile% -f
WinWait, % RetroarchWinTitle
Sleep, % FocusHotkeyDelay
; Sends hotkey to give focus to game window so inputs are detected
Send {LCtrl down}{LAlt down}{t down}{t up}{LAlt up}{LCtrl up}
If (InStr(ExistingWindow, ".exe")) 
    WinWaitClose, % "ahk_exe" . "i)" . ExistingWindow
Else
    WinWaitClose, % "i)" . ExistingWindow
WinClose, % RetroarchWinTitle
ExitApp

; Hotkey to exit Retroarch and terminate script
$Esc:: ; keyboard modifier ($) is needed so input isn't "eaten" by the game
WinClose, % RetroarchWinTitle
ExitApp


I'll attach the file here as well.

I do not get the message box you mentionied. It's just that nothing happens when I double click the script. Except that AutoHotKey appears in my task bar with the contents that I uploaded above.

WindowCast.ahk 2.34 kB · 2 downloads

Thanks. This confirms the script is stuck in an infinite loop that is skipping over the body of a loop due to not reading your WindowCast.txt file appropriately. Further confirmed you never get the timeout message since it never reaches that line.  As far as I can tell the root problem is the script not reading/parsing anything from your WindowCast.txt file otherwise it wouldn't be doing this loop body skipping. I was able to recreate the same issue with the infinite loop so I can prevent it, but need to confirm you did the same or something similar to get into an infinite loop too. I should be able to connect the dots after reviewing and trying out your WindowCast.txt file

You forgot to upload the WindowCast.txt file. I need the file you are using located at M:\WindowCast\WindowCast.txt 

I did improve the script to throw a different error when this happens as well as prevent the infinite loop. 

No redflags in the .ahk file! And that clarifies which version you were using so I know I'm testing with the same.

Attach that WindowCast.txt file and I'll check it out and get back to ya

  • Like 1
Posted
6 minutes ago, skizzosjt said:

Thanks. This confirms the script is stuck in an infinite loop that is skipping over the body of a loop due to not reading your WindowCast.txt file appropriately. Further confirmed you never get the timeout message since it never reaches that line.  As far as I can tell the root problem is the script not reading/parsing anything from your WindowCast.txt file otherwise it wouldn't be doing this loop body skipping. I was able to recreate the same issue with the infinite loop so I can prevent it, but need to confirm you did the same or something similar to get into an infinite loop too. I should be able to connect the dots after reviewing and trying out your WindowCast.txt file

You forgot to upload the WindowCast.txt file. I need the file you are using located at M:\WindowCast\WindowCast.txt 

I did improve the script to throw a different error when this happens as well as prevent the infinite loop. 

No redflags in the .ahk file! And that clarifies which version you were using so I know I'm testing with the same.

Attach that WindowCast.txt file and I'll check it out and get back to ya

Ah, yeah I forgot sorry. Anyway, it's just the file that came with the core. I just renamed it to "WindowCast.txt". Did nothing else to it.

Thank you so much for helping me out 😃

WindowCast.txt

Posted
1 hour ago, SiriusVI said:

Ah, yeah I forgot sorry. Anyway, it's just the file that came with the core. I just renamed it to "WindowCast.txt". Did nothing else to it.

Thank you so much for helping me out 😃

WindowCast.txt 104 B · 1 download

Damn, no red flags! That's formatted correctly. You didn't add anything? Did you get lucky and xemu was already in there? 😂

 

I could create same infinite loop by putting no lines that would need to be used to match to the emulator/game window. for ex....

image.thumb.png.418a8ce328509db1ed53c74785ca9bec.png

Though there is text here, they have the intended comment marker that the WindowCast core uses, and my script is using them in the same fashion, skipping a line if that is found in said line.

This results in nothing being pushed into an array, which I then use the qty of entries in that array to determine the qty of loops needed. So if it's 0 the infinite loop can happen. This is why I think your file isn't being read/parsed and/or pushed into the array.

I can take your files, change the path of the two needed variables, that being Retroarch and WindowCast.txt and it works for me. So far, I think something specific is causing your system to not read/parse the file appropriately. It does explain why it works manually, but not through this script.

 

I'm gonna need to make some special script for you in order to troubleshoot further. Still need to determine why it's going off the rails for only you. 

I've added a message box to display right at start to show the exact contents of the file being read. You should see a message box just like this, displaying the contents of the file as expected. If you do not, we at least will know this is where it is going off the rails. The rest of message boxes will be blank or nonsense if this first one isn't showing anything. If you see the expected file contents then I got more checks below

image.png.867343e4e1979c60f5c29ce5bf1ac54a.png

 

If the file is being read properly, next message boxes are checking the contents are or are not getting pushed into the array. Checks line by line starting at top, based on contents of your WindowCast.txt file it should be a no, yes cycle. For ex

image.png.9754ec857a5447db425a720bdb19290e.png

Followed by

image.png.69e96f49d521a4f8c1b197b1a913efbd.png

It will then do the same for the PCSX2 and Xemu entries

 

Once it makes it through the file it should display one more message box showing the qty of entries in the array, which is how many loops it runs in order to check each one of these lines for an existing window or process. Should be 3 entries based on your WindowCast.txt file

image.png.6e58718e47bd1b72ebe0e296e3e1949b.png

 

 

Please try this version of the script to see how these message boxes behave. Let me know how it goes!

Spoiler
SetWorkingDir, % A_ScriptDir
SetTitleMatchMode, RegEx    ; seems to work like mode 2 (partial match) but allows for use of expressions
RetroarchWinTitle := "ahk_exe retroarch.exe"
RetroarchEXE := "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe"
WindowCastFile := "M:\WindowCast\WindowCast.txt"
WindowCastListArray := []
TimeOutDelay := 10000       ; close script if game/emulator window is not found in X seconds
RunRetroarchDelay := 1500   ; delay between finding game/emulator window and then opening Retroarch
FocusHotkeyDelay := 2000    ; delay between launching Retroarch and sending hotkey to grab focus of game/emulator window. *HDR/Fullscreen method ONLY*

; Read WindowCast window list file and parse into array
FileRead, WindowCastList, %WindowCastFile%
MsgBox, 4096, TROUBLESHOOTING #1, % WindowCastList
Loop, Parse, WindowCastList, `r, `r`n 
{
    If (InStr(A_LoopField, "#")) {
        MsgBox, 4096, TROUBLESHOOTING #2, % A_LoopField . " was NOT pushed into array"
        Continue
    }
    WindowCastListArray.Push(A_LoopField)
    MsgBox, 4096, TROUBLESHOOTING #3, % A_LoopField . " WAS pushed into array"
}
MsgBox, 4096, TROUBLESHOOTING #4, % "WindowCastListArray.Count() = " . WindowCastListArray.Count()

; Loop through list to check which window exists
InitialTime := A_TickCount
WindowCheck:
Loop, % WindowCastListArray.Count() {
    ; Check if entry is an exe
    If (InStr(WindowCastListArray[A_Index], ".exe")) {
        If (WinExist("ahk_exe " . "i)" . WindowCastListArray[A_Index])) {
            ExistingWindow := WindowCastListArray[A_Index]
            Break
        }    
    }
    ; If entry is not an exe, it is a window title
    Else If (WinExist("i)" . WindowCastListArray[A_Index])) {
        ExistingWindow := WindowCastListArray[A_Index]
        Break
    }
    DurationTime := A_TickCount - InitialTime
    If (DurationTime >= TimeOutDelay) {
        MsgBox, 4096, Window Check Timeout, Couldn't find existing window. Exiting script!
        ExitApp
    }
}
If (ExistingWindow = "")
    Goto, WindowCheck

Sleep, RunRetroarchDelay
Run, %RetroarchEXE% -L wgc_libretro.dll %WindowCastFile% -f
WinWait, % RetroarchWinTitle
Sleep, % FocusHotkeyDelay
; Sends hotkey to give focus to game window so inputs are detected
Send {LCtrl down}{LAlt down}{t down}{t up}{LAlt up}{LCtrl up}
If (InStr(ExistingWindow, ".exe")) 
    WinWaitClose, % "ahk_exe" . "i)" . ExistingWindow
Else
    WinWaitClose, % "i)" . ExistingWindow
WinClose, % RetroarchWinTitle
ExitApp

; Hotkey to exit Retroarch and terminate script
$Esc:: ; keyboard modifier ($) is needed so input isn't "eaten" by the game
WinClose, % RetroarchWinTitle
ExitApp

 

 

 

Posted (edited)

Wow thx so much for your hard work helping me. Truly appreciate it! Alright, here we go:

1. box
image.thumb.png.34557ff821383b1afb515f2ea6320b97.png

2. box:
image.thumb.png.225363e4300494c77383dd998bf72071.png

3. box
image.thumb.png.8929cef2a8184563e7f465fba0fb5df7.png

4. box
image.thumb.png.a414eac5c41dbe255db7420e1c71da67.png

5.box
image.thumb.png.a96a2e133ad99bdcf78d1097746a4ec0.png

6. box
image.thumb.png.c3ff65972b0ca393eb20229bd7e80be4.png

7. box
image.thumb.png.15ae38f2bc2944227fba01b03be781e3.png

8. box
image.thumb.png.2c0f74120790d42438c3c03df641566f.png

So this is empty, it does not = 3 ...

AKH window looks the same:
image.thumb.png.27aa4e6e5746f86a6c7bbec759e62572.png

Edited by SiriusVI
Posted
3 hours ago, SiriusVI said:

Wow thx so much for your hard work helping me. Truly appreciate it! Alright, here we go:

no problem and your welcome! but we're not quite out of the woods yet, hold the thanks until then......we will get there. I'm determined lol

 

ok this is all excellent info but......not good.....I'm at a point of  'da fuck is going on here?  😕

it's reading the file (good), but does not seem to be pushing these values into the array (bad)......weird situation. I'm no programmer and don't understand what challenge is on your side, bare with me as we stumble through this together.  Very frustrating since the script works for me, this specific issue isn't making sense why it would show up on one person's system but not another's.

 

I'm adding some more stuff to try and troubleshoot. After the 3rd message box I've got #3B right after it. Right before this, the value is pushed into the array. So, by theory reading that array position right afterwards should let us see the exact same value. For ex

image.png.2e5bffd17131612662e07fe37d1dd3fd.png

 

If it's blank like this (notice no "Dolphin" or whatever value it was supposed to add to the array) there is some problem going on I cannot identify yet

image.png.c4270e9a953fd61e11e2504567f78eba.png

this will repeat for the PCSX2 and Xemu lines like last time

 

The last message box will have more text. Even if the array count is null maybe something weird is going on with just the count function. This also reads the array's first three entries regardless. So we want to see stuff here for ex

image.png.cfde5c8efec051b55eff777632475095.png

 

 

Please try this version of the script out

Spoiler
SetWorkingDir, % A_ScriptDir
SetTitleMatchMode, RegEx    ; seems to work like mode 2 (partial match) but allows for use of expressions
RetroarchWinTitle := "ahk_exe retroarch.exe"
RetroarchEXE := "M:\Launchbox\Emulators\RetroArch - WindowCast\retroarch.exe"
WindowCastFile := "M:\WindowCast\WindowCast.txt" 
WindowCastListArray := []
TimeOutDelay := 10000       ; close script if game/emulator window is not found in X seconds
RunRetroarchDelay := 1500   ; delay between finding game/emulator window and then opening Retroarch
FocusHotkeyDelay := 2000    ; delay between launching Retroarch and sending hotkey to grab focus of game/emulator window. *HDR/Fullscreen method ONLY*

; Read WindowCast window list file and parse into array
FileRead, WindowCastList, %WindowCastFile%
MsgBox, 4096, TROUBLESHOOTING #1, % WindowCastList
Index := 1
Loop, Parse, WindowCastList, `r, `r`n 
{
    If (InStr(A_LoopField, "#")) {
        MsgBox, 4096, TROUBLESHOOTING #2, % A_LoopField . " was NOT pushed into array"
        Continue
    }
    WindowCastListArray.Push(A_LoopField)
    MsgBox, 4096, TROUBLESHOOTING #3, % A_LoopField . " WAS pushed into array"
    MsgBox, 4096, TROUBLESHOOTING #3B, % WindowCastListArray[Index] . " is in WindowCastListArray position # " . Index
    Index++
}
MsgBox, 4096, TROUBLESHOOTING #4, % "WindowCastListArray.Count() = " . WindowCastListArray.Count()
. "`n`nArray Position #1 = " . WindowCastListArray[1]
. "`nArray Position #2 = " . WindowCastListArray[2]
. "`nArray Position #3 = " . WindowCastListArray[3]

; Loop through list to check which window exists
InitialTime := A_TickCount
WindowCheck:
Loop, % WindowCastListArray.Count() {
    ; Check if entry is an exe
    If (InStr(WindowCastListArray[A_Index], ".exe")) {
        If (WinExist("ahk_exe " . "i)" . WindowCastListArray[A_Index])) {
            ExistingWindow := WindowCastListArray[A_Index]
            Break
        }    
    }
    ; If entry is not an exe, it is a window title
    Else If (WinExist("i)" . WindowCastListArray[A_Index])) {
        ExistingWindow := WindowCastListArray[A_Index]
        Break
    }
    DurationTime := A_TickCount - InitialTime
    If (DurationTime >= TimeOutDelay) {
        MsgBox, 4096, Window Check Timeout, Couldn't find existing window. Exiting script!
        ExitApp
    }
}
If (ExistingWindow = "")
    Goto, WindowCheck

Sleep, RunRetroarchDelay
Run, %RetroarchEXE% -L wgc_libretro.dll %WindowCastFile% -f
WinWait, % RetroarchWinTitle
Sleep, % FocusHotkeyDelay
; Sends hotkey to give focus to game window so inputs are detected
Send {LCtrl down}{LAlt down}{t down}{t up}{LAlt up}{LCtrl up}
If (InStr(ExistingWindow, ".exe")) 
    WinWaitClose, % "ahk_exe" . "i)" . ExistingWindow
Else
    WinWaitClose, % "i)" . ExistingWindow
WinClose, % RetroarchWinTitle
ExitApp

; Hotkey to exit Retroarch and terminate script
$Esc:: ; keyboard modifier ($) is needed so input isn't "eaten" by the game
WinClose, % RetroarchWinTitle
ExitApp

 

 

 

AFTER trying the above version to see what happens....THEN please do this edit to the above script. Simply replace line #6 with this line below.  All we're doing here is adding "Global" in front of declaring the array.

Global WindowCastListArray := []

 

After making that edit try and run the script again and see if behavior changes! Fingers crossed! 🤞

 

 

For transparency. The first test is to see if the values in the array can be read prior to leaving the loop where they are being pushed into said array but still cannot be read outside the loop. The second test is to see if making the array a global variable will allow it to be read at all other points in the script

Posted

d00d! do0o0o0o0o0o0o0o0d!  having an eureka moment! :) 

Started thinking about the fact you're using the AHK version included with LaunchBox. One of the very first scripts I wrote years ago had an issue when I first started using LB. It was the other way around though, I wrote a script on a really old version of V1 and it worked fine with that version.....but LB had a newer version and it impacted the scripts behavior negatively. I had to change syntax since they changed it between those versions.

this time around I'm using a more recent release of V1

I just tried running the script with LB's AHK file, which is v1.1.24.03 and is pretty darn old relatively speaking in AHK world. Also is the 32bit version and I always use the 64bit version

image.thumb.png.2e2b00d4a5cca998c4ec0093e08aa54c.png

 

THERE IS DIFFERENT BEHAVIOR BETWEEN AHK VERSIONS!

I'm betting on THAT is the root cause here! I can recreate same error that being the file is read, but I cannot get the qty of entries in the array due to it seems the count method isn't working! As I wondered with the above troubleshooting version, I can even read the array, but something not working right with the Count() method (I called it a function in other posts but it's really a "method"). I get a null value and infinite loop just like you do when trying to use it to determine number of values in the array!

 

 

 

Value is null using the AHK exe included with LB

image.thumb.png.7ddd521491253e4d2fff35f38d610276.png

 

yet here I am running a much more recent version of AHK V1 and it works fine!

image.thumb.png.cae38bb4198b91cac9c03df304fc2464.png

 

lets check if 32bit matters at all......NOPE!

image.thumb.png.19f44d647c615b35bbdf664bf63ba191.png

 

 

Get your hands on the latest version of AHK V1. Even I am not on the latest but should be. The last release for V1 was like a year ago. V2 was in limbo for many years and they finally pulled the trigger on making it the official release version at that time about a year ago. So V1 is actually deprecated now but it's been around for so long that most basic users aren't going to make the switch.

 

so for ex I have this working fine when using v1.1.36.02

I just downloaded the last official release of V1 which is v1.1.37.02 and also works fine!

Each time I try and run it with the one included with LB is the only time the script doesn't work correctly!

You will need to download a newer version from their site. You can then replace the exe included with LB with the one you downloaded

 

Showing this so you don't think I'm just linking you to some rando website

Got to autohotkey.com and Click the green download button

image.thumb.png.dc3d04886bb649f88c64ba9824ae35c2.png

Click other versions

image.thumb.png.fecba1213c2a0535afb3ab2083c688d1.png

Click AHK V1.1

image.thumb.png.0c236689ee9b75ce182225a043ba13bf.png

Sort by date and pick the circled zip version of the latest release. The zip version is a portable version. You can simply unpack this archive anywhere and AHK is set to jet right away. Go into that folder and copy AutoHotkeyU64.exe to where LB stores its AHK exe. (\LaunchBox\ThirdParty\AutoHotkey) Be sure to rename the file to the same name inside the LaunchBox folder. ie rename the exe you just pasted in there from AutoHotkeyU64.exe to AutoHotkey.exe
 

image.thumb.png.541d51d3d525f48a1119aaede6426a20.png

I also pointed to the exe version should you want that. this one goes through the typical setup wizard process if that is more to your liking. Adding it to start menu and Windows Programs and App list, right click context menu and the like, etc etc official program stuff.

I think I'll advocate to the dev team to not be several years behind on their AHK version lmao! They are using a version released in 2017 that's before I even started using LB let alone AHK! 🤦‍♂️ Gotta get with the times!

 

 

I went digging in their change log and it all makes so much sense now! this method didn't even EXIST until a later version! Of course it won't work in some version from 2017, gotta have this version from 2018 or newer to use .Count()

image.thumb.png.6d973e02704f3b8d1e9485085d3ee721.png

I assumed I was going to find some bug fix report in here for the count method rather than it wasn't even introduced until a later version, but boy I'm glad I found this info here! I go nuts not knowing the "why" of things! The dots are now fully connected!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...