找回密码
 加入
搜索
查看: 1549|回复: 2

如何在输入回车后转到下一个输入框?附原码

[复制链接]
发表于 2009-4-26 15:51:30 | 显示全部楼层 |阅读模式
本帖最后由 hhasee 于 2009-4-27 09:27 编辑

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

#Region ### START  GUI section ###
    Local $Mac, $btn, $msg, $Sn, $top_pic, $back_pic, $NB1, $NB2, $pctest, $MACR, $snr
        ;$font = "MS Sans Serif"
        $pctest = GUICreate("条码捆邦系统", 400, 200)
        GUICtrlSetState(-1, $Gui_Disable)
        GUISetFont(16, 400, 1)
        GUICtrlCreateLabel("扫 描 MAC 号:",45,55,150,20)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0x0b1746)
        $Mac = GUICtrlCreateInput("", 200, 53, 150, 25)
        GUICtrlSetState(-1, $GUI_DROPACCEPTED)
        GUISetFont(16, 400, 1)
        GUICtrlCreateLabel("扫 描 S N 号:",45,100,150,20)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0x0b1746)
        $Sn = GUICtrlCreateInput("", 200, 98, 150, 25)        
        $btn = GUICtrlCreateButton("Ok", 40, 150, 60, 20)
        GUISetState()
#EndRegion ### end  GUI section ###   
   
;-------------------------------------------------------------------------------------------------------------------------
$msg = 0
  While $msg <> $GUI_EVENT_CLOSE
                $msg = GUIGetMsg()
                Select
                        Case $msg = $btn
                                ExitLoop
                    
                EndSelect
  WEnd
    $NB1 = GUICtrlRead($Mac)
        $NB2 = GUICtrlRead($Sn)
if $NB1= "" or $NB2 = "" then
                MsgBox (0+16,"提示:","条码不能为空!")
        Else
            $MACR = "MAC: " & $NB1
            $SNR = "   SN: " & $NB2
            FileWriteLine('123.xls',$MACR & $SNR)
EndIf       
       
       
;------------------------------------------------------------------------------------------------------------
现在的问题如下:
1、当我在MAC后面的对话框里输入条码后按回车光标无法自动跳到SN后面的对话框!
2、必须要点确认才能将前面所输的条码扫到123.XLS里,但我想在输入第二个SN条码后再输一个回车的话就自动输到123.XLS里去,并光标要跳到MAC后的对话框里, 以便我再一次输入!
在线等各位大侠指点啊!!!
发表于 2009-4-26 16:41:44 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

Opt('MustDeclareVars', 1)

#Region ### START  GUI section ###
    Local $Mac, $btn, $msg, $Sn, $top_pic, $back_pic, $NB1, $NB2, $pctest, $MACR, $snr
        ;$font = "MS Sans Serif"
        $pctest = GUICreate("条码捆邦系统", 400, 200)
        GUICtrlSetState(-1, $Gui_Disable)
        GUISetFont(16, 400, 1)
        GUICtrlCreateLabel("扫 描 MAC 号:",45,55,150,20)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0x0b1746)
        $Mac = GUICtrlCreateInput("", 200, 53, 150, 25)
        GUICtrlSetState(-1, $GUI_DROPACCEPTED)
        GUISetFont(16, 400, 1)
        GUICtrlCreateLabel("扫 描 S N 号:",45,100,150,20)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0x0b1746)
        $Sn = GUICtrlCreateInput("", 200, 98, 150, 25)
        $btn = GUICtrlCreateButton("Ok", 40, 150, 60, 20, $BS_DEFPUSHBUTTON)
        GUISetState()
#EndRegion ### end  GUI section ###

;-------------------------------------------------------------------------------------------------------------------------

While 1
        Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $btn
                        $NB1 = GUICtrlRead($Mac)
                        $NB2 = GUICtrlRead($Sn)
                        Select
                                Case $NB1 = ""
                                        GUICtrlSetState($Mac, $GUI_FOCUS)
                                Case $NB2 = ""
                                        GUICtrlSetState($Sn, $GUI_FOCUS)
                                Case Else
                                        $MACR = "MAC: " & $NB1
                                        $SNR = "   SN: " & $NB2
                                        FileWriteLine('123.xls', $MACR & $SNR)
                                        GUICtrlSetData($Mac, "")
                                        GUICtrlSetData($Sn, "")
                                        GUICtrlSetState($Mac, $GUI_FOCUS)
                        EndSelect
        EndSwitch
WEnd
;------------------------------------------------------------------------------------------------------------
 楼主| 发表于 2009-4-27 09:24:13 | 显示全部楼层
想了半天都没有搞定,在此谢谢了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-28 10:17 , Processed in 0.071258 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表