#include <GuiConstants.au3>
#Include <string.au3>
#include <GuiEdit.au3>
HotKeySet("!s", "_selectionRead")
 
GUICreate("Test", 200, 100)
$a = GUICtrlCreateEdit("", 20, 20, 150, 32, $WS_HSCROLL, $WS_EX_LAYERED )
GUISetState(@SW_SHOW)
 
$b = _StringRepeat("1234567890", 15)
GUICtrlSetData($a, $b)

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
   EndSelect
	 Sleep(10)
WEnd
 
Exit

Func _selectionRead()
	_GUICtrlEditSetSel ($edit, 0, 0)
;~ 	MsgBox(0, '', _GUICtrlEditGetSelTxt($a) & @LF & @error)
EndFunc


;----------------------------------------------------------------------------------------------------------------------
;	Fuction			_GUICtrlEditGetSelTxt($h_edit)
;
;	Description		Get selectet text from an edit-control
;
;	Parameter		$h_edit		edit control
;
;	Return			Succes		selected text
;					Failure		0	set @error = 1; error from _GUICtrlEditGetSel()
;									set @error = 2; nothing selected
;
;	Requirement		#include <GuiEdit.au3>
;
; 	Author			BugFix (bugfix@autoit.de)
;----------------------------------------------------------------------------------------------------------------------
Func _GUICtrlEditGetSelTxt($h_edit)
	Local $sel = _GUICtrlEditGetSel($h_edit)
	If ($sel == $EC_ERR) Then
		SetError(1)
		Return 0
	ElseIf (Not IsArray($sel)) Or ($sel[1] = $sel[2]) Then
		SetError(2)
		Return 0
	EndIf
	Local $selTxt = ''
	$arTxt = StringSplit(GUICtrlRead($h_edit),'')
	For $i = $sel[1]+1 To $sel[2]
		$selTxt &= $arTxt[$i]
	Next
	Return $selTxt
EndFunc ;==>_GUICtrlEditGetSelTxt