如何在输入回车后转到下一个输入框?附原码
本帖最后由 hhasee 于 2009-4-27 09:27 编辑#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
#Region ### STARTGUI 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 ### endGUI 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后的对话框里, 以便我再一次输入!
在线等各位大侠指点啊!!! #include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
Opt('MustDeclareVars', 1)
#Region ### STARTGUI 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 ### endGUI 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
;------------------------------------------------------------------------------------------------------------ 想了半天都没有搞定,在此谢谢了!
页:
[1]