Autohotkey - 如何在EDIT控件中从文本创建变量

时间:2014-10-16 22:23:32

标签: controls edit autohotkey

我想创建包含EDIT控件内容的变量,如下所示 -

ResizeCL := "width=1920, height=1080"

Gui, Add, Edit, x26 y397 w910 h20 r1 vResizeCL, % ResizeCL
Gui, Show, w960 h465, name
return

GuiClose:
ExitApp

如果运行它,您可以看到EDIT控件内容。我很确定Loop,解析可能有效,但我没有走得太远。

1 个答案:

答案 0 :(得分:0)

查看StrSplit,需要AHK_L

ResizeCL := "width=1920, height=1080"
Gui, Add, Edit, w300 r1 vResizeCL, % ResizeCL
Gui, Add, Button, gSubmit Default, Submit
Gui, Show, , name
return

Submit:
Gui, Submit, NoHide
If InStr(ResizeCL, ",")
    for k, val in StrSplit(ResizeCL, ",", " ")
        v := StrSplit(val, "=", " ").1 , %v% := StrSplit(val, "=", " ").2
else    
    v := StrSplit(ResizeCL, "=", " ").1 , %v% := StrSplit(ResizeCL, "=", " ").2
ListVars  ; test line to view current defined variables
return