0
votes

How do I Add or remove a GUI Button based on a variable setting ? My thought is if in the ini file I read if it has the 1 it will show Gui, Add, Button, h30 w140 gAEFiles vButton13, Actual hours if is set to 0 it will not show. I have tried several variation without success. Any help I would appreciate it.

if(%AEButton%=1)
{
    gui Tab,Daily
    Gui, Add, Button, h30 w140 gNewfolder vButton14, Make daily folder
    Gui, Add, Button, h30 w140 gdailyfile vButton8, Daily file 
    Gui, Add, Button, h30 w140 gLaborfile vButton9, Labor 
    Gui, Add, Button, h30 w140 gCyclefile vButton10, Cycle Count
    Gui, Add, Button, h30 w140 gGLQueryfile vButton11, gQuery
    Gui, Add, Button, h30 w140 gEarnhoursfile vButton12, Earn Hours
    Gui, Add, Button, h30 w140 gAEFiles vButton13, Actual hours
}
else
{
    gui Tab,Daily
    Gui, Add, Button, h30 w140 gNewfolder vButton14, Make daily folder
    Gui, Add, Button, h30 w140 gdailyfile vButton8, Daily file
    Gui, Add, Button, h30 w140 gLaborfile vButton9, Labor 
    Gui, Add, Button, h30 w140 gCyclefile vButton10, Cycle Count
    Gui, Add, Button, h30 w140 gGLQueryfile vButton11, gQuery
    Gui, Add, Button, h30 w140 gEarnhoursfile vButton12, Earn Hours
}
1

1 Answers

0
votes

Give this a try:

config.ini

[General]
AEButton=1

script.ahk

dailyTabHeight := 250
IniRead, AEButton, config.ini, General, AEButton

If(AEButton = 1) {
    dailyTabHeight += 35 ;make the tab 35 pixels higher
}
Gui, Add, Tab, w165 h%dailyTabHeight%, Daily
Gui, Add, Button, h30 w140 gNewfolder vButton14, Make daily folder
Gui, Add, Button, h30 w140 gdailyfile vButton8, Daily file 
Gui, Add, Button, h30 w140 gLaborfile vButton9, Labor 
Gui, Add, Button, h30 w140 gCyclefile vButton10, Cycle Count
Gui, Add, Button, h30 w140 gGLQueryfile vButton11, gQuery
Gui, Add, Button, h30 w140 gEarnhoursfile vButton12, Earn Hours
If(AEButton = 1)
{
    Gui, Add, Button, h30 w140 gAEFiles vButton13, Actual hours
    ;you could put other things in here too
}
Gui, Show

Newfolder:
dailyfile:
Laborfile:
Cyclefile:
GLQueryfile:
Earnhoursfile:
AEFiles:

Return
GuiClose:
    ExitApp