如果在輸入框按下Enter就執行某個function [已解决]
本帖最后由 sta 于 2011-1-16 21:52 编辑我想在輸入框中做到可以按下Enter就執行某個function的功能
我要如何做? 看看帮助里的GUISetAccelerators
多体会你就明白了 #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
Opt("TrayMenuMode", 1)
Global $aArray, $list_path,$list_iccode,$list_ictype,$list_softpath,$list_checksum,$list_flag
Global $sFilePath1 = "c:\list.xls" ; Path of Excel list This file should already exist
#Region ### START Koda GUI section ### Form=e:\autoit\koda_2007.07.07\forms\aform1.kxf
;;;;;;;;;;;;;;;;;;;;;;;
$AForm1 = GUICreate("烧录站参数设定辅助工具", 300, 154)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF00FF)
$Group1 = GUICtrlCreateGroup("@ ! @", 8, 8, 284, 137)
$Label1 = GUICtrlCreateLabel("", 64, 3, 4, 4)
$Label2 = GUICtrlCreateLabel(" 在下框中输入要烧录的 SN 条码 ", 58, 30, 200, 17)
;$Address = GUICtrlCreateInput("SN ", 136, 52, 200, 21)
$SN = GUICtrlCreateInput("Input SN", 40, 56, 220, 21)
;$Run = GUICtrlCreateButton("打开(&O)", 104, 96, 113, 25, 0)
$Run = GUICtrlCreateButton("打开(&O)", 45, 98, 77, 25, 0)
$Exit = GUICtrlCreateButton("退出(&X)", 185, 98, 74, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Dim $AccelKeys=[["{Enter}", $SN], ["{Enter}", $Run]]
GUISetAccelerators($AccelKeys)
GUISetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit
Exit
Case $Msg =$SN
_msg()
EndSelect
WEnd
Func _msg()
MsgBox(0,"","OK")
EndFunc http://www.autoitx.com/forum.php?mod=redirect&goto=findpost&ptid=20869&pid=251109&fromuid=7644217 謝謝,問題已經解決 有用到!!多謝分享!!
页:
[1]