Multiple GUI ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
alesyt0h
Posts: 214
Joined: 28 Jan 2015, 20:37

Multiple GUI ?

11 Apr 2019, 11:44

Hello folks.

I have an script for showing a gui depends on a variable number, if var value is 1 then show only that if statement, but if value is 2, show 1 & 2 if statement, if value is 3, then show 1, 2 & 3 statements.

Problem is only showing 1 gui no matter what I try, always showing one gui.

Here is the code

Code: Select all

If (var = "1")
{
	WinGetActiveStats,Title, Width,Height,X,Y 
	Gui,+AlwaysOnTop +ToolWindow -Caption
	Gui, Add,Picture,x1 y1 w32 h32,C:\image.jpg
	Gui, Show,% "x" X + Width - 345 "." "y" Y + Height - 105 "." "w32 h32 NA",
}
If (var = "2")
{
	WinGetActiveStats,Title, Width,Height,X,Y 
	Gui,+AlwaysOnTop +ToolWindow -Caption
	Gui, Add,Picture,x1 y1 w32 h32,C:\image.jpg
	Gui, Show,% "x" X + Width - 365 "." "y" Y + Height - 105 "." "w32 h32 NA",
}
If (var = "3")
{
	WinGetActiveStats,Title, Width,Height,X,Y 
	Gui,+AlwaysOnTop +ToolWindow -Caption
	Gui, Add,Picture,x1 y1 w32 h32,C:\image.jpg
	Gui, Show,% "x" X + Width - 385 "." "y" Y + Height - 105 "." "w32 h32 NA",
}
How can I fix this?

Thank you very much!
Klarion
Posts: 176
Joined: 26 Mar 2019, 10:02

Re: Multiple GUI ?

11 Apr 2019, 12:15

Code: Select all

Loop 10
{
	Gui, % A_Index ": Add", Button, w100, % A_Index
	Gui, % A_Index ": Show", % "x" A_Index * 70 " y" A_Index * 70
}
alesyt0h
Posts: 214
Joined: 28 Jan 2015, 20:37

Re: Multiple GUI ?

11 Apr 2019, 16:44

Klarion wrote:
11 Apr 2019, 12:15

Code: Select all

Loop 10
{
	Gui, % A_Index ": Add", Button, w100, % A_Index
	Gui, % A_Index ": Show", % "x" A_Index * 70 " y" A_Index * 70
}
MMM yes and no, I mean, it does replicate the gui 10 times because of the loop, but it's only working there, when I try to make it work in my script I cannot :( been trying for hours.

This is my script

Code: Select all

	
	Loop 2 {
		WinGetActiveStats,Title, Width,Height,X,Y 
		Gui,+AlwaysOnTop +ToolWindow -Caption
		Gui, Add,Picture,x1 y1 w32 h32,C:\Example.jpg
		Gui, Show,% "x" X + Width - 345 "." "y" Y + Height - 105 "." "w32 h32 NA",
	}
	
	MoveW:
	IfWinNotActive, Documentos
		Gui,Hide
	Else if SelectedFile in %FilesMatchList%
		{
			WinGetActiveStats,Title, Width,Height,X,Y
			Gui, Show,% "x" X + Width - 345 "." "y" Y + Height - 105 "." "w32 h32 NA",
		}
	Else
		Gui,Hide
	Return
when I use A_Index like in your code I cannot retrieve A_Index value outside of a loop for MoveW: (MoveW is the timer for move the gui if I drag the window)

What can I do to make it work?
Klarion
Posts: 176
Joined: 26 Mar 2019, 10:02

Re: Multiple GUI ?

11 Apr 2019, 20:33

so, you want me to do your homework

Code: Select all

InputBox, _,, % "`n`n" "Type a Number"
LoopLoop(_)
LoopLoop(_)
{
	Loop % _
	{
		Gui, % A_Index ": Add", Button, w100, % A_Index
		Gui, % A_Index ": Show", % "x" A_Index * 70 " y" A_Index * 70
	}
}
just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Multiple GUI ?

12 Apr 2019, 05:21

If your GUIs actually differ in other aspects than the number:

Code: Select all

MaxGuiNumber := 99
If Var Is Integer
{
   If Var Between 1 And %MaxGuiNumber%
   {
      If (var = 1)
      {
      	WinGetActiveStats,Title, Width,Height,X,Y
        Gui, %Var%:New
      	Gui, +AlwaysOnTop +ToolWindow -Caption
      	Gui, Add,Picture,x1 y1 w32 h32,C:\image.jpg
      	Gui, Show,% "x" X + Width - 345 "." "y" Y + Height - 105 "." "w32 h32 NA",
      }
      Else If (var = 2)
      {
      	WinGetActiveStats,Title, Width,Height,X,Y
        Gui, %Var%:New
      	Gui,+AlwaysOnTop +ToolWindow -Caption
      	Gui, Add,Picture,x1 y1 w32 h32,C:\image.jpg
      	Gui, Show,% "x" X + Width - 365 "." "y" Y + Height - 105 "." "w32 h32 NA",
      }
      Else If (var = 3)
      {
      	WinGetActiveStats,Title, Width,Height,X,Y
        Gui, %Var%:New
      	Gui,+AlwaysOnTop +ToolWindow -Caption
      	Gui, Add,Picture,x1 y1 w32 h32,C:\image.jpg
      	Gui, Show,% "x" X + Width - 385 "." "y" Y + Height - 105 "." "w32 h32 NA",
      }
      ...
   }
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Theda and 181 guests