title: Switch Scene in OBS Studio using Hotkeys based on Current Monitor Mouse Position
body: <p>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.</p>
  
  <p>I've got a somewhat working example, but with problems and I need help sorting those out.</p>
  
  <p>Here's my attempt:</p>
  
  <pre><code>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 &gt;= 1806)
          controlSend,,{NumPad2}, ahk_class Qt5QWindowIcon
      Else
          controlSend,,{NumPad1}, ahk_class Qt5QWindowIcon
  
  }
  
  Esc::ExitApp
  </code></pre>
  
  <p>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.</p>
  
  <ol>
  <li>I need that to be fixed.</li>
  <li>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.</li>
  <li>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).</li>
  </ol>
  
  <p>Here is my monitor setup:</p>
  
  <p><a href="https://i.stack.imgur.com/RxhZe.png" rel="nofollow">My Multi Monitor Setup</a></p>
  
  <p>Any help would be greatly appreciated!  Thanks!</p>