How can many GUIs be used simultaneously? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Albireo
Posts: 1285
Joined: 16 Oct 2013, 13:53

How can many GUIs be used simultaneously?

04 Apr 2020, 05:20

Tried to replace a MsgBox to a GUI instead.
(The GUI is easier to handle - in one way)

My wish is that e.g. an error message should be placed in front of the main GUI. If the main GUI is moved, the message is moved too.
(and I find it more complicated to handle a MsgBox in that way)

I have tried to use two GUI at the same time.
It seems to work if there is no button on the second GUI.
A little test of Two GUI at the same time
Albireo
Posts: 1285
Joined: 16 Oct 2013, 13:53

Re: How can many GUIs be used simultaneously?

08 Apr 2020, 13:57

This AHK-program, works almost as intended. The main window has no problem.
AHK-program with two GUI
When the Cancel is pressed a second - green GUI is opened with two buttons (No! and Yes!) No! and Yes! works as intended.
If the green GUI closes with the cross (in the upper right) the green GUI closes (as intended)

But if I also want to close the main GUI with the cross in the upper right - the whole program crashes.

The following error occurred .:
  • ---------------------------
    Error: The same variable cannot be used for more than one control.

    Specifically: vCloseInfo1

    Line#
    035: WinGet,GuiPid,PID,%A_ScriptName%
    036: WinGetPos,PosX,PosY,Width,Height,ahk_pid %GuiPid%
    038: PosX += 20
    039: PosY += 20
    040: Gui,2: +AlwaysOnTop
    041: Gui,2: Color,Green
    043: Gui,2: Font,cSilver s16 Bold,Verdana
    ---> 044: Gui,2: Add,Text,x20 y10 h25 w210 Center vCloseInfo1,Information!
    046: Gui,2: Font,cWhite s14 Bold,Verdana
    047: Gui,2: Add,Text,x20 y50 h60 w210 Center vCloseInfo2,Do you want to quit the program?
    049: Gui,2: Add,Button,x30 y120 h40 w80 center vButt1 gButtCloseNo,No!
    050: Gui,2: Add,Button,x130 y120 h40 w80 center +default vButt2 gButtCloseYes,&Yes
    051: Gui,2: Show,x%PosX% y%PosY% h190 w250,Programslut!
    052: Return
    054: Gui,2: Destroy

    The current thread will exit.
    ---------------------------
User avatar
Hellbent
Posts: 1058
Joined: 23 Sep 2017, 13:34

Re: How can many GUIs be used simultaneously?  Topic is solved

08 Apr 2020, 14:14

Change:

Code: Select all

Gui 2: +AlwaysOnTop
To:

Code: Select all

Gui 2: New, +AlwaysOnTop
***Edit***

What is up with this?

Code: Select all

Gui 2: Show, x%PosX% y%PosY% h190 w250, Programslut!
Is that a typo? :lol:
Albireo
Posts: 1285
Joined: 16 Oct 2013, 13:53

Re: How can many GUIs be used simultaneously?

08 Apr 2020, 14:47

Thanks!
Hellbent wrote:
08 Apr 2020, 14:14

Code: Select all

Gui 2: New, +AlwaysOnTop
This was the solution!

Hellbent wrote:
08 Apr 2020, 14:14
What is up with this?

Code: Select all

Gui 2: Show, x%PosX% y%PosY% h190 w250, Programslut!
This causes the second window to follow and be placed on top of the main window (with an offset +20)

Code: Select all

WinGet GuiPid, PID, %A_ScriptName%
WinGetPos PosX, PosY, Width, Height, ahk_pid %GuiPid%
PosX += 20
PosY += 20
...   ...   ...
Gui 2: Show, x%PosX% y%PosY% h190 w250, Programslut!
I didn't come up with any better way to do this ;)
User avatar
Hellbent
Posts: 1058
Joined: 23 Sep 2017, 13:34

Re: How can many GUIs be used simultaneously?

08 Apr 2020, 15:00

Albireo wrote:
08 Apr 2020, 14:47
Hellbent wrote:
08 Apr 2020, 14:14
What is up with this?

Code: Select all

Gui 2: Show, x%PosX% y%PosY% h190 w250, Programslut!
This causes the second window to follow and be placed on top of the main window (with an offset +20)
That's not what I was referring to. :silent: :lol: :silent:

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], boiler, Finallf and 34 guests