2017-05-25 4 views
0

Nehmen wir an, ich wähle "Option1" und "Color1". Dann schreibe ich etwas in den Freitextbereich. Wenn ich nun OK drücke, werden die bedingten Tags ausgeführt. Da Option1/Farbe1 ausgewählt ist, führt sie einen sendinput-Befehl aus mit:Bedingtes Verhalten mit Dropdown-Liste und GUI-Textfeld in AHK

blabala% text1% blabla% text2%.

Wenn ich aber wählen „option1“ und „Farbe“ wird es mit

blabla mit seiner Frau und ihre Frau text1 dann tat der Hund text2 ein Send zu tun.

Ich habe todo Teil dieses Codes geschafft. Mein Problem ist, dass wenn ich aus den Drop-Listen auswähle, es das Skript ausführt, egal was ich geschrieben habe. Ich möchte, dass es mit einem Klick auf OK ausgeführt wird und text1/text2 angezeigt wird, wo immer ich es hinstellen möchte.

#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 

Antwort

1

Ich habe todo Teil dieses Codes verwaltet. Mein Problem ist, dass, wenn ich von den Droplisten wähle, führt es das Skript aus, egal was ich schrieb.

Das liegt daran, dass Sie ein Gosub an Ihre Dropdown-Liste angehängt haben. Das ist, was die g in gDropDownList ist. Wenn Sie etwas daraus auswählen, wird die DropDownList-Beschriftung ausgeführt.

Sie können das gDropDownList entweder vollständig aus dem Optionsfeld entfernen, oder Sie können ein Etikett erstellen, das Ihre Auswahl beim Klicken speichert, indem Sie ein GUI-Etikett erstellen.

versuchen, etwas wie folgt aus:

#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