1
votes

I have created a GUI in AHK and it works well now. I am processing multiple records and would like to be able to track the place that I am on. My code loops through each record and does some actions before moving on to the next one. While this is happening the GUI window is shown. Also I am writing this in AHK then using the conversion tool and creating an .exe with it. I am developing this tool to be distributed as a stand alone EXE that one can install/save and then run when they want to. Below is a screen shot of the tool and the code to load in the names.

Gui, PasteGUI:Add, Text,, Please add the Names that you want to Process.
Counter := 0
Loop, parse, Clipboard, `n, `r
{
    x%A_Index% := A_LoopField
    Counter++
}
Counter--    
Loop, %Counter%  ;  Dynamic List length
Gui PasteGUI:Add, Edit, vButton%A_Index%, % x%A_Index%
Gui PasteGUI:Add, Button, x200 y270 w88 h26 vButton02 gGoCont Default, Continue
Gui PasteGUI:Add, Button,  x290 y270 w88 h26 vButton03 gGoQuit, Cancel  
Gui, PasteGUI:Show
}
Return
GoCont:
{
    Loop, %Counter%
    {
        CODE TO PROCESS MY EACH NAME
    }
    MsgBox Done!
    Gui Destroy
}
Return
GoQuit:  
    Gui Destroy 
Return

I want to add something so that when I am processing Jason it can be identified. Having an arrow that moves as I loop through the list would be nice. As I have depicted it below,I drew it on in paint. Otherwise if I could turn the past records a color that would work too. So for the below example the names "Chris" & "Ben" would be highlighted in a color or the boxes would be somehow identified as different. I am not sure how to do either so it would be great to learn both if possible. Lastly, whatever method is described I need to be able to convert it to an .exe with Ahk2Exe and then be able to run the .exe and not have a need to have any further files or other references in the program that would not work. This is interned to be run on a standard Windows computer so if there are some default images that can be accessed that might be useful too.

Tool Processing Jason

1
Perhaps you can add a checkbox in front or after each line that creates an edit box in your GUI. Then, in the code that process the name, you would simply tick the checkbox to keep track. Try it first, then I can help with your code. Thx,PGilm

1 Answers

0
votes

Okay so Ive worked out how to do this with PGilm's method of checkboxes. You could also possibly do this with a table of some sort. But the code below looks to be working for me.

Also I wanted to let you know I changed the var x to cliparray so it is easier to read.

Gui, Add, Text,section, Please add the Names that you want to Process.
Counter := 0
Loop, parse, Clipboard, `n, `r
{
    cliparray%A_Index% := A_LoopField
    Counter++
}
Counter--  


Loop, %Counter%  {
;  Dynamic List length
Gui, Add,  Checkbox,  xs vCheckBox%A_Index%
Gui Add, Edit, yp+1 xs+30 vTextbox%A_Index%, % cliparray%A_Index%

}
Gui Add, Button, x200 y270 w88 h26 gGoCont vButton02 Default, Continue
Gui Add, Button,  x290 y270 w88 h26 vButton03 gGoQuit, Cancel  
Gui, Show
Return

GoCont:
;needed to get the variables from the edits and check box, else the varibles dont exist See below for more information. 
Gui, Submit, NoHide  
msgbox, Go..
    Loop, %Counter%
    {
        line=Textbox%A_Index%
        GuiControl,, CheckBox%A_Index%, 1
        backone:=A_Index-1
        GuiControl,, CheckBox%backone%, 0

        Msgbox % "variable " line " contains: " Textbox%A_Index%
    }
    MsgBox Done!

Return
GoQuit:
   Gui Destroy 
Return

;Used to debug to see list of all variables. Super helpful :D
F7::
ListVars
return

Some logic to take note of would be on the lines that add the edits and checkbox's. I used the Section logic of Gui positioning to make the edit and check on the same line. In this code the section element is set in the first Gui, Add, for the text section. And thus carries down to the other gui elements. Section AHK Documentation

Gui, Add,  Checkbox,  xs vCheckBox%A_Index%
Gui Add, Edit, yp+1 xs+30 vTextbox%A_Index%, % cliparray%A_Index%

The next part to take a closer look at is in the GoCont function. I am using the index of the loop to check the CheckBox%A_Index% checkbox so that the current line turns on. I also turn off the last index's check box with the GuiControl,, CheckBox%backone%, 0 line. This give the effect of the check box moving through list as you process text with in each element.

One last line to mention is the Gui, Submit, NoHide. Without this you will be missing the variables created for each checkbox and edit. This will create and fill the variables with the data from each gui element. Gui, Submit AHK Documentation