0
votes

So, I'm kinda new to ahk...made a program that when I press a specific key, a variable goes up, and when I press another key, the variable become 0. Simple Code. Now I want to see the variable on my monitor in real-time, so i made a gui.

Gui I made

But, It does not update and is stuck at 0 no matter what I do. I searched for documents and examples, but still haven't got any clue. This is my code so far:

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

I know It makes no sense at all, but I really have no idea what to do.

1

1 Answers

0
votes

That might help, Press F1 to add or F2 to substract.

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