Jump to content

Controlcommand, Getline


Recommended Posts

If a large Edit control (like Notepad) has a long line wordwrapped, the "GetLine" ControlCommand returns the only portion of the line on visible on screen.

However, the AutoIt Spy program reports the text without wrapping.

For example, if '@' denotes the cursorGetLine returns only 'long word'

This is a really
long @ word
wrapped line.

Is there anyway to obtain the entire line?

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Since that function uses a common message, its reply can be whatever the program thinks a line is, even if its not exactly what you think it should be. AutoIt_Spy uses a different method to get text (I think it uses a control independant message where-as that function uses a control dependant one).

My best answer is to just say, turn wordwrap off. :whistle:

Link to comment
Share on other sites

Found something that works in metapad but (not notepad). I can check for the presence of @CR to determine if I got the entire line!

Opt("WinTitleMatchMode", 2)   ;mode 2 matches substrings
$title = "metapad"
$control = "RichEdit20A1"

;First, determine the end-of-line character....
;When metapad is in DOS-Text format, check for @CR

$eol = @CR

; If the result of GetLine does not end in $eol, then only a portion
; of a word-wrapped line was obtained.  Loop to get entire line...

While 1
    $n = ControlCommand($title, "", $control, "GetCurrentLine", "")
    $line = ControlCommand($title, "", $control, "GetLine", $n)
    
    TrayTip($n, $line, 30)

    Local $tmp = ""
    While ($n >= 1) And Not StringInStr($tmp, $eol)
        $n = $n - 1
        $tmp = ControlCommand($title, "", $control, "GetLine", $n)
    WEnd 

    $line = "";build up the actual entire line
    Do
        $n = $n + 1
        $tmp = ControlCommand($title, "", $control, "GetLine", $n)
        $err = @error
        $line = $line & $tmp
    Until StringInStr($tmp, $eol) Or $err


    ToolTip($line, 0, 0)
    sleep(100)
WEnd

Hmm, the code acts funny if I use a very small delay or use LF-only format: The tooltip blinks between the correct result and 1 (presumably implying that the ControlCommand sometimes fails)

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
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...