0
votes

I'm trying to write an autohotkey script that monitors the current Mouse X location and if my mouse moves to my 4th monitor, it should switch a scene in OBS Studio... and if I move my mouse back to my Primary monitor, it should switch the scene back.

I've got a somewhat working example, but with problems and I need help sorting those out.

Here's my attempt:

SetTimer, GetMonitorMouse, 20

GetMonitorMouse()
{
    MouseGetPos, x, y

    SysGet, Mon1, Monitor, 2
    SysGet, Mon2, Monitor, 3
    SysGet, Mon3, Monitor, 1
    SysGet, Mon4, Monitor, 4


    if(x >= 1806)
        controlSend,,{NumPad2}, ahk_class Qt5QWindowIcon
    Else
        controlSend,,{NumPad1}, ahk_class Qt5QWindowIcon

}

Esc::ExitApp

I most definitely did that wrong because it triggers the hotkeys at different X positions depending on what program is the foreground. It really doesn't make sense.

  1. I need that to be fixed.
  2. I need to make it only trigger the hotkey if it detects I've actually moved the mouse to the other monitor. Currently, it triggers once every 20ms, which is very rapid and messes me up when I'm typing things (causes capital letters to become lowercase, etc etc). A simple increase in the ms won't resolve this issue, I need it to be more intelligent.
  3. Optional - Need to figure out how to make "CTRL + SomeHotKey" or "CTRL + SomeHotKey" work because keys will sometimes type into the foreground app I'm trying to use (That's no good).

Here is my monitor setup:

My Multi Monitor Setup

Any help would be greatly appreciated! Thanks!

1

1 Answers

1
votes

Well, I discovered there's a plugin for OBS called "Automatic Scene Switching" which does this 1000x better than any autohotkey script (not hating).

Automatic Scene Switching