multiple GUI start in one script? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

multiple GUI start in one script?

13 Feb 2019, 23:40

multiple GUI start in one script. possible?

this shows only one GUI:
Gui, Show, NoActivate x+%x% y%y%,titleOrSo2
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: multiple GUI start in one script?

14 Feb 2019, 02:01

to make more of the same gui use Gui New, assign it a handle, then use the handle to refer to each newly created gui:

Code: Select all

if(1){
; Get Current Position
	SysGet,Mon_BboxNew_,Monitor,0
	y := Mon_BboxNew_Bottom -  170
	x := Mon_BboxNew_Right -  170

	hwndGui1 := newGui()
	Gui, %hwndGui1%:Show, NoActivate x+%x% y%y%,titleOrSo

	y := Mon_BboxNew_Bottom -  270
	x := Mon_BboxNew_Right -  270

	hwndGui2 := newGui()
	Gui, %hwndGui2%:Show, NoActivate x+%x% y%y%,titleOrSo2
}


newGui() {
	Gui, New, +AlwaysOnTop +ToolWindow -SysMenu -Caption +Hwndhwnd ; <<< this here
	Gui, Font,  cWhite s10 q1, Arial Narrow ;red ; changed s11 to s10
	str := "huibuhh huibuhh huibuhh huibuhh huibuhh huibuhh huibuhh "
	Gui, Add, Text, vD y0 , %str%

	return hwnd
}
a class is probably a saner way to manage this
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: multiple GUI start in one script?

14 Feb 2019, 02:55

Error: A control's variable must be global or static.

Specifically: vD
---> 040: Gui,Add,Text,vD,%str%
the same error here. it shows the first gui and shows the error by running the second:

Code: Select all

newGui2(200,"titleOrSo1902121943")
WinSet, AlwaysOnTop, On, titleOrSo1902121943
FormatTime, timestampHHmmss, %A_now%,HH:mm:ss
GuiControl, , D, %timestampHHmmss% %return_from_LineNumber%:%actionList% | %activeTitle%
; ^- works

newGui2(100,"title1902141119")
; ^- works not

newGui2(y , title ) {
	global
	; global vD, str
; Get Current Position
	SysGet,Mon_BboxNew_,Monitor,0
	; y := Mon_BboxNew_Bottom -  170
	x := Mon_BboxNew_Right -  170
	
	Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption
	Gui, Color, green
	Gui, Font,  cWhite s10 q1, Arial Narrow ;red ; changed s11 to s10
	str := "huibuhh huibuhh huibuhh huibuhh huibuhh huibuhh huibuhh "
	Gui, Add, Text, vD y0 , %str%
	; Gui, Add, Text, D y0 , %str% ; invalid option
	;GuiControl, , D, %timestampHHmmss% %return_from_LineNumber%:%actionList% | %activeTitle%
	Gui, Show, NoActivate x+%x% y%y%,%title% ; screen position here
	
	; y := Mon_BboxNew_Bottom -  270
	x := Mon_BboxNew_Right -  270
	Gui, Show, NoActivate x+%x% y%y%,%title% ; screen position here
	
	
	; WinSet, TransColor, green 255,titleOrSo ; 255 is max tansparent
	
	
}

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: multiple GUI start in one script?  Topic is solved

14 Feb 2019, 05:36

global works
global D works. the variable is called D, not vD
ur second script wont work correctly, since u arent using Gui New
no, Gui +.... +... +... is not the same as Gui New
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: multiple GUI start in one script?

14 Feb 2019, 06:08

swagfag wrote:
14 Feb 2019, 05:36
global works
global D works. the variable is called D, not vD
ur second script wont work correctly, since u arent using Gui New
no, Gui +.... +... +... is not the same as Gui New
thanks. i read https://autohotkey.com/docs/commands/Gui.htm
and i dont understand.
i changed
all Gui to Gui New and got errors. diffucult thnk.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: multiple GUI start in one script?

14 Feb 2019, 06:14

works. I did a full-text search through all 1000 scripts that I have on my hard drive.
thanks
only at first entry:

Gui New, +AlwaysOnTop +ToolWindow -SysMenu -Caption

later

Gui ...

Code: Select all

newGui2(200,"titleOrSo1902121943")
WinSet, AlwaysOnTop, On, titleOrSo1902121943
FormatTime, timestampHHmmss, %A_now%,HH:mm:ss
GuiControl, , D, %timestampHHmmss% %return_from_LineNumber%:%actionList% | %activeTitle%
; ^- works

newGui2(100,"title1902141119")
; ^- works 

newGui2(y , title ) {
	global D ; global D works. the variable is called D, not vD
	; Get Current Position
	SysGet,Mon_BboxNew_,Monitor,0
	; y := Mon_BboxNew_Bottom -  170
	x := Mon_BboxNew_Right -  170
	
	Gui New, +AlwaysOnTop +ToolWindow -SysMenu -Caption
	Gui, Color, green
	Gui, Font,  cWhite s10 q1, Arial Narrow ;red ; changed s11 to s10
	str := "huibuhh huibuhh huibuhh huibuhh huibuhh huibuhh huibuhh "
	Gui, Add, Text, vD y0 , %str%
	; Gui, Add, Text, D y0 , %str% ; invalid option
	;GuiControl, , D, %timestampHHmmss% %return_from_LineNumber%:%actionList% | %activeTitle%
	Gui, Show, NoActivate x+%x% y%y%,%title% ; screen position here
	
	; y := Mon_BboxNew_Bottom -  270
	x := Mon_BboxNew_Right -  270
	Gui, Show, NoActivate x+%x% y%y%,%title% ; screen position here
	
	
	; WinSet, TransColor, green 255,titleOrSo ; 255 is max tansparent
	
	
}
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: multiple GUI start in one script?

14 Feb 2019, 08:04

tried change it using handle. something wrong :think:
its changes nothing

Code: Select all

hwndGui1 := newGui()
	Gui, %hwndGui1%:Show, NoActivate x+%x% y%y% ; ,titleOrSo
	
	y := 270
	x := 270
	
	hwndGui2 := newGui()
	Gui, %hwndGui2%:Show, NoActivate x+%x% y%y% ; ,titleOrSo2
	
	
	GuiControl, %hwndGui2%: D, 22222222, ahk_id %hwndGui2%
	GuiControl, %hwndGui1%: D, 11111111, ahk_id %hwndGui1%
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: multiple GUI start in one script?

14 Feb 2019, 08:49

Code: Select all

GuiControl, %hwndGui2%:, 22222222, D
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: multiple GUI start in one script?

14 Feb 2019, 09:26

swagfag wrote:
14 Feb 2019, 08:49

Code: Select all

GuiControl, %hwndGui2%:, 22222222, D
for some reasons this is not working. changes nothing.

Code: Select all

if(1){
; Get Current Position
	SysGet,Mon_BboxNew_,Monitor,0
	y := Mon_BboxNew_Bottom -  170
	x := Mon_BboxNew_Right -  170
	
	hwndGui1 := newGui()
	Gui, %hwndGui1%:Show, NoActivate x+%x% y%y% ; ,titleOrSo
	
	y := Mon_BboxNew_Bottom -  170
	x := Mon_BboxNew_Right -  70
	
	hwndGui2 := newGui()
	Gui, %hwndGui2%:Show, NoActivate x+%x% y%y% ; ,titleOrSo2
	
	
	GuiControl, %hwndGui2%: D, 22222222, ahk_id %hwndGui2%
	
	GuiControl, %hwndGui2%, 22222222, D
	GuiControl, %hwndGui1%, 11111111, D
	; ^- not working

	GuiControl:, %hwndGui2%:, 22222222, D
	GuiControl:, %hwndGui1%:, 11111111, D
	; ^- not working

}


newGui() {
	global D ; global D works. the variable is called D, not vD
	Gui, New, +AlwaysOnTop +ToolWindow -SysMenu -Caption +Hwndhwnd ; <<< this here
	Gui, Color, green
	Gui, Font,  cWhite s10 q1, Arial Narrow ;red ; changed s11 to s10
	loop,200
		str .= "_/\" 
	Gui, Add, Text, vD y0 , %str%	
	return hwnd
}
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: multiple GUI start in one script?

14 Feb 2019, 12:01

Syntax:

Code: Select all

GuiControl, SubCommand, ControlID , Value
=>

Code: Select all

GuiControl, , %hwndGui2%:D, 22222222

As an option:

Code: Select all

If (1){
   ; Get Current Position
   SysGet,Mon_BboxNew_,Monitor,0
   y := Mon_BboxNew_Bottom - 170
   x := Mon_BboxNew_Right - 170

   Gui1 := newGui()
   Gui, % Gui1.HGUI . ":Show", NoActivate x%x% y%y% ; ,titleOrSo

   y := Mon_BboxNew_Bottom -  170
   x := Mon_BboxNew_Right -  70

   Gui2 := newGui()
   Gui, % Gui2.HGUI . ":Show", NoActivate x%x% y%y% ; ,titleOrSo2

   Sleep, 1000
   GuiControl,  , % Gui1.HTXT, 11111111
   GuiControl,  , % Gui2.HTXT, 22222222
}
Return

GuiEscape:
ExitApp

newGui() {
   Gui, New, +AlwaysOnTop +ToolWindow -SysMenu -Caption +HwndHGUI
   Gui, Color, Green
   Gui, Font, cWhite s10 q1, Arial Narrow ;red ; changed s11 to s10
   Loop, 200
      Str .= "_/\"
   Gui, Add, Text, y0 hwndHTXT, %Str%
   Return {HGUI: HGUI, HTXT: HTXT}
}
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: multiple GUI start in one script?

14 Feb 2019, 13:44

just me wrote:
14 Feb 2019, 12:01
Syntax:
GuiControl, SubCommand, ControlID , Value
=> GuiControl, , %hwndGui2%:D, 22222222

As an option:
GuiControl, , % Gui1.HTXT, 11111111
Thanks :-) ! I like your `option` code. Works fine and i dont need a global command inside. everything encapsulated. There are always variants. Surprised. I take these. I think I have the better overview with your `option`. both works.

Thank you all for the help :-) :thumbup: :clap:


update : i changed it a little bit:

Code: Select all

Gui1 := toolTipGui(10,10,"1 1 1 1")
GuiControl,  , % Gui1.HTXT, 11111111
Gui2 := toolTipGui(10,100,"2 2 2 2")
toolTipGui(x, y, text, bgColor := "Green"){
	Gui, New, +AlwaysOnTop +ToolWindow -SysMenu -Caption +HwndHGUI
	Gui, Color, %bgColor%
	Gui, Font, cWhite s10 q1, Arial Narrow ;red ; changed s11 to s10
	Gui, Add, Text, y0 hwndHTXT, %text%
	; Return {HGUI: HGUI, HTXT: HTXT} ; Gui1 := toolTipGui()
	Gui1 := {HGUI: HGUI, HTXT: HTXT}
	Gui, % Gui1.HGUI . ":Show", NoActivate x%x% y%y% ; ,titleOrSo
	return Gui1 ; older: 
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ArkuS, Descolada, Google [Bot] and 109 guests