这个程序如何退出才好?
这是一个很简单发送无限按键的程序,但是我每次强制退出的后,游戏一直会受到最后一个按键影响很长一段时间。(比如强制退出前的最后一次按键是“下”,那么游戏程序就一直受到“下”的命令,过了很久才恢复)。不知有啥解决办法~~?
#Include <PostMessage_UDF.au3>
$i=1
$key=0
While 1
$hWnd=WinGetHandle("NO$Zoomer")
;MsgBox(0,"a",$i)
If $i = 1 Then
takeStep($hWnd, "right")
ElseIf $i = 2 Then
takeStep($hWnd, "up")
ElseIf $i = 3 Then
takeStep($hWnd, "left")
ElseIf $i = 4 Then
takeStep($hWnd, "down")
;MsgBox(0,"zzzzzzzzzzzzz","")
$i=0
EndIf
;MsgBox(0,"c",$i)
$i = $i + 1
;MsgBox(0,"b",$i)
WEnd
Func takeStep($hWnd,$key)
$j=100
While $j > 0
_ArrowKey($hWnd, $key)
$j=$j-1
WEnd
EndFunc
#include <PostMessage_UDF.au3>
HotKeySet('{Esc}', '_ExitLoop')
Local $i = 1, $key = 0, $FExit = 0, $hWnd
$hWnd = WinGetHandle("NO$Zoomer")
While IsHWnd($hWnd) And Not $FExit
Sleep(1)
If $i = 1 Then
takeStep($hWnd, "right")
ElseIf $i = 2 Then
takeStep($hWnd, "up")
ElseIf $i = 3 Then
takeStep($hWnd, "left")
ElseIf $i = 4 Then
takeStep($hWnd, "down")
$i = 0
EndIf
$i += 1
WEnd
MsgBox(64, 'ok', '已退出 ')
Func takeStep($hWnd, $key)
$j = 100
While $j > 0 And Not $FExit
_ArrowKey($hWnd, $key)
$j -= 1
Sleep(1)
WEnd
EndFunc ;==>takeStep
Func _ExitLoop()
$FExit = 1
EndFunc ;==>_ExitLoop
学习了!!!
页:
[1]