回复 8# cashiba
用最简单的思路
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Opt("GUIOnEventMode", 1)
Global $Input[7], $hHandle[7]
#Region ### START Koda GUI section ### Form=
$hForm = GUICreate("Form", 634, 376)
GUISetOnEvent($GUI_EVENT_CLOSE, "SEvents")
$iUP = GUICtrlCreateButton("", 0, 0, 0, 0)
GUICtrlSetOnEvent(-1, "OnDummyEvents")
$iDOWN = GUICtrlCreateButton("", 1, 1, 0, 0)
GUICtrlSetOnEvent(-1, "OnDummyEvents")
$iLEFT = GUICtrlCreateButton("", 2, 2, 0, 0)
GUICtrlSetOnEvent(-1, "OnDummyEvents")
$iRIGHT = GUICtrlCreateButton("", 3, 3, 0, 0)
GUICtrlSetOnEvent(-1, "OnDummyEvents")
Dim $Quickeys[4][2] = [["{UP}",$iUP],["{DOWN}",$iDOWN],["{LEFT}",$iLEFT],["{RIGHT}",$iRIGHT]]
GUISetAccelerators($Quickeys)
$Label1 = GUICtrlCreateLabel("数据录入窗口", 248, 8, 224, 31)
GUICtrlSetFont(-1, 20, 400, 0, "宋体")
$Label2 = GUICtrlCreateLabel("户名:", 32, 48, 63, 17)
GUICtrlSetFont(-1, 10, 400, 0, "宋体")
$Input[1] = GUICtrlCreateInput("", 128, 48, 121, 21)
GUICtrlSetState(-1,$GUI_FOCUS)
$Label3 = GUICtrlCreateLabel("号码:", 288, 48, 69, 17)
GUICtrlSetFont(-1, 10, 400, 0, "宋体")
$Input[2] = GUICtrlCreateInput("", 392, 48, 121, 21)
$Label4 = GUICtrlCreateLabel("品名:", 32, 96, 64, 17)
$Input[3] = GUICtrlCreateCombo("", 128, 96, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|")
$Label5 = GUICtrlCreateLabel("单位:", 288, 96, 40, 17)
$Input[4] = GUICtrlCreateCombo("", 392, 96, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9")
$Label6 = GUICtrlCreateLabel("数量:", 32, 144, 40, 17)
$Input[5] = GUICtrlCreateInput("", 128, 144, 121, 21,$ES_NUMBER)
$Label7 = GUICtrlCreateLabel("单价:", 288, 144, 40, 17)
$Input[6] = GUICtrlCreateInput("", 392, 144, 121, 21,$ES_NUMBER)
$buton1 = GUICtrlCreateButton("确定",150, 244, 121, 45)
$buton2 = GUICtrlCreateButton("取消",310, 244, 121, 45)
GUICtrlSetOnEvent($buton1, "OKPressed")
GUICtrlSetOnEvent($buton2, "NoPressed")
GUISetState(@SW_SHOW)
While 1
Sleep(10)
WEnd
Func SEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
Exit
EndSelect
EndFunc
Func OnDummyEvents()
Switch @GUI_CtrlId
Case $iUP ;向上
Local $focusName=ControlGetFocus($hForm)
For $i=1 To 6
If $focusName ="Edit"&$i Then
If $i >2 Then GUICtrlSetState($Input[$i-2],$GUI_FOCUS)
ExitLoop
EndIf
Next
Case $iDOWN ;向下
Local $focusName=ControlGetFocus($hForm)
For $i=1 To 6
If $focusName ="Edit"&$i Then
If $i<5 Then GUICtrlSetState($Input[$i+2],$GUI_FOCUS)
ExitLoop
EndIf
Next
Case $iLEFT ;向左
Local $focusName=ControlGetFocus($hForm)
For $i=1 To 6
If $focusName ="Edit"&$i Then
If $i > 1 Then GUICtrlSetState($Input[$i-1],$GUI_FOCUS)
ExitLoop
EndIf
Next
Case $iRIGHT ;向右
Local $focusName=ControlGetFocus($hForm)
For $i=1 To 6
If $focusName ="Edit"&$i Then
If $i<6 Then GUICtrlSetState($Input[$i+1],$GUI_FOCUS)
ExitLoop
EndIf
Next
EndSwitch
EndFunc
Func OKPressed()
exit
EndFunc ;==>OKPressed
Func NoPressed()
Exit
EndFunc
|