#include <WinAPI.au3>
#include <GUIEdit.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>
If Not IsDeclared("WM_CHAR") Then $WM_CHAR = 0x102
$hGUI = GUICreate("Test", 180, 100)
GUICtrlCreateLabel("", 20, 20, 140, 20, $SS_SUNKEN)
$hParent = GUICtrlGetHandle(-1)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$hCall = DllCallbackRegister("_IptProc", "int", "hWnd;uint;wparam;lparam")
$pCall = DllCallbackGetPtr($hCall)
Dim $iPos = 0
For $i = 0 to 5
GUICtrlCreateInput("00", $iPos, 3, 20, 17, 1, 4)
GUICtrlSetLimit(-1, 2)
GUICtrlSetFont(-1, 10, 800, "", "Garamond")
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hParent)
If $i = 0 Then
$hOldC = _WinAPI_SetWindowLong(GUICtrlGetHandle(-1), -4, $pCall)
Else
_WinAPI_SetWindowLong(GUICtrlGetHandle(-1), -4, $pCall)
EndIf
GUICtrlCreateLabel("-", $iPos + 41, 30, 4, 2, $SS_SUNKEN)
GUICtrlSetFont(-1, 10, 800, "", "Garamond")
$iPos += 23
Next
GUICtrlDelete(-1)
$iBtnRead = GUICtrlCreateButton("Read", 20, 60, 140, 20)
GUISetState()
GUIRegisterMsg(0x111, "_WMCOMMAND")
Do
$iMsg = guiGetMsg()
Switch $iMsg
Case $iBtnRead
Dim $sData = ""
For $i = 4 to 14 Step 2
$sData &= GUICtrlRead($i) & "-"
Next
Msgbox(0, '', StringTrimRight($sData, 1))
EndSwitch
Until $iMsg = -3
Func _IptProc($hWnd, $iMsg, $wparam, $lparam)
If $iMsg = $WM_CHAR Then
If StringIsXDigit(Chr($wparam)) = 0 And $wparam <> 8 Then Return 0
EndIf
Return _WinAPI_CallWindowProc($hOldC, $hWnd, $iMsg, $wparam, $lparam)
EndFunc ;==>_IptProc
Func _WMCOMMAND($hWnd, $iMsg, $wparam, $lparam)
Local $nID, $iNotifyCode
$nID = bitAND($wparam, 0xFFFF)
$iNotifyCode = bitShift($wparam, 0x10)
If $iNotifyCode = $EN_CHANGE Then
If StringLen(GUICtrlRead($nID)) >= 2 Then
GUICtrlSetState($nID + 2, $GUI_FOCUS)
_GUICtrlEdit_SetSel($nID + 2, 1, 2)
EndIf
EndIf
EndFunc ;==>_WMCOMMAND
完全是多个INPUT控件组合模拟出来的,如果都在一个INPUT控件中,那么完成楼主的要求,对我来说不知要难上多少倍。虽是模拟,但生成的界面和效果和顶楼的无甚两样。