GUI help needed

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mrdigitalis
Posts: 67
Joined: 23 May 2022, 01:17

GUI help needed

Post by mrdigitalis » 02 Oct 2022, 13:10

Dear form-members,

I need a simple GUI box (just like a msgbox), where I can show the program status / progress / flow.

I put it in a function, and I will call it one time and after that, I want that
the updated letters (A - E) will show up. One after another.
But I have this error:
image.png
image.png (25.69 KiB) Viewed 458 times
What can I do to improve this?

Thanks in advance!

This is what I have right now:

Code: Select all

Progress_GUI_Box(Update_TXT)
{
  Gui,+AlwaysOnTop
  GUI_Titel := "Bla bla"
  gui, Font, s12
  Gui, Add, Edit, x2 y-1 w670 h150 gTXT vUpdater_TXT, %Update_TXT% 
  Gui, Show, x1356 y86 h158 w682, %GUI_Titel%
  TXT:
  GuiControl,,Updater_TXT, %Update_TXT%
  return
}

^q::
Progress_GUI_Box(Update_TXT)
Update_TXT := "A"
sleep 1000
Update_TXT := "B"
sleep 1000
Update_TXT := "C"
sleep 1000
Update_TXT := "D"
sleep 1000
Update_TXT := "E"
sleep 1000

User avatar
boiler
Posts: 16911
Joined: 21 Dec 2014, 02:44

Re: GUI help needed

Post by boiler » 02 Oct 2022, 15:28

You might try declaring the variable as global or static like the error message says:

Code: Select all

global Updater_TXT

User avatar
mikeyww
Posts: 26869
Joined: 09 Sep 2014, 18:38

Re: GUI help needed

Post by mikeyww » 02 Oct 2022, 15:32

Changing your variable does not automatically call your function again.

Here is one example that may help.

Code: Select all

^q::
progress_GUI_Box("A")
Sleep, 1000
progress_GUI_Box("B")
Return

progress_GUI_Box(text) {
 Static guiTitle := "Bla bla", txt
 If !WinExist(guiTitle " ahk_class AutoHotkeyGUI") {
  Gui, +AlwaysOnTop
  Gui, Font, s12
  Gui, Add, Edit, w250 r10 vtxt ReadOnly
  Gui, Show,, %guiTitle%
 }
 GuiControl,, txt, % txt .= (txt > "" ? "`n" : "") text
}

mrdigitalis
Posts: 67
Joined: 23 May 2022, 01:17

Re: GUI help needed

Post by mrdigitalis » 03 Oct 2022, 14:11

@boiler thank you!

@mikeyww
Changing your variable does not automatically call your function again.
Yes that makes sense! Thanks for the perfect example!

Post Reply

Return to “Ask for Help (v1)”