Simulating Keystrokes to Change Scenes?

MattEatsMochi

New Member
Hi friends, I wanted to open this to the floor as I've kinda hit my wits end. I wrote an app this evening with the desired effect of having one stream overlay on during game and off when not. For example, see this overlay my friend Shayed uses. Great in game, doesn't make any sense when not.

In game: https://clips.twitch.tv/shayed_/AmusedFerretRitzMitz
Not in game: https://clips.twitch.tv/shayed_/GleamingJellyfishAsianGlow

As far as I can tell, this should be working. Game can tell when you're playing, switches back and forth fine, but for some reason OBS is not putting up or removing the overlay source. Any thoughts? I'm using SendKeys to simulate the keystrokes that are mapped to reveling and hiding the source. Maybe that's what OBS doesn't recgonize.

Here is the code:
https://github.com/matteatsmochi/OverwatchOverlay
 

dodgepong

Administrator
Forum Admin
It would probably be better to write a plugin that actually uses the OBS API to toggle source visibility or active scene, rather than trying to communicate with OBS via simulated keystrokes.
 

MattEatsMochi

New Member
It would probably be better to write a plugin that actually uses the OBS API to toggle source visibility or active scene, rather than trying to communicate with OBS via simulated keystrokes.
As someone who does this on a very amateur level, are there any resources for this that would be written for say... a 6 year old? I do of course appreciate the reply. (Also have this written in VB, if that makes a difference)
 

ThoNohT

Developer
Why not get your program to write the scene name to a text file, and use the advanced scene switcher to switch based on this file? Or maybe the advanced scene switcher may even have the functionality needed to determine whether you are ingame, how does your own program do this?
 

Warmuptill

Active Member
I think MattEatsMochi is comparing the color of a pixel at the location of the overwatch crosshair to the color he chose for his crosshair. A feature like this is not available in the advanced scene switcher. But as you suggested using the option to read the scene from file can be used if you cant get the keystrokes to work.
 

MattEatsMochi

New Member
Out of curiosity, how does the advanced scene switcher communicate with OBS? Could I use it to somehow backdoor into what I'm trying to do?

I'd rather not switch scenes, but if it's my only option right now then I guess I can use it as a temporary option. I've tried 2 methods of simulating keystrokes, but neither of them are recognized to show/hide sources.
 

MattEatsMochi

New Member
Just had an idea in the shower. While SendKeys and InputSimulator didn't work I pulled up an older "OpenTwitchPlays" app designed to simulate keystrokes that twitch chat sends it.

I attached it to OBS and using the PostMessage method I was able to turn the overlay on and off. Now I just need to google how postmessage works lol
 

MattEatsMochi

New Member
As this never really received a proper answer, I wanted to loop around with a solution I found.
Ended up creating a handshake with AutoHotkey that grabs the SendKeys stroke and sends it directly to OBS.

the following simply grabs f7 and sends it to OBS (as mentioned above).

F7::
SetTitleMatchMode, 2
ControlSend, Qt5QWindowIcon9, {F7}, OBS
return​

There are obviously better solutions, some presented in this thread, but this was the most straight forwards answer I found to sending simulated keystrokes in order to changes scenes.
 

Suslik V

Active Member
General suggestions, for hotkeys use: same privileges for both applications (receiver<>sender), holding down time ~10ms (shorter events maybe unrecognized).
 
Top