Hi, I am a bit new to the GUI programming of AHK, so bare with me please.
Application Plan: Make a small gui script that show X amount of buttons depending how many SWGClients (a game) im running.
Functionality of the buttons is to hide/show the game window when pressed.
I got the Adding of Buttons dynamic made, but the functionality of them i am having a bit a trouble with howto make dynamic.
Notice how i have to make all the ButtonSWGClient1 / ButtonSWGClient2 / ButtonSWGClient3.
How would i go by making that more dynamic / scalable?
Code:
;
; Language: English
; Platform: Win9x/NT
; Author: Andri(Titboy) <amg@quakemet.org>
;
; Script Function:
; Will Parse a logfile generated from Star Wars Galaxies(TM). Will Generate a script file for SWG.
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
DetectHiddenWindows, On
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Height = 10
Width = 165
; Form
WinGet, ClientArray, List, SwgClient
loop %ClientArray%
{
element := ClientArray%A_Index%
; MsgBox % "Element number " . A_Index . " is " . ClientArray%A_Index%
Gui, Add, Button, x15 y%Height% w135 h20, SWGClient %A_Index%
Height := Height + 25
}
Height := Height + 25
Gui, Show, h%Height% w%Width%, StarWarsGalaxiesController
return
ButtonSWGClient1:
{
if not DllCall("IsWindowVisible", "UInt", ClientArray1)
winshow, ahk_id %ClientArray1%
else
winhide, ahk_id %ClientArray1%
WinActivate StarWarsGalaxiesController
return
}
ButtonSWGClient2:
{
if not DllCall("IsWindowVisible", "UInt", ClientArray2)
winshow, ahk_id %ClientArray2%
else
winhide, ahk_id %ClientArray2%
WinActivate StarWarsGalaxiesController
return
}
ButtonSWGClient3:
{
if not DllCall("IsWindowVisible", "UInt", ClientArray3)
winshow, ahk_id %ClientArray3%
else
winhide, ahk_id %ClientArray3%
WinActivate StarWarsGalaxiesController
return
}
GuiClose:
ExitApp