Code:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GuiScrollBars.au3>
Global $inputs[0][3];x,y,handle
Global const $INPUT_INIT_X = 30
Global const $INPUT_INIT_Y = 10
Global const $INPUT_HEIGHT = 20
$hGUI = GUICreate("Test", 335, 100)
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
For $i = 1 to 15
newInput() ;Create inputs
Next
$button = GUICtrlCreateButton("Read",200,60)
GUISetState(@SW_SHOW)
_GUIScrollBars_Init($hGUI,-1,UBound($inputs)*2)
_GUIScrollBars_EnableScrollBar($hGUI,$SB_HORZ,$ESB_DISABLE_BOTH)
Func newInput()
If UBound($inputs) > 0 Then
$x = $INPUT_INIT_X
$y = $INPUT_INIT_Y + $inputs[UBound($inputs)-1][1] + $INPUT_HEIGHT;Last input y
Else
$x = $INPUT_INIT_X
$y = $INPUT_INIT_Y
EndIf
ReDim $inputs[UBound($inputs)+1][3];
$inputs[UBound($inputs)-1][0] = $x
$inputs[UBound($inputs)-1][1] = $y
GUICtrlCreateLabel(UBound($inputs),$x-25,$y)
$inputs[UBound($inputs)-1][2] = GUICtrlCreateInput("",$x,$y,120)
EndFunc
While 1
$msg = GUIGetMsg()
If $msg = $button Then
$keys = ""
For $i = 0 To UBound($inputs)-1
$keys &= GUICtrlRead($inputs[$i][2]) & @CRLF
Next
MsgBox(0,"KEYS",$keys)
EndIf
If $msg = -3 Then ExitLoop
WEnd
;Don't try to understand this, it cames with autoit help file example...
Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)
#forceref $Msg, $wParam, $lParam
Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
Local $index = -1, $yChar, $yPos
Local $Min, $Max, $Page, $Pos, $TrackPos
For $x = 0 To UBound($aSB_WindowInfo) - 1
If $aSB_WindowInfo[$x][0] = $hWnd Then
$index = $x
$yChar = $aSB_WindowInfo[$index][3]
ExitLoop
EndIf
Next
If $index = -1 Then Return 0
; Get all the vertial scroll bar information
Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
$Min = DllStructGetData($tSCROLLINFO, "nMin")
$Max = DllStructGetData($tSCROLLINFO, "nMax")
$Page = DllStructGetData($tSCROLLINFO, "nPage")
; Save the position for comparison later on
$yPos = DllStructGetData($tSCROLLINFO, "nPos")
$Pos = $yPos
$TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
Switch $nScrollCode
Case $SB_TOP ; user clicked the HOME keyboard key
DllStructSetData($tSCROLLINFO, "nPos", $Min)
Case $SB_BOTTOM ; user clicked the END keyboard key
DllStructSetData($tSCROLLINFO, "nPos", $Max)
Case $SB_LINEUP ; user clicked the top arrow
DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)
Case $SB_LINEDOWN ; user clicked the bottom arrow
DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)
Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
Case $SB_THUMBTRACK ; user dragged the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
EndSwitch
; // Set the position and then retrieve it. Due to adjustments
; // by Windows it may not be the same as the value set.
DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
_GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
;// If the position has changed, scroll the window and update it
$Pos = DllStructGetData($tSCROLLINFO, "nPos")
If ($Pos <> $yPos) Then
_GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))
$yPos = $Pos
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_VSCROLL