在 AHK 中使用下拉列表和 gui 文本框的条件行为
Conditional behaviour using dropdownlist and gui textbox in AHK
假设我选择 "Option1" 和 "Color1"。然后我在自由文本区写一些东西。现在,当我按下 OK 时,它将执行条件标记。由于 Option1/color1 被选中,它会执行一个发送输入命令:
blablala %text1% blabla %text2%.
如果我选择 "option1" 和 "color" 它将使用
进行发送输入
blabla with his wife and her wife text1 then the dog did text2.
我已经完成了这段代码的一部分。我的问题是,当我从下拉列表中选择时,无论我写了什么,它都会执行脚本。我希望它在单击“确定”并在我想放置的任何位置显示 text1/text2 后执行。
#NoEnv
Gui, 1: font, s10 , Verdana
Gui, 1: Add, DropDownList, gDropDownList vDropDownList1 R2 choose1, Option1|Option2
Gui, 1: Add, DropDownList, gDropDownList vDropDownList2 R2 choose1, Color1|Color2
Gui, 1:Add, text,, Text1
Gui, 1:Add, edit, vText1
Gui, 1:Add, text,, Text2
Gui, 1:Add, edit, vText2
Return
DropDownList:
Gui, 1:Submit,NoHide
if (dropdownlist1 = "Option1") && (dropdownlist2 = "Color1")
{
MsgBox, A flower said to a be: %text1%. The bee replied %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option1") && (dropdownlist2 = "Color2")
{
MsgBox, You picked %text1% and %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option2") && (dropdownlist2 = "Color1")
{
MsgBox, A girl said %text1% when you picked %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option2") && (dropdownlist2 = "Color2")
{
MsgBox, Blabla %text1% blabla %text2%
Gui 1: hide
}
return
#j::
Gui 1: show,, DropDownGui
return
I've managed todo part of this code. My problem is that when I pick
from the droplists, it executes the script no matter what I wrote.
那是因为您的下拉列表中附加了一个 gosub。这就是 gDropDownList
中的 g
。当你 select 从那里得到一些东西时,它会运行 DropDownList 标签。
您可以从选项字段中完全删除 gDropDownList
,或者您可以制作一个标签,通过制作一个 gui 提交标签,在点击时保存您的 selection。
尝试这样的事情:
#NoEnv
Gui, 1:font, s10 , Verdana
Gui, 1:Add, DropDownList, gGuiSave vDropDownList1 R2 choose1, Option1|Option2
Gui, 1:Add, DropDownList, gGuiSave vDropDownList2 R2 choose1, Color1|Color2
Gui, 1:Add, text,, Text1
Gui, 1:Add, edit, vText1
Gui, 1:Add, text,, Text2
Gui, 1:Add, edit, vText2
Return
GuiSave:
Gui, 1:Submit,NoHide
return
DropDownList:
Gui, 1:Submit,NoHide
if (dropdownlist1 = "Option1") && (dropdownlist2 = "Color1")
{
MsgBox, A flower said to a be: %text1%. The bee replied %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option1") && (dropdownlist2 = "Color2")
{
MsgBox, You picked %text1% and %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option2") && (dropdownlist2 = "Color1")
{
MsgBox, A girl said %text1% when you picked %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option2") && (dropdownlist2 = "Color2")
{
MsgBox, Blabla %text1% blabla %text2%
Gui 1: hide
}
return
#j::
Gui 1: show,, DropDownGui
return
假设我选择 "Option1" 和 "Color1"。然后我在自由文本区写一些东西。现在,当我按下 OK 时,它将执行条件标记。由于 Option1/color1 被选中,它会执行一个发送输入命令:
blablala %text1% blabla %text2%.
如果我选择 "option1" 和 "color" 它将使用
进行发送输入blabla with his wife and her wife text1 then the dog did text2.
我已经完成了这段代码的一部分。我的问题是,当我从下拉列表中选择时,无论我写了什么,它都会执行脚本。我希望它在单击“确定”并在我想放置的任何位置显示 text1/text2 后执行。
#NoEnv
Gui, 1: font, s10 , Verdana
Gui, 1: Add, DropDownList, gDropDownList vDropDownList1 R2 choose1, Option1|Option2
Gui, 1: Add, DropDownList, gDropDownList vDropDownList2 R2 choose1, Color1|Color2
Gui, 1:Add, text,, Text1
Gui, 1:Add, edit, vText1
Gui, 1:Add, text,, Text2
Gui, 1:Add, edit, vText2
Return
DropDownList:
Gui, 1:Submit,NoHide
if (dropdownlist1 = "Option1") && (dropdownlist2 = "Color1")
{
MsgBox, A flower said to a be: %text1%. The bee replied %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option1") && (dropdownlist2 = "Color2")
{
MsgBox, You picked %text1% and %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option2") && (dropdownlist2 = "Color1")
{
MsgBox, A girl said %text1% when you picked %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option2") && (dropdownlist2 = "Color2")
{
MsgBox, Blabla %text1% blabla %text2%
Gui 1: hide
}
return
#j::
Gui 1: show,, DropDownGui
return
I've managed todo part of this code. My problem is that when I pick from the droplists, it executes the script no matter what I wrote.
那是因为您的下拉列表中附加了一个 gosub。这就是 gDropDownList
中的 g
。当你 select 从那里得到一些东西时,它会运行 DropDownList 标签。
您可以从选项字段中完全删除 gDropDownList
,或者您可以制作一个标签,通过制作一个 gui 提交标签,在点击时保存您的 selection。
尝试这样的事情:
#NoEnv
Gui, 1:font, s10 , Verdana
Gui, 1:Add, DropDownList, gGuiSave vDropDownList1 R2 choose1, Option1|Option2
Gui, 1:Add, DropDownList, gGuiSave vDropDownList2 R2 choose1, Color1|Color2
Gui, 1:Add, text,, Text1
Gui, 1:Add, edit, vText1
Gui, 1:Add, text,, Text2
Gui, 1:Add, edit, vText2
Return
GuiSave:
Gui, 1:Submit,NoHide
return
DropDownList:
Gui, 1:Submit,NoHide
if (dropdownlist1 = "Option1") && (dropdownlist2 = "Color1")
{
MsgBox, A flower said to a be: %text1%. The bee replied %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option1") && (dropdownlist2 = "Color2")
{
MsgBox, You picked %text1% and %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option2") && (dropdownlist2 = "Color1")
{
MsgBox, A girl said %text1% when you picked %text2%
Gui 1: hide
}
else if (dropdownlist1 = "Option2") && (dropdownlist2 = "Color2")
{
MsgBox, Blabla %text1% blabla %text2%
Gui 1: hide
}
return
#j::
Gui 1: show,, DropDownGui
return