Reputation: 11
I'm trying to make a On Screen Display with a count-down in the mouse-position every time I press a key. So far, I was able to make multiple GUIs in the Mouse position every time I press the key and set up a Timer. But for some reason, I'm only capable of updating the last GUI created, even accessing it thru the Remarks.
Tabs := 0
Tab_OSD := 0
count := 0
return
F7::
CreateGUI("Gui" . Tabs)
SetTimer, Tick, 1000
Tabs++
;Tab_OSD := Tabs - 1
;Loop, %Tab_OSD%{
; GuiControl, Text, % "Gui" . A_Index . "", % "" . count . ""
; ;MsgBox, % "Iteration number is Gui" . A_Index . " and " . count
;}
return
CreateGUI(nome) {
MouseGetPos, StartX , StartY
StartX:=StartX-15
StartY:=StartY-15
Gui, % nome . ": New"
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 000001
Gui, Font, s12
WinSet, TransColor, 000001
Gui, % nome . ":Add", Text, cReD , %nome%
Gui, % nome . ":Show", x%StartX% y%StartY% NoActivate
}
Tick:
count++
Gosub, UpdateOSD
return
UpdateOSD:
Tab_OSD := Tabs - 1
Loop, %Tab_OSD%{
GuiControl, Text, % "Gui" . A_Index . "", % "" . count . ""
;MsgBox, % "Iteration number is Gui" . A_Index . " and " . count
}
return
When I try to update the GUIs from the F7:: block (commented), it updates the last GUI. But when I try the same Loop on UpdateOSD, it don't update any Text.
If anyone can give me some light, I would be thankfull.
Upvotes: 0
Views: 131
Reputation: 11
Found a way to make it work. It was missing a control variable in each GUI to update the text.
Another problem was that the name and control variable were being created on a function who didn't allow to use the variables out of that block.
Don't know if I could solve this another way, but creating the GUI on the trigger solved it.
I've also implemented a limit for the counter and Destroy the GUI when it's done.
Tabs := 1
count := 0
return
F7::
MouseGetPos, StartX , StartY
StartX:=StartX-40
StartY:=StartY-40
Gui, % "Gui" . Tabs . ": New",
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 000001
Gui, Font, s16
WinSet, TransColor, 000001
Gui, % "Gui" . Tabs . ":Add", Text, % "vCtrl" . Tabs . " cReD", 00
Gui, % "Gui" . Tabs . ":Show", x%StartX% y%StartY% NoActivate
Tmp%Tabs% := 0
SetTimer, Tick, 1000
Tabs++
return
Tick:
count++
Gosub, UpdateOSD
return
UpdateOSD:
TabOSD := Tabs - 1
Loop, %TabOSD%{
Tmp%A_Index%++
if (Tmp%A_Index% > 45){
Gui, % "Gui" . A_Index . ": Destroy"
Tmp%A_Index% := 0
}
Tempo := Tmp%A_Index%
GuiControl, % "Gui" . A_Index . ":", % "Ctrl" . A_Index . "" , %Tempo%
}
count := 1
return
Upvotes: 1