title: AutoIT WinWaitActive doesn't uderstands that window is active
body: <p>I want to get pixel color from a game and react.
  So I have this sript:</p>
  
  <pre><code>#include &lt;Color.au3&gt;
  
  Local $pause = False;
  
  $WinName = "Game" ; Let's say there is a game with this name =)
  $hwnd = WinGetHandle($WinName) ; Checked handle with powershell and Au3Info, handle is correct
  
  local $res
  
  Opt("PixelCoordMode", 2);
  
  HotKeySet("{F10}", "exitNow");
  HotKeySet("{F11}", "Pause");
  
  While 1
     ;WinWaitActive($hwnd) ; The script stops here if it is uncommented no matter if window is active or not
      if ( $pause ) Then
        $res = GetPos();
        ConsoleWrite ( StringFormat ("Result color: %s %s", $res[0], $res[1] ) )
        Sleep (1000)
      EndIf
  WEnd
  
  Func exitNow()
      Exit
  EndFunc
  
  Func Pause()
      $pause = Not $pause
  EndFunc
  
  Func GetPos()
      local $var = Hex(PixelGetColor(5, 5, $hwnd)) ; Only works in windowed mode, FullScreen return some random colors like 00FFFFFF or 00AAAAAA
      $var = StringTrimLeft($var,2) ; Removing first 2 numbers they r always 00
      local $var1 = Hex(PixelGetColor(15, 5, $hwnd)) ; Only works in windowed mode, FullScreen return some random colors like 00FFFFFF or 00AAAAAA
      $var1 = StringTrimLeft($var1,2) ; Removing first 2 numbers they r always 00
      local $result[2] = [ $var, $var1 ]
      return $result
  EndFunc
  </code></pre>
  
  <p>Main script should before window is active and only then should try to <strong>GetPixelColor</strong> but that never happens, no matter what I do, i've tried <strong>WindowActivate</strong> still no result.</p>
  
  <p><strong>a)</strong> - What am I doing wrong ? Or may be there is another way to check if window is currently active ?</p>
  
  <p>So at the moment I start script disabled, and when I activate window manually I press <strong>F11</strong> to enable.</p>
  
  <p><strong>b)</strong> - <strong>PixelGetColor</strong> only works if game is running in Windowed mode, if it's a fullscreen mode result is unpredictable. Is there a way to make <strong>PixelGetColor</strong> work in fullscreen.</p>
  
  <p>I've tried to run game x32, x64, DX9 and DX11 in different combinations Fullscreen result is just wrong.</p>
  
  <p><strong>ADDED:</strong></p>
  
  <p>Now While looks like this and that works :)
  Thanks to Xenobeologist!!! </p>
  
  <pre><code>While 1
      $hwnd = WinGetHandle('[Active]');
      If ( $pause ) Then
          If WinGetTitle($hwnd) &lt;&gt; $WinName Then
              Pause()
              ContinueLoop
          EndIf
          $res = GetPos();
          ConsoleWrite ( StringFormat ("Result color: %s %s", $res[0], $res[1] ) )
          Sleep (1000)
      Else
          If WinGetTitle($hwnd) = $WinName Then
              Pause()
              ContinueLoop
          EndIf
      EndIf
  WEnd
  </code></pre>
  
  <p><strong>a)</strong> is now solved</p>
  
  <p><strong>b)</strong> is still not solved. One more thing, topic of this question doesn't say anything bout this question, should add info bout this into the topic or it's better to start a new thread? <strong>a)</strong> was my main question, it would be prefect to solve b) as well but I can live without it. As far as I understood it's much more complicated. What do you think?</p>
  
  <p><strong>ADDED2:</strong></p>
  
  <p>As far as I understand problem <strong>b)</strong> can be solved by using more complex code. Here <a href="http://www.autohotkey.com/board/topic/63664-solved-imagesearch-failure-wdirectx-fullscreen-gamewin7/" rel="nofollow">http://www.autohotkey.com/board/topic/63664-solved-imagesearch-failure-wdirectx-fullscreen-gamewin7/</a> was discussed pretty same problem. It's AHK and ImageSearch function, but im pretty sure that the reason I get wrong colours in fullscreen is the same. I don't want to complicate code that much and PrintScreen is too slow so I'll use windowed mode and wont be bothering with <strong>b)</strong>. </p>