Jump to content
Sign in to follow this  
E1M1

edit go to line

Recommended Posts

E1M1

Is there any command or method how to goto given line in edit control? Only thing I came up with was _GUICtrlEdit_LineScroll($Edit1, 10, 10) but this command onlyscrols text, but it dont move your cursor on that line

Edited by E1M1

edited

Share this post


Link to post
Share on other sites
GEOSoft

Help File >> ControlCommand()


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
Valuater

try..

GUICtrlSendMsg($Edit, $EM_SETSEL, 150, 180)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
E1M1

it won't go to given line go goes to given char.

I have seen some scripts that have DllStruct* commands and DllCall commands... but can someone make similar thing for going to line?

I wonder why autoit dont have command for so usual operation. Edit is 1 of the most used GUI element, and autoit just dont have full support for it....

Edited by E1M1

edited

Share this post


Link to post
Share on other sites
Valuater

You are not giving enough info, or script, to make a reasonable effort to help you..

We do not read minds

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

$iPos = GUICtrlSendMsg($Edit, $EM_LINEINDEX, 9, 0)
GUICtrlSendMsg($Edit, $EM_SETSEL, $iPos, $iPos)
Well, you got someone to guess....

... did that do the trick?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
E1M1

Thanks

but where from do you learn tings like $EM_SETSEL and $EM_LINEINDEX? I cant see those variables in help file.


edited

Share this post


Link to post
Share on other sites
E1M1

yep this is what i was looking for


edited

Share this post


Link to post
Share on other sites
Mat

Sorry to bump a complet-ish topic, but:

how can I search for a word in an edit and then highlight it + scroll to it?

I can search, and I can highlight chars and scroll to them, but I don't know how to search and return the character #...

some help would be appreciated...

Mdiesel

Share this post


Link to post
Share on other sites
E1M1

#Include <GuiEdit.au3>

_GUICtrlEdit_Find($hWnd[, $fReplace = False])

it will also highlight (actually mark) the string

or you can write ur own richtext control.

Edited by E1M1

edited

Share this post


Link to post
Share on other sites
Authenticity

#include <EditConstants.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>

HotKeySet('^f', 'Find')

Dim $iCase = 0, $iCurrent = 0, $iPos = 0
Dim $sEdit = '', $sSearch = ''

Dim $hGUI = GUICreate('GUI', 350, 200)
Dim $Edit = GUICtrlCreateEdit('', 0, 0, 350, 200)

Dim $hFindGUI = GUICreate('Search', 200, 120, 50, 50, BitOR($WS_POPUPWINDOW, $WS_CAPTION), $WS_EX_TOOLWINDOW, $hGUI)
Dim $EditSearch = GUICtrlCreateEdit('', 20, 20, 160, 25, 0)
Dim $CheckCaseSensitive = GUICtrlCreateCheckbox('&Use case-sensitive search', 20, 50)
Dim $ButtonFindNext = GUICtrlCreateButton('&Next', 30, 90, 60, 25)

GUISwitch($hGUI)

For $i = 1 To 20
    GUICtrlSetData($Edit, 'The quick brown fox jumps over the lazy dog' & @CRLF, 1)
Next

GUISetState()
GUICtrlSendMsg($Edit, $EM_SETSEL, 0, 0)

While 1
    Local $Msg = GUIGetMsg(1)
    
    Select
        Case $Msg[0] = $GUI_EVENT_CLOSE And $Msg[1] = $hGUI
            ExitLoop
            
        Case $Msg[0] = $GUI_EVENT_CLOSE And $Msg[1] = $hFindGUI
            GUISetState(@SW_HIDE, $hFindGUI)
            
        Case $Msg[0] = $ButtonFindNext
            $sSearch = GUICtrlRead($EditSearch)
            $sEdit = GUICtrlRead($Edit)
            
            If $sSearch <> "" Then
                $iPos = StringInStr($sEdit, $sSearch, $iCase, 1, $iCurrent)
                ConsoleWrite($iPos)
                GUICtrlSetState($Edit, $GUI_FOCUS)
                If $iPos Then GUICtrlSendMsg($Edit, $EM_SETSEL, $iPos-1, $iPos+StringLen($sSearch)-1)
            EndIf
            
        Case $CheckCaseSensitive
            If GUICtrlRead($CheckCaseSensitive) = $GUI_CHECKED Then
                $iCase = 1
            Else
                $iCase = 0
            EndIf
    EndSelect
WEnd

GUIDelete()

Func Find()
    $iCurrent = BitAND(GUICtrlSendMsg($Edit, $EM_GETSEL, 0, 0), 0xFFFF)+1
    GUISetState(@SW_SHOW, $hFindGUI)
EndFunc

Share this post


Link to post
Share on other sites
Authenticity

Yes, just change the $iCurrent on success to $iPos+StringLen($sSearch). ;]

Share this post


Link to post
Share on other sites
Valuater

It did not work for me???

... awh... hotKey()

8)

EDIT.... Very Nice Authenticity!!

Edited by Valuater

NEWHeader1.png

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  

×