AutoIt 捕获Input的回车事件

2010-01-20 程序代码 1308 阅读 0 评论

AutoIt 捕获Input的回车事件

#include 
#include 
$Form1 = GUICreate("AutoIt 捕获Input的回车事件", 309, 171, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_TOPMOST)
$Input1 = GUICtrlCreateInput("", 72, 40, 153, 21)
$Button1 = GUICtrlCreateButton("修改(&E)", 152, 72, 75, 25)
$Label1 = GUICtrlCreateLabel("╃苍狼山庄╃ HTTP://WWW.CLANG.CN", 90, 152, 235, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $strInput1 = StringLower (GUICtrlRead($Input1))
            If $strInput1 = "" Then
                MsgBox(0+16+262144,"警告","您没有输入任何内容!")        
            Else
                Msgbox(0+64+262144, "信息", "您输入的是:"& $strInput1)
            EndIf
    EndSwitch
WEnd

Input文本框中输入任意内容,按回车激活按钮事件,只要在

$Button1 = GUICtrlCreateButton("修改(&E)", 152, 72, 75, 25)

下面加入两行代码即可:

Dim $Form1_AccelTable[1][2] = [["{ENTER}", $Button1]]
GUISetAccelerators($Form1_AccelTable)

修改后的代码如下:

#include 
#include 
$Form1 = GUICreate("AutoIt 捕获Input的回车事件", 309, 171, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_BORDER,$WS_CLIPSIBLINGS), $WS_EX_TOPMOST)
$Input1 = GUICtrlCreateInput("", 72, 40, 153, 21)
$Button1 = GUICtrlCreateButton("修改(&E)", 152, 72, 75, 25)
Dim $Form1_AccelTable[1][2] = [["{ENTER}", $Button1]]
GUISetAccelerators($Form1_AccelTable)
$Label1 = GUICtrlCreateLabel("╃苍狼山庄╃ HTTP://WWW.CLANG.CN", 90, 152, 235, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $strInput1 = StringLower (GUICtrlRead($Input1))
            If $strInput1 = "" Then
                MsgBox(0+16+262144,"警告","您没有输入任何内容!")        
            Else
                Msgbox(0+64+262144, "信息", "您输入的是:"& $strInput1)
            EndIf
    EndSwitch
WEnd

本文链接:https://blog.clang.cn/615.html

版权声明:转载请注明出处。

评论 (0)

评论已关闭