Beiträge von Rufio
-
-
Danke für die schnelle Antwort
Code
Alles anzeigen#include <GUIConstants.au3> Opt ("GUIOnEventMode", 1) Local $DPIAware = DllCall ("user32.dll", "bool", "SetProcessDPIAware") DllClose ($DPIAware) $ConfigFile = @ScriptDir & "\config.ini" $ButtonsFile = @ScriptDir & "\buttons.cfg" $GUI_Name = IniRead ($ConfigFile, "GUI", "Name", 0) $GUI_Breite = IniRead ($ConfigFile, "GUI", "Breite", 0) $GUI_Hoehe = IniRead ($ConfigFile, "GUI", "Hoehe", 0) $GUI_PositionX = IniRead ($ConfigFile, "GUI", "PositionX", 0) $GUI_PositionY = IniRead ($ConfigFile, "GUI", "PositionY", 0) $GUI_Hintergrundbild = IniRead ($ConfigFile, "GUI", "Hintergrundbild", 0) $GUI = GUICreate ($GUI_Name, @DesktopWidth, @DesktopHeight, $GUI_PositionX, $GUI_PositionY, $WS_POPUP) GUISetOnEvent ($GUI_EVENT_CLOSE, "_Exit") GUICtrlCreatePic ($GUI_Hintergrundbild, 0, 0, $GUI_Breite, $GUI_Hoehe) $Sections = IniReadSectionNames ($ButtonsFile) If @error Then Exit Dim $Button[$Sections[0]],$Picture[$Sections[0]] For $i = 1 To $Sections[0]-1 $Position = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Position", ""), ",") $Size = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Size", ""), ",") $Image = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Image", ""), ",") ;$Button[$i-1] = GUICtrlCreateButton ($Sections[$i], $Position[1], $Position[2], $Size[1], $Size[2], $BS_BITMAP) ;GUICtrlSetImage (-1, @ScriptDir & "\gfx\" & $Image[1]) $Button[$i-1] = GUICtrlCreatePic (@ScriptDir & "\gfx\" & $Image[1], $Position[1], $Position[2], $Size[1], $Size[2]) ConsoleWrite (GUICtrlRead ($Button[$i-1]) & @CRLF) Next GUISetState () While 1 Sleep (1000) WEnd Func _Exit() Exit EndFunc
Config.ini:
[GUI]
Name = Dashboard
Breite = 1920
Hoehe = 1080
PositionX = 0
PositionY = 0
Hintergrundbild = bg.jpg
Und Buttons.cfg im ini-format:
[Kodi]
Name = Kodi
Size = 192,192
Position = 32,32
Image = kodi.bmp,kodi_h.bmp
[Steam]
Name = Steam
Size = 192,192
Position = 224,32
Image = steam.bmp,steam_h.bmp
[Amiga]
Name = Amiga
Size = 192,192
Position = 416,32
Image = amiga.bmp,amiga_h.bmp
[ScummVM]
Name = ScummVM
Size = 192,192
Position = 608,32
Image = scummvm.bmp,scummvm_h.bmp
[SNES]
Name = Super Nintendo
Size = 192,192
Position = 800,32
Image = snes.bmp,snes_h.bmp
[N64]
Name = N64
Size = 192,192
Position = 992,32
Image = n64.bmp,n64_h.bmp
[GameCube]
Name = Nintendo GameCube
Size = 192,192
Position = 1184,32
Image = ngc.bmp,ngc_h.bmp
[Wii]
Name = Nintendo Wii
Size = 192,192
Position = 1376,32
Image = nwii.bmp,nwii_h.bmp
-
Hallo zusammen, das ist mein erstes Thema hier im Forum.
Ich versuche normalerweise selbst eine Lösung zu finden, jedoch hänge ich an diesem Problem jetzt schon zu lange.
Es geht darum, per For-Loop Einträge aus einer INI-Datei zu lesen und die Sectionnames als Bezeichnung für Buttons zu nutzen.
Hier mal das Script:
Code
Alles anzeigen$Sections = IniReadSectionNames ($ButtonsFile) If @error Then Exit Dim $Button[$Sections[0]] For $i = 1 To $Sections[0] $Position = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Position", ""), ",") $Size = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Size", ""), ",") $Image = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Image", ""), ",") $Button[$i-1] = GUICtrlCreateButton ($Sections[$i], $Position[1], $Position[2], $Size[1], $Size[2], $BS_BITMAP) GUICtrlSetImage (-1, @ScriptDir & "\gfx\" & $Image[1]) Next
Die Buttons werden auch alle erstellt, jedoch werden nur 6 der insgesamt 8 Bilder auf die Knöpfe gelegt.
Ich würde eigentlich auch lieber GUICtrlCreatePic anstelle von GUICtrlCreateButton verwenden, da ich den gepunkteten Focus nicht wegbekomme, aber dann werden mir gar nicht erst alle Buttons bzw. Pics angezeigt, sondern auch wieder nur 6 von 8...
CodeButton[$i-1] = GUICtrlCreatePic (@ScriptDir & "\gfx\" & $Image[1], $Position[1], $Position[2], $Size[1], $Size[2])
Es hat sicherlich was mit Arrays / UBound oder sonstwas zu tun, allerdings habe ich mich damit bisher so in den Wahnsinn getrieben, dass ich jetzt wirklich Hilfe dazu brauche