Jump to content

edit go to line


E1M1
 Share

Recommended Posts

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

Link to comment
Share on other sites

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!"

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

#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

Link to comment
Share on other sites

#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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...