Sign in to follow this  
Followers 0
m0nk3yI3unz

Auto Scroll

10 posts in this topic

Heya. I searched for this but nothin came up.

How do I get an Edit box to automatically scroll when I add data to it? It is read only, and I have a function that reads all of its data then append a string to it and update the edit box, but when it exceeds the length of the box, it doesn't scroll down to show the new text. I have the autovscroll or w/e set on it, but it doesn't seem to be doing anything :)

Any help?

Monkey


Monkeh.

Share this post


Link to post
Share on other sites



Hi,

How do I get an Edit box to automatically scroll when I add data to it?

I supose you could send a Ctrl + END to the EditBox, but this doesn't work...

But you can send a proper message to editbox for scrolling always to a visible carret position:

#include <GuiConstants.au3>

$Gui = GuiCreate("Test")

$Edit = GUICtrlCreateEdit("Data", 120, 40, 250, 80)

$SetData = GUICtrlCreateButton("Set New Data", 20, 40)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
        Case $SetData
            $NewData = "New Data"
            _EditSetData($Edit, @CRLF & $NewData)
    EndSwitch
WEnd

Func _EditSetData($hEdit, $sData)
    Local Const $SB_SCROLLCARET = 0xB7
    
    GUICtrlSetData($hEdit, GUICtrlRead($hEdit) & $sData)
    GUICtrlSendMsg($hEdit, $SB_SCROLLCARET, 0, 0)
    ControlFocus($Gui, "", $hEdit)
EndFunc

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Try using these styles with the input control

Example

$input = GUICtrlcreateEdit("",5,22,190,25,$ES_AUTOVSCROLL+$WS_VSCROLL+$ES_MULTILINE+$ES_WANTRETURN)

Share this post


Link to post
Share on other sites

Try using these styles with the input control

Have you tested it before posting? it doesn't work.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Let me try it, MsCreatoR...

AHA! Thanks so much! It worked like a charm!

Question: What exactly does that all do? I mean the sending of the message and giving it focus?


Monkeh.

Share this post


Link to post
Share on other sites

Question: What exactly does that all do? I mean the sending of the message and giving it focus?

The sending message is to "tell" to our control that we want to sroll down to caret position, and the focus is to insure that we will see the caret after new set data (not so neccessary).

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

It does work, but maybe it has to be an GUICtrlCreateInput.

At least it does work with my input in v3.2.10.0

I wanted my input to be an log. So it had to be readonly and scroll to the last entry.

So my input has these styles: "$ES_AUTOVSCROLL+$WS_VSCROLL+$ES_MULTILINE+$ES_AUTOHSCROLL"

And after GUICtrlSetData to it I use: GUICtrlSendMsg($input, "0xB7", 0, 0)


My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites

i found 2 more examples. :)

remember to #include <GUIEdit.au3>

; #FUNCTION# ====================================================================================================

================

; Name...........: _GUICtrlEdit_Scroll

; Description ...: Scrolls the text vertically

; Syntax.........: _GUICtrlEdit_Scroll($hWnd, $iDirection)

; Parameters ....: $hWnd - Handle to the control

; $iDirection - This parameter can be one of the following values:

; |$SB_LINEDOWN - Scrolls down one line

; |$SB_LINEUP - Scrolls up one line

; |$SB_PAGEDOWN - Scrolls down one page

; |$SB_PAGEUP - Scrolls up one page

; |$SB_SCROLLCARET - Scrolls the caret into view

; Return values .: Success - The high-order word of the return value is TRUE

; +The low-order word is the number of lines that the command scrolls

; Failure - 0

; Author ........: Gary Frost (gafrost)

; Modified.......:

; Remarks .......:

; Related .......: _GUICtrlEdit_LineScroll

; Link ..........;

; Example .......; Yes

; ====================================================================================================

===========================

Func _GUICtrlEdit_Scroll($hWnd, $iDirection)

If $Debug_Ed Then _GUICtrlEdit_ValidateClassName($hWnd)

If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

If BitAND($iDirection, $SB_LINEDOWN) <> $SB_LINEDOWN And _

BitAND($iDirection, $SB_LINEUP) <> $SB_LINEUP And _

BitAND($iDirection, $SB_PAGEDOWN) <> $SB_PAGEDOWN And _

BitAND($iDirection, $SB_PAGEUP) <> $SB_PAGEUP And _

BitAND($iDirection, $SB_SCROLLCARET) <> $SB_SCROLLCARET Then Return 0

If $iDirection == $SB_SCROLLCARET Then

Return _SendMessage($hWnd, $EM_SCROLLCARET)

Else

Return _SendMessage($hWnd, $EM_SCROLL, $iDirection)

EndIf

EndFunc ;==>_GUICtrlEdit_Scroll

; #FUNCTION# ====================================================================================================

================

; Name...........: _GUICtrlEdit_LineScroll

; Description ...: Scrolls the text

; Syntax.........: _GUICtrlEdit_LineScroll($hWnd, $iHoriz, $iVert)

; Parameters ....: $hWnd - Handle to the control

; $iHoriz - Specifies the number of characters to scroll horizontally.

; $iVert - Specifies the number of lines to scroll vertically.

; Return values .: Success - True

; Failure - False

; Author ........: Gary Frost (gafrost)

; Modified.......:

; Remarks .......: The control does not scroll vertically past the last line of text in the edit control.

;+

; If the current line plus the number of lines specified by the $iVert parameter exceeds the total number

; of lines in the edit control, the value is adjusted so that the last line of the edit control is scrolled

; to the top of the edit-control window.

;+

; _GUICtrlEdit_LineScroll scrolls the text vertically or horizontally.

; _GUICtrlEdit_LineScroll can be used to scroll horizontally past the last character of any line.

; Related .......: _GUICtrlEdit_Scroll

; Link ..........;

; Example .......; Yes

; ====================================================================================================

===========================

Func _GUICtrlEdit_LineScroll($hWnd, $iHoriz, $iVert)

If $Debug_Ed Then _GUICtrlEdit_ValidateClassName($hWnd)

If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

Return _SendMessage($hWnd, $EM_LINESCROLL, $iHoriz, $iVert) <> 0

EndFunc ;==>_GUICtrlEdit_LineScroll


You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"

Share this post


Link to post
Share on other sites

And after GUICtrlSetData to it I use: GUICtrlSendMsg($input, "0xB7", 0, 0)

That exactly what i did in my example, and that exactly what used in the _GUICtrlEdit_Scroll() :)

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

ah I see how it works. THANKS!


Monkeh.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0