Dynamic GuiControl Function

Get help with using AutoHotkey and its commands and hotkeys
RNDLDVL
Posts: 15
Joined: 04 Oct 2015, 10:48

Dynamic GuiControl Function

04 Oct 2015, 11:06

Basically the script that I'm working has 64 buttons that is bound to read the entire content of a text file and copies it to the clipboard when clicked. Saving and loading is easy, now to change the corresponding button's text according to the label assigned to it is the difficult part. I can't wrap my head around this without making a very long pseudo case switch function. Here's what I'm working wth.

Code: Select all

ParaLoad:
  GuiControlGet, ParaNo
  If (ParaNo == "") 
    GuiControl, , ParaNo, 00
  Else {
    nParaNo := SubStr("0" . ParaNo, -1)
    GuiControl, , ParaNo, %nParaNo%
  }
  ReadFile(nParaNo)
return

ParaSave:
  GuiControlGet, ParaNo
  GuiControlGet, strToWrite, , ParaEdit
  GuiControlGet, strIniLabel, , ParaLabel
  WriteFile(ParaNo, strToWrite, strIniLabel)
  btn2Rename := "pb"ParaNo
  GuiControl, 1:, btn2Rename, %ParaNo%.%strIniLabel%
Return

ReadFile(Filename) {
  If (Filename <= 64 && Filename >= 1) {
    FileSelected := Filename ".txt"
    If FileExist(FileSelected){
      FileRead, ReadContent, %FileSelected%
      IniRead, strIniLabel, cfg.ini, PastebinLabels, %Filename%, %A_Space%
      GuiControl, , ParaEdit, %ReadContent%
      GuiControl, , ParaLabel, %strIniLabel%
    } Else
      GuiControl, , ParaEdit, % "No saved data for this slot."
  } Else
    GuiControl, , ParaEdit, % "Must load a number between 1-64."
}

WriteFile(Filename, Content, Label) {
  FileSelected := Filename ".txt"
  Loop 2 {
    If FileExist(FileSelected)
      FileDelete, %FileSelected%
    Else
      IniDelete, cfg.ini, PastebinLabels, %Filename%
      IniWrite, %Label%, cfg.ini, PastebinLabels, %Filename%
      FileAppend, %Content%, %FileSelected%
  }
}
I can get the value right but GuiControl can't seem to work with it.

Edit. Figured it out, thanks to Maestr0.

Code: Select all

  GuiControl, 1:, pb%ParaNo%, %ParaNo%.%strIniLabel%
Last edited by RNDLDVL on 04 Oct 2015, 11:31, edited 2 times in total.
User avatar
Maestr0
Posts: 126
Joined: 05 Dec 2013, 17:43

Re: Dynamic GuiControl Function

04 Oct 2015, 11:29

try this:

Code: Select all

GuiControl, , ParaNo, %nParaNo%

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, autohotkeycool, Bing [Bot], daywalker, keylo, Pilu, songdg, vanil, yagami19821223, zvit and 48 guests