Hello,
I have 3 OBS scenes that I want to trigger in sequence using one button assigned to my Elgato stream deck. The stream deck has the ability to either run the .AHK program off of a button, or alternatively I could assign the button to a hotkey that triggers the program. I am thinking it would be easiest to assign the 3 scenes to their own hotkeys and trigger them in sequence with a pause in between. I put together a simple script that works the first time but is very unreliable. After it runs the first time, I have to spam the hotkey to trigger the script and it doesn't always run through the entire thing. Sometimes it triggers the first scene and holds, or the second scene and holds. Never in sequence. I could use some help if anyone out there has any input. Here's what I have so far:
Send ^j
Sleep, 1000
Send ^k
Sleep, 1000
Send ^l
return
Thanks!
Trigger 3 OBS scenes with 1 button
Re: Trigger 3 OBS scenes with 1 button
The code below works for me (Windows 10 - x64 bit, OBS 21.1.2 x64 bit). An issue I found with my code was OBS had to be the window in the foreground. I've used OBS before and I highly recommend the plugin "advanced scene switcher" which also has the option for hotkey start/stop --> https://obsproject.com/forum/resources/ ... tcher.395/
If you only want AHK here's what I have. I hope this helps..
If you only want AHK here's what I have. I hope this helps..
Code: Select all
#Persistent ; Keep the script "alive"
#SingleInstance, Force ; Only run 1 instance of the script
Start: ; Gosub/GoTo Label to keep it looping (Delete this entire line to run only once)
Send ^j
Sleep, 1000
Send ^k
Sleep, 1000
Send ^l
Sleep, 1000
Gosub, Start ; Go to the Start Label and loop again
return
^Esc::ExitApp ; stop the script
Re: Trigger 3 OBS scenes with 1 button
Thank you!
This is working perfectly for the most part, I ended up taking the looping stuff out, since I only need it to fire off once. It still hitches every once in awhile and I noticed that the app doesn't fully close, it stays minimized in the toolbar. Could this be causing it to not refresh properly by chance?
This is working perfectly for the most part, I ended up taking the looping stuff out, since I only need it to fire off once. It still hitches every once in awhile and I noticed that the app doesn't fully close, it stays minimized in the toolbar. Could this be causing it to not refresh properly by chance?
Re: Trigger 3 OBS scenes with 1 button
This code worked every time for me but it takes the focus off the active/foreground window to make sure the hotkeys are fired. If you're interested in a work around.. You can use ControlClick. It will click "through" the other windows and click the scenes without putting focus on the OBS window.
Code: Select all
#SingleInstance, Force ; Only run 1 instance of the script
; Check if the OBS window exists
IfWinExist, ahk_class Qt5QWindowIcon
{
; Then activate or focus on it (may not be desirable?)
WinActivate, ahk_class Qt5QWindowIcon
; Wait for the window to be active in the foreground
WinWaitActive, ahk_class Qt5QWindowIcon
Send, ^j
Sleep, 1000
Send, ^k
Sleep, 1000
Send, ^l
Sleep, 10 ; Probably not needed but just in case the hotkey is slow to fire
ExitApp ; Stop the script to run a new instance (probably not needed together with #SingleInstance)
return
}
^Esc::ExitApp ; stop the script
Who is online
Users browsing this forum: CrowexBR, doodles333, vysmaty and 248 guests