2017-06-04 8 views
-2
in Schleife

ich Probleme mit dem folgenden Code habe. Ich versuche, die Schleife Kaution zu haben und zu einem Setup() Funktion gehen, wenn Sie die TAB-Taste gedrückt wird. Wenn ich jedoch TAB drücke, passiert nichts, es geht einfach weiter, bitte helfen!AutoIt _IsPressed woking nicht

While -1 
    While -1 
     WinActivate($PID) 
     Sleep(1000) 
     Send("Hello") 
     $timer = TimerInit() 
     While -1 
      PixelSearch($searchL,$searchT,$searchR,$searchB,"0x" & Hex($color,6),10,1) 
--->  If _IsPressed("09",$dll) Then ExitLoop 3 ;HERE IS THE CODE THAT IS NOT WORKING 
      If @error <> 1 Then ExitLoop 
      If TimerDiff($timer) > 1000 Then 
       Sleep(1000) 
       WinActivate($PID) 
       ExitLoop 2 
      EndIf 
     Wend 
     $timer = TimerInit() 
     MouseMove($shade[0], $shade[1]) 
     While -1 
      PixelSearch($shade[0]-10,$shade[1]-10,$shade[0]+10,$shade[1]+10,"0x" & Hex($color,6),10,1) 
--->  If _IsPressed("09",$dll) Then ExitLoop 3 ;HERE IS THE CODE THAT IS NOT WORKING 
      If @error = 1 Then ExitLoop 
      If TimerDiff($timer) > 5000 Then 
       Sleep(1000) 
       WinActivate($PID) 
       Exitloop 2 
      EndIf 
     Wend 
    Wend 
Wend 
Setup() 
EndFunc 
+2

Können Sie [MCVE] (http://stackoverflow.com/help/mcve) bereitstellen? –

Antwort

0

Ich nehme an, Sie haben ein Problem mit der $dll Variable. Es ist wahrscheinlich nicht initialisiert. Einfach loswerden. Dieses kleine Beispiel funktioniert gut:

#include <Misc.au3> 

MsgBox(0, "1 loop", "Now testing with 1 loop.") 
While -1 
    If _IsPressed("09") Then 
     MsgBox(0, "_IsPressed", "You pressed the TAB key.") 
     ExitLoop 
    EndIf 
WEnd 

MsgBox(0, "3 loops", "Now testing with 3 loops.") 
While -1 
    While -1 
     While -1 
      If _IsPressed("09") Then 
       MsgBox(0, "_IsPressed", "You pressed the TAB key.") 
       ExitLoop 3 
      EndIf 
     WEnd 
    WEnd 
WEnd 

MsgBox(0, "_IsPressed", "Test done.")