1

我不是专家,但现在试着弄清楚大约 6 个小时,我有一个包含 2 个项目的选择窗口,无论我选择什么,我都选择 No1 项目。稍后,如果选择可以工作,我会用操作替换 nr1、nr2。请帮忙!我假设我在 MyListbox1 使用了错误的代码。

Gui, Add, ListBox, vMyListBox1 gMyListBox1 w100 r10
{
    GuiControl,, MyListBox1, Item1|Item2
}
Gui, Show
return

MyListBox1:
if A_GuiEvent <> DoubleClick
    return
GuiControlGet, MyListBox1, %Item1%
GuiControlGet, MyListBox1, %Item2%
IfMsgBox, %Item1%
MsgBox, MsgBox You entered 1
    return
IfMsgBox, %Item2%
MsgBox, MsgBox You entered 2
Return

GuiClose:
GuiEscape:
ExitApp
4

1 回答 1

2

像这样?

Gui, Add, ListBox, vMyListBox1 gMyListBox1 w100 r10, NotePad|x
Gui, Show
return

MyListBox1:
if A_GuiEvent <> DoubleClick ; If not double click stop
    Return
GuiControlGet, MyListBox1 ; Get current value of MyListBox1 variable
If (MyListBox1 = "NotePad") ; If MyListBox1 contains NotePad
    Run, NotePad.exe
Else If (MyListBox1 = "x") ; If MyListBox1 contains x
{
    Send, !{Esc} ; Need to switch back to previous application since GUI is in focus and you would send the data to your own GUI
    Sleep, 100 ; Wait a little while, so that the other application can be in focus
    Send, x ; You could have used Send, %MyListBox1%, since MyListBox1 contains x
}
Return

GuiClose:
GuiEscape:
ExitApp
于 2013-04-17T06:19:05.047 回答