Resource icon

Simple scene switcher 0.6

chris84

New Member
Re: Very simple scene switcher

Download the zip on first post, and extract 32bit\scenesw.dll in "plugins" folder of your obs installation, which will be "C:\Program Files (x86)\OBS\plugins" for example. Use 64bit\scenesw.dll instead if you use 64bit OBS.
 

Wehs

New Member
Re: Very simple scene switcher

This seems so cool, especially for league. Can't wait to experiment with this. Nice job man!
 

Wehs

New Member
Re: Very simple scene switcher

Actually I have come across an issue (assuming Windows 8 related).

I have everything set up so that League of Legends is my main window, and will go to a scene that contains its Game Capture. The alternate scene is a screen region.

It's recognizing that the main window exists, but it says that the "Window is minimized". This would show up when I had my game of LoL open, and my OBS in the second monitor. (Two monitors, LoL was on the main, OBS on the secondary).

I'm not sure what the issue could be here, I restarted both OBS and League, and it's continually saying that the window is minimized despite the fact that I have it open. I have league in borderless mode, however none of the other options worked either. I'm assuming it's an issue with OBS finding the window, but again, it was open and borderless full screen on my main monitor with obs on the secondary.

Halp.


League of Legends is the main window. If done correctly it should be on the League of Legends Game scene. Notice it says Window is minimized in the bottom left hand corner, yet it is my main and active display.
 

chris84

New Member
Re: Very simple scene switcher

It's probably a dual monitor issue, I'll do some tests to understand what's happening as soon as I'm back home.
No idea what this window is minimized message is though.

edit: I tried, couldn't find any problem, it worked as intended. I don't have LoL though, tried other games in windowed fullscreen.
What's your dual screen setup ? extend displays ?
 

BeauWest

Member
Re: Very simple scene switcher

This is fantastic Chris, I didn't see this on the forums so started to try to write my own way of doing this in Python, it didn't work near as well as what you've got here.

Only thing I can think of that I would add is the ability to configure multiple games/windows and have each have it's own scene settings. That'd make it so you wouldn't have to reconfigure the plugin for different games. But I know that's probably easier said than done.
 

chris84

New Member
Re: Very simple scene switcher

Thanks ^^
About your suggestion, yes, this is the next step I have in mind, just need to find some time to do it properly.
 

BeauWest

Member
Re: Very simple scene switcher

After I've used it more, I'm running into one more inconvenience. Battlefield 3 requires you to relaunch the game every time you switch servers, so the game closes, and understandably, the plugin doesn't see the window anymore. Even when you relaunch the game. It works to just go into the plugin and restart it.
 

chris84

New Member
Re: Very simple scene switcher

Yes, because it monitors window handles. When you close your game and open it again the handle changes.
This is something I'll have to solve as well for the "multiple configurations saving" upgrade.
 

BeauWest

Member
Re: Very simple scene switcher

I'm sure there's a better way (not a Windows programmer), but the way I sorta-kinda solved this when I was trying it was something like:

Code:
activeWindowId = win32process.GetWindowThreadProcessId(win32gui.GetForegroundWindow())[1]
processes = psutil.get_process_list()
for process in processes:
        if process.pid == activeWindowId:
            activeWindowProcess = process.name

This let me get the process name (bf3.exe, sc2.exe, explorer.exe) for the foreground window.
 

chris84

New Member
Re: Very simple scene switcher

This looks like a good solution indeed.
BTW if you (or anyone else for that matter) feels like getting involved, I GPL'ed it so feel free to do so.

Actually it might not work for LoL, since from what I gathered you have 2 windows that belong to the same process
 

BeauWest

Member
Re: Very simple scene switcher

I've never played LoL, but would it matter to go off of process name? I'm not sure how the 2 windows behave, but as long as one of them is focused the process name should be correct. I'm probably missing something.
 

chris84

New Member
Re: Very simple scene switcher

From what I understood, what most people do, there's the game, which should trigger the main scene, and the lobby which should trigger an alternate scene.
So if they both belong to the same process, which they probably do, the lobby wouldn't switch to alt scene. See what I mean ?
 

ThoNohT

Developer
Re: Very simple scene switcher

This is very awesome. It goes a long way towards an idea I had for a scene switcher plugin. I'm not a livestreamer myself, but love to experiment with it, and if I had the time, would probably be doing some livestreaming. The only thing I'd like is to be able to not have a main window/scene and an alternate scene, but to be able to define a list of window titles, each of which can have a scene associated with then. Alternate scene would be called default, but that's just linguistics. In stead of working with window handles, the windows would be identified by their title.

My proficiency with c++ is far from sufficient to create such a plugin, as I generally work with Java and C#. However, I'm a quick learner, and with this code as an example, I might be able to extend it to include the functionality described above. So I'll take you up on your offer to get involved, and I'll see if I can find the time to do some work on it.

So far I have managed to compile OBS in Visual Studio 2008. scenesw seems to be made in a newer version of visual studio though, and I do not own any newer version. I did get it working in Visual C++ Express 2012 by changing the following line in scenesw.rc:
#include "afxres.h"
to (code boxes are huge, so I'm using quotes)
#include "winres.h"
I'm not sure if this breaks anything, but so far I got it to compile, and it functions properly within OBS. Could anyone tell me if this could cause any problems?

I don't know how far I should go into the code in this thread, but when looking at APIInterface.h from OBS. It seems Jim wants you to use the C-style API exports, rather than the virtual functions. My first try at changing something was to replace these, and that seems to work the same still.
 

chris84

New Member
Re: Very simple scene switcher

Yes I also had to do that change to compile it on my laptop that only has vs2012, it doesn't break anything don't worry.
 

BeauWest

Member
Re: Very simple scene switcher

So I made some slight modifications that kinda-sorta work. https://gist.github.com/beaudesigns/5008143

Basically you were already getting the window name with "GetWindowText()" so you could auto-start. I just used that to check the currently focused window instead of the window handler.

The only minor change to SceneSwitcher.h is that I removed the piece that said " && mainHwnd" in CheckSettings().

It works for me, as always, I'm sure there's a cleaner/safer way of doing it, but this should work for my event this weekend. ^_^
 

zetka

New Member
Re: Very simple scene switcher

Hi mate, this plugin is almost perfect for what I need but I have some suggestions for it!

As a League of Legends streamer I have to have 2 scenes for the Launcher and the Game itself, I was hoping to use this plugin for this purpose but there is a couple of issues.
-As the game window opens and closes every game, it will only work for the first time it opens and closes and no further (presumably because it's technically a different window the following times)
-If I alt-tab to check a message it will also switch scene

Would it be possible to implement a feature so it is done on process (like sources) and to switch when that process is running or closed rather than in the primary view?

That would be ace, thanks a lot and great work so far!
 

chris84

New Member
Re: Very simple scene switcher

You mean the game and the launcher are different processes ?
For your first problem, it's probably gonna be fixed soon, as for the second, i guess you could associate your messaging app with your main scene once multiple conf is supported, but what you're asking is pretty different from what the plugin is supposed to do :/
 

ThoNohT

Developer
Re: Very simple scene switcher

One possibility is to make the default/alternate scene optional. Maybe by adding a "don't change" checkbox. Then it would only change whenever a defined window is opened.
 

zetka

New Member
Re: Very simple scene switcher

chris84 said:
You mean the game and the launcher are different processes ?
For your first problem, it's probably gonna be fixed soon, as for the second, i guess you could associate your messaging app with your main scene once multiple conf is supported, but what you're asking is pretty different from what the plugin is supposed to do :/

Yeah, there's a game launcher and then the game itself on 2 different processes. I have to switch between them everytime a game starts and finishes. Was hoping to find a plugin that could do that automatically :/
 
Top