How Is This Variable Being Used For More Than One Control? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

How Is This Variable Being Used For More Than One Control?

Post by Mulsiphix » 15 Jan 2022, 22:02

I found an old script in this thread (by SKAN, post #3). I edited it slightly and it is producing an error. I am really new to playing with GUI stuff. I don't understand how to overcome this error. Can anyone explain it to me? Here is the script.

Code: Select all

d::
SetWorkingDir, %A_ScriptDir%
   
Gui +Toolwindow +AlwaysOnTop -Caption +LastFound
Gui1 := WinExist()
WinSet, TransColor, EEAA99
Gui, Margin, 0, 0
Gui, Add, Picture, x0 y0 w128 h128 Hide vMute0 , mute0.png
Gui, Add, Picture, x0 y0 w128 h128 Hide vMute1 , mute1.png
Gui, Show, x100 y100 Hide
Return

HideGUI:
 Gui, Hide
Return

#Esc::
  SoundSet, +1,  , MUTE
  SoundGet, Mute,, MUTE
  If ( MUTE="On" ) {
     GuiControl,Hide,Mute0
     GuiControl,Show,Mute1
  } Else {   
     GuiControl,Hide,Mute1
     GuiControl,Show,Mute0
  }
  SetTimer, HideGUI, -2000
  Gui, Show
Return
The error it returns is:
Image

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

Re: How Is This Variable Being Used For More Than One Control?  Topic is solved

Post by mikeyww » 15 Jan 2022, 22:06

Every time you press the hotkey, you add the same controls, but the previously added ones are already there. Instead, build your GUI in the auto-execute section. You can use your hotkey to show the GUI that was built.

User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: How Is This Variable Being Used For More Than One Control?

Post by flyingDman » 15 Jan 2022, 22:08

or just add gui, 1:new, or gui, destroy at the top.
14.3 & 1.3.7

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

Re: How Is This Variable Being Used For More Than One Control?

Post by mikeyww » 16 Jan 2022, 00:06

An example is below.

Code: Select all

Gui, +ToolWindow +AlwaysOnTop -Caption +LastFound
WinSet, TransColor, EEAA99
Gui, Margin, 0, 0
Gui, Add, Picture,       w128 h128      , mute0.png
Gui, Add, Picture, xm ym wp   hp   vmute, mute1.png

#Esc::
SoundSet, +1,  , MUTE
SoundGet, mute,, MUTE
GuiControl, % mute = "On" ? "Show" : "Hide", mute
SetTimer, HideGUI, -2000
d::Gui, Show, x100 y100
HideGUI:
Gui, Hide
Return

Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

Re: How Is This Variable Being Used For More Than One Control?

Post by Mulsiphix » 16 Jan 2022, 12:58

I see. Thank you very much for your help guys.

Post Reply

Return to “Ask for Help (v1)”