0
votes

I have a short script that sends Ctrl + Shift + Function Keys with AHK, since those are the hotkeys I've set up for switching scenes in OBS, but I'm not having any luck. Once the script is running, it seems like it's sending out the keys, but for some reason OBS isn't switching. If I enter the hotkey by hand, then it does switch OBS, so I don't know why AHK isn't "triggering" it the same way.

This is my script:

Loop{
 SendInput ^+{F11}
 Sleep 3000

 SendInput ^+{F12}
 Sleep 3000

 SendInput ^+{F11}
 Sleep 3000
}
2

2 Answers

1
votes

Try this:

Loop {
ControlSend,, {Ctrl down}{F11}{Ctrl up}, ahk_class OBSWindowClass
Sleep 3000
ControlSend,, {Ctrl down}{F12}{Ctrl up}, ahk_class OBSWindowClass
Sleep 3000
ControlSend,, {Ctrl down}{F11}{Ctrl up}, ahk_class OBSWindowClass
Sleep 3000
}
0
votes

Got it. The trick was to not use hotkeys at all (thank God, since they have the possibility to cause input when it's not wanted if the hotkey is used by another program), but to access the elements of the OBS application directly.

My new full script is as follows:

Loop {
Control, ChooseString, Scene 1 Name, ListBox1, ahk_class OBSWindowClass
Sleep 30000
Control, ChooseString, Scene 2 Name, ListBox1, ahk_class OBSWindowClass
Sleep 30000
}

Help from this forum page here https://autohotkey.com/board/topic/88151-obs-hotkeys-not-being-triggered/

And also, the program called "Active Window Info (Window Spy)" that installs with AHK was very helpful with all of this.