找回密码
 加入
搜索
查看: 1427|回复: 3

HotKeySet的问题!高手们帮忙

[复制链接]
发表于 2008-11-28 12:22:41 | 显示全部楼层 |阅读模式
这个代码要怎么才能实现,当我按了F9以后循环执行操作,当再一次按F9或者按其他一个键的时候,可以终止这个循环操作,但是不退出程序?
HotKeySet('{F9}','HOT')
$Ran = Random(2000,2300,100)

While 1
        Sleep(2000)
WEnd

Func HOT()
        While 1
                If PixelGetColor(740,366)=13677996 Then
                        MouseClick("left", 477, 487, 1,1)
                ElseIf PixelGetColor(508,407)=16724940 Then
                        Send('{BS}')
                EndIf
                Sleep($Ran)
        WEnd
EndFunc

[ 本帖最后由 superflq 于 2008-11-28 18:57 编辑 ]
发表于 2008-11-28 14:57:21 | 显示全部楼层
我一直用下面这种方式处理这种问题,当然这并不是最好的方法。如果哪位还有更好的方法也请告诉我。。

HotKeySet('{F9}','HOT')
HotKeySet('{F10}','_return')     ;F10返回
Global $return_flag = 0         ;返回标志
Global $run_flag = 0            ;运行中标志
$Ran = Random(2000,2300,100)

While 1
        Sleep(2000)
WEnd

Func HOT()
        if $run_flag <> 0 Then    ;若运行标志不为0
                Return                ;直接返回
        Else
                $run_flag = 1         ;设置运行标志为1
        EndIf
       
        While 1
                        if $return_flag = 1 Then     ;如果返回标志为1
                                $return_flag = 0          ;设置返回标志为0
                                Return                    ;返回
                        EndIf
                If PixelGetColor(740,366)=13677996 Then
                        MouseClick("left", 477, 487, 1,1)
                ElseIf PixelGetColor(508,407)=16724940 Then
                        Send('{BS}')
                EndIf
                Sleep($Ran)
        WEnd
EndFunc

Func _return()
        if $run_flag = 1 Then    ;如果运行标志为1  表示hot 函数正在执行
                $return_flag = 1     ;设置返回标志为1
                $run_flag = 0         ;设置运行标志为0
        EndIf
       
EndFunc
发表于 2008-11-28 17:20:12 | 显示全部楼层
帮助本身就有相关例子。


Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d

;;;; Body of program would go here ;;;;
While 1
        Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
        $Paused = NOT $Paused
        While $Paused
                sleep(100)
                ToolTip('Script is "Paused"',0,0)
        WEnd
        ToolTip("")
EndFunc

Func Terminate()
        Exit 0
EndFunc

Func ShowMessage()
        MsgBox(4096,"","This is a message.")
EndFunc
 楼主| 发表于 2008-11-28 18:54:16 | 显示全部楼层
$Paused = NOT $Paused
解决问题,谢谢三恨
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-6 02:15 , Processed in 0.073373 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表