#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
GUICreate("Input回车示例", 533, 142, 219, 320)
GUICtrlCreateLabel("输入网址后按回车和按打开按钮一样的效果,且不会影响其他窗口。", 16, 20, 380, 17)
GUICtrlCreateLabel("输入正确的网址:", 16, 55, 116, 17)
$Address = GUICtrlCreateInput("Http://www.baidu.com", 136, 52, 377, 21)
$Run = GUICtrlCreateButton("打开(&O)", 104, 96, 113, 25, 0)
$Exit = GUICtrlCreateButton("退出(&X)", 298, 96, 113, 25, 0)
Dim $AccelKeys[2][2]=[["{Enter}", $Address], ["{Enter}", $Run]]
GUISetAccelerators($AccelKeys)
GUISetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit
Exit
Case $Msg = $Address
_RunDOS("start "& GUICtrlRead($Address))
Case $Msg = $Run
_RunDOS("start "& GUICtrlRead($Address))
EndSelect
WEnd
嘿嘿,这样就OK了。主要看下GUISetAccelerators()函数,貌似只有新版里才有。 |