hi just me,
Thanks for the info. The second point you make about changing the text once the button is created is what I am after. I already have that code in my script:
Code: Select all
#NoEnv ; Recommended for performance and compa tibil ity with future AutoHotkey releases.
#SingleInstance, Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;https://autohotkey.com/docs/Tutorial.htm#s24
;=============================================================
;Global variables
;-------------------------------------------------------------
global PauseFlag = 1
;-------------------------------------------------------------
;gui layout
;-------------------------------------------------------------
GuiOpen:
Gui, font, cwhite
;Buttons
;First column
Gui, add, button, x5 y5 w75 h50 gOnTop, On top toggle
Gui, add, button, y+20 w75 h50 gClose, Close program
Gui, add, button, y+5 w75 h50 gThree, 3 Minimise
;....there are more here....
;Bigger buttons
Gui, add, button, y+5 w75 h50 glaunch_Gui2, 20 gui 2
Gui, add, button, y+20 w75 h50 gToggleOnOff, On ;this is the button in question
;-------------------------------------------------------------
;GUI setup
;-------------------------------------------------------------
Gui, +alwaysontop
Gui, +LastFound +AlwaysOnTop +ToolWindow +Border +E0x08000000
Gui, color, black
;-------------------------------------------------------------
Gui, show, x5 y5 w85 h600 NoActivate, Gui 1 ;NoActivate means the window doesn't ever get 'selected'
Return
;=============================================================
;Labels
;-------------------------------------------------------------
GuiClose:
ExitApp
return
;....more button labels....
ToggleOnOff:
Suspend
Pause,,1
If PauseFlag = 1
{
;If PauseFlag = 1, then they are currently active; toggle to off.
GuiControlGet, ButtonText ;is it because it doesn't know which control?
GuiControl,, ButtonText, Off
PauseFlag = 0
}
Else If PauseFlag = 0
{
;If PauseFlag = 0, then they are currently inactive; toggle to on.
PauseFlag = 1
GuiControlGet, ButtonText
GuiControl,, ButtonText, On
}
Return
Is it because my script can't work out which button I'm trying to change?