首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AutoHotKey刷新Gui

AutoHotKey刷新Gui
EN

Stack Overflow用户
提问于 2020-07-16 02:54:11
回答 1查看 192关注 0票数 0

简单的代码。现在我想在我的监视器上实时看到变量,所以我做了一个gui。

Gui I made

但是,无论我做什么,它都不会更新,并且停留在0。我搜索了文档和示例,但仍然没有任何线索。这是我到目前为止的代码:

代码语言:javascript
复制
Gui, Font, s32, impact
Gui, Color, EEAA99
WinSet, TransColor, EEAA99
Gui -Caption +AlwaysOnTop +ToolWindow
Gui, Add, Text, , CC: %ConsCount%
Gui, Add, Text, , LN: %LastN%
Gui, Add, Text, , LR: %LastR%
Gui, Add, Text, , LS: %LastSpace%
Gui, Show, NoActivate X0 Y0
SetTimer, Loop, On



Loop:
SetTimer, Loop, off
Sleep, 2
SetTimer, Loop, reset

我知道这没有任何意义,但我真的不知道该怎么办。

EN

回答 1

Stack Overflow用户

发布于 2020-07-20 02:41:11

这可能会有帮助,按F1添加或F2减去。

代码语言:javascript
复制
Gui, Font, s32, impact
Gui, Color, EEAA99
WinSet, TransColor, EEAA99
Gui, -Caption +AlwaysOnTop +ToolWindow
vararr := {"ConsCount": 0, "LastN": 0, "LastR": 0, "LastSpace": 0} ; Array contains the gui controls variables names and it values as 0.
For key, val in vararr                                             ; Loop throw vararr array keys and values.
    Gui, Add, Text, v%key% w9, %key%: %val%                        ; Add the variable name and it value to the gui.
Gui, Show, NoActivate X0 Y0
Return

F1::                                                               ; Press F1
For key, val in vararr
{
    val++                                                          ; Add +1 to the previous value of the variable.
    GuiControl,, %key%, %key%: %val%                               ; Update the gui to show the new value.
    vararr[Key] := val                                             ; Replace the old values of the variable with the new one in the array.
}
Return

F2::                                                               ; Press F2
    For key, val in vararr
    {
        val--                                                      ; Add -1 to the previous value of the variable.
        GuiControl,, %key%, %key%: %val%
        vararr[Key] := val
    }
Return
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62921929

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档