使用AHK GUI为输入框创建标识符 [英] Create Identifier for input box with AHK GUI

查看:390
本文介绍了使用AHK GUI为输入框创建标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在AHK中创建了一个GUI,并且现在运行良好.我正在处理多条记录,并且希望能够跟踪自己所在的位置.我的代码遍历每条记录并执行一些操作,然后再继续进行下一条记录.发生这种情况时,将显示GUI窗口.我也用AHK编写此文件,然后使用转换工具并用它创建一个.exe.我正在开发此工具,使其作为独立的EXE分发,可以安装/保存然后在需要时运行.下面是该工具的屏幕快照以及要在名称中加载的代码.

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

我想添加一些内容,以便在处理Jason时可以将其识别出来.当我在列表中循环时,有一个可以移动的箭头会很好.正如我在下面描述的那样,我在油漆上画了它.否则,如果我可以翻过去,则会记录一种也可以使用的颜色.因此,在下面的示例中,名称为"Chris"& "Ben"将以一种颜色突出显示,或者以某种方式将其标识为不同的框.我不确定该怎么做,因此尽可能学习两者都很好.最后,无论描述什么方法,我都需要能够使用Ahk2Exe将其转换为.exe,然后能够运行.exe,而无需在程序中添加任何其他文件或其他无效的引用.它可以在标准Windows计算机上运行,​​因此,如果有一些可以访问的默认图像可能也很有用.

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.

推荐答案

好的,所以我想出了如何使用PGilm的复选框方法来做到这一点.您也可以使用某种类型的表来执行此操作.但是下面的代码似乎对我有用.

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.

我也想让您知道我将var x更改为cliparray,以便于阅读.

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

在添加修改和复选框的行上需要注意一些逻辑.我使用Gui定位的Section逻辑进行编辑并在同一行上进行检查.在此代码中,section元素在文本部分的第一个Gui, Add,中设置.从而继承了其他gui元素. 第AHK文档

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%

接下来要仔细研究的部分是在GoCont函数中.我正在使用循环的索引来 check CheckBox%A_Index%复选框,以便打开当前行.我还用GuiControl,, CheckBox%backone%, 0行关闭了上一个索引的复选框.当您处理每个元素中的文本时,这会产生复选框在列表中移动的效果.

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.

最后要提到的一行是Gui, Submit, NoHide.否则,您将丢失为每个复选框创建的变量并进行编辑.这将创建每个gui元素中的数据并将其填充到变量中. Gui,提交AHK文档

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

这篇关于使用AHK GUI为输入框创建标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆