title: Differentiate between multiple instances of same program
body: <p>How to target processes by PID? I have multiple instances of the same program active at the same time, but my code only works for one. I want to target all instances.</p>
  
  <p>So where to put the PID (I mean the first line) or how else to differentiate between multiple instances?</p>
  
  <pre><code>Global $WindowTitle = "World of Warcraft"
  
  Global $PauseKey = "{F7}"
  Global $TerminateKey = "{F8}"
  Global $PVPOpenKey = "{h}"
  Global $MacroBindKey = "{8}{a}"
  
  Global $Paused = False
  
  HotKeySet( $PauseKey, "Pause" )
  HotKeySet( $TerminateKey, "Terminate" )
  
  While 1
      If Not $Paused Then
          ControlSend( $WindowTitle, "", 0, $PVPOpenKey )
          Sleep( 5000 )
          ControlSend( $WindowTitle, "", 0, $MacroBindKey )
      EndIf
  
      Sleep( 500 )
  WEnd
  
  Func Pause()
      $Paused = Not $Paused
  EndFunc
  
  Func Terminate()
      Exit
  EndFunc
  </code></pre>