#include #Include #Include #include #include #include Global $Max_Car_Input_Control = 10 $hGUI = GUICreate("Test", 100, 320) $a_inpTest = Draw_Input_Controls($Max_Car_Input_Control) GUISetState() While 1 $a_Return = Return_Control_Focus($a_inpTest,$hGUI) Check_Index_And_Focus_New_Control($a_Return[0],$Max_Car_Input_Control+1,$a_inpTest,$a_Return[1]+1,$hGUI) Tooltip($a_Return[0] & " --- " & $a_Return[1]) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep(25) WEnd ;********************************************************************************************************************************************************************* Func _OIG_IsFocused($h_Wnd, $i_ControlID) ; Check if a control has focus. ;********************************************************************************************************************************************************************* Return ControlGetHandle($h_Wnd, '', $i_ControlID) = ControlGetHandle($h_Wnd, '', ControlGetFocus($h_Wnd)) EndFunc ;==>_OIG_IsFocused ;********************************************************************************************************************************************************************* Func Check_Index_And_Focus_New_Control($Var_CurrentControlFocus_Func,$Max_Index_Val,$aInputControls,$IndexControlNumber,$Winmain) ;********************************************************************************************************************************************************************* $Index_Val = ControlCommand($Winmain, "",$Var_CurrentControlFocus_Func, "getCurrentCol", "" ) if $IndexControlNumber=UBound($aInputControls) And $Index_Val=$Max_Index_Val Then $IndexControlNumber=0 ;Return 0 EndIf if $Index_Val = $Max_Index_Val Then for $i=9 to 221 ; any key +/- if _IsPressed($i) Then GUICtrlSetState($aInputControls[$IndexControlNumber],$GUI_FOCUS) EndIf Next EndIf if $Index_Val = 1 And _IsPressed(8) Then ;Backspace if $IndexControlNumber<=1 Then $IndexControlNumber=UBound($aInputControls)+1 ;Return 0 EndIf $IndexControlNumber -=1 GUICtrlSetState($aInputControls[$IndexControlNumber-1],$GUI_FOCUS) Sleep(100) EndIf EndFunc ;********************************************************************************************************************************************************************* Func ReturnIndexControl($aControls_Func,$Control_Func) ;********************************************************************************************************************************************************************* for $i=0 to UBound($aControls_Func)-1 if $Control_Func=$aControls_Func[$i] Then Return $i Next Return -1 EndFunc ;********************************************************************************************************************************************************************* Func Return_Control_Focus($a_inpTest_Func,$Winmain) ;********************************************************************************************************************************************************************* Local $a_Return[2]=["",""] for $i=0 to UBound($a_inpTest)-1 if _OIG_IsFocused($Winmain, $a_inpTest_Func[$i])=True Then $a_Return[0]=$a_inpTest_Func[$i] $a_Return[1]=ReturnIndexControl($a_inpTest_Func,$a_inpTest_Func[$i]) Return $a_Return EndIf Next EndFunc ;********************************************************************************************************************************************************************* Func Draw_Input_Controls($Max_Car_Input_Control_Func) ;********************************************************************************************************************************************************************* Local $a_inpTest_Func[10] $incy=0 for $i=0 to UBound($a_inpTest_Func)-1 $a_inpTest_Func[$i] = GUICtrlCreateInput("", 10, 10+$incy, 70, 20) GUICtrlSetLimit($a_inpTest_Func[$i],$Max_Car_Input_Control_Func) $incy+=30 Next Return $a_inpTest_Func EndFunc