正在运行while循环时更改AHK标签文本

问题描述 投票:0回答:1

AHK脚本的新手,只是学习了如何使用ImageSearch,但是现在我想通过创建状态来提高脚本的生活质量。例如,当脚本正在运行时,我希望有一个标签文本,以便让我知道脚本在尝试查找图像时正在运行,反之亦然,以了解脚本是否未运行。试图在while循环运行时以及未运行但似乎无法正常运行时更改标签文本。感谢您的帮助,因为我是新来的。谢谢!

        Gui,2:Add,Button,x10 y10 w200 h40 gFind_Image ,Start Image Search
        Gui,2:Add,Button,x10 w200 h40 gGui_1,Load / Reload image
        Gui,2:Add, Button,x10 w200 h40 gStop_Music, Stop Music
        Gui,2:Add, Text, x10, Press Numpad 1 to stop `n  
        Gui,2:Add, Text, vStartStop x10,  Stop
        Gui,2:Add, Text,x20
        Gui,2:Show, x1000 y300, Image search
        return



    2GuiClose:
        ExitApp


; StartStop:
; GuiControlGet, Text
;     if (Stop:=0) 
;     {
;         GuiControl,, Text, Stop
;         Gosub, Start
;     }
;     else if (Stop:=1)
;     {
;         GuiControl,, Text, Start
;         Gosub, Stop
;     }
; return

MyTimer: 
if (A_sec <> 10)
return
Settimer, MyTimer, off 


Find_Image:

    Stop:= 0
    While(Stop=0)
        {


            ;ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile
            ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, wizet.png

                if(ErrorLevel = 1)
                {
                    ;
                    Traytip,, Image not found, 1
                    Sleep, 2000

                }
                else if (ErrorLevel = 0)
                {
                    ;play sound as image is found 
                    musicPlay:= 0             
                    ;SoundPlay, %W%, wait]
                    Stop:=1
                }    
        }

    return
text label autohotkey
1个回答
0
投票

看来,您提供的代码只是脚本的一部分。我相信您尝试使用GuiControl。这是在这种情况下使用的正确命令。

您已经使用vStartStop设置了控件的GUI ID,因此要修改文本,您必须执行以下操作。

GuiControl,, StartStop, My new text here...

[我相信您会希望在while循环的开头插入一个GuiControl,, StartStop, search running...之类的语句,而在while循环之后插入一个GuiControl,, StartStop, search stopped...之类的语句。

© www.soinside.com 2019 - 2024. All rights reserved.