【问题标题】:AutoHotKey Refresh GuiAutoHotKey 刷新 GUI
【发布时间】:2020-07-15 18:54:10
【问题描述】:

所以,我对 ahk 有点陌生...做了一个程序,当我按下一个特定的键时,一个变量上升,当我按下另一个键时,变量变为 0。 简单的代码。现在我想在我的显示器上实时查看变量,所以我做了一个 gui。

Gui I made

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

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

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

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

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

    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
    

    【讨论】:

      猜你喜欢
      • 2018-09-18
      • 2014-08-28
      • 2015-02-08
      • 2012-03-09
      • 2019-11-30
      • 2012-01-17
      • 2015-11-17
      • 2014-09-11
      • 1970-01-01
      相关资源
      最近更新 更多