Jump to content

WinGetText() 64Kb text limitations


wroom
 Share

Recommended Posts

I have a script that retrieves the text from an active window using the wingettext() command works fine

excepting when the text exceeds its limit as described in the help file,in this situation it truncates the text

(text in window is part of a application with that scrolls activity in realtime much to fast for any sort of OCR)

what I am hoping for is to possibly find a way to extract all the text in the active window or extract the "bottom part of the text"

the text can grow to about 400Kb somewhat larger than the 64Kb limit

Link to comment
Share on other sites

I have a script that retrieves the text from an active window using the wingettext() command works fine

excepting when the text exceeds its limit as described in the help file,in this situation it truncates the text

(text in window is part of a application with that scrolls activity in realtime much to fast for any sort of OCR)

what I am hoping for is to possibly find a way to extract all the text in the active window or extract the "bottom part of the text"

the text can grow to about 400Kb somewhat larger than the 64Kb limit

if it's an edit control there are ways to get what you want.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

if it's an edit control there are ways to get what you want.

Gary, Thanks for the tip

Yes it is a edit control and did a quick test and it appears to work ( I can extract the text from the text window)

using - "WinGetHandle" function to get the handle and using the example in the help file with a few modifications got the text

with "ControlGetText" function

I have not tested it fully yet if it resolves the size limitation issue but your help appears promising

Thanks

Link to comment
Share on other sites

Gary, Thanks for the tip

Yes it is a edit control and did a quick test and it appears to work ( I can extract the text from the text window)

using - "WinGetHandle" function to get the handle and using the example in the help file with a few modifications got the text

with "ControlGetText" function

I have not tested it fully yet if it resolves the size limitation issue but your help appears promising

Thanks

if that don't work for you might look at:

_GUICtrlEditGetLineCount

_GUICtrlEditGetLine

The above functions may end up deprecated in the near future.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • 2 weeks later...

I had the same buffer overflow problem with WinGetText(). But after reading this topic I got some new ideas which I'd like to share.

Instead of reading the entire text chunk at once, try read row by row.

Dim $rowCnt, $lastRow = 1, $row, $rows,
While True  
    $rowCnt = ControlCommand( "Windows-application-window-title", "", 101, "GetLineCount" ) 
    ; I used the AutoIt Window Tool to find our the control id 101 above 
    $rows = ""
    For $i=$lastRow To $rowCnt Step 1
        $row = ControlCommand( "Windows-application-window-title", "", 101, "GetLine", $i )
        $rows = $rows & $row
    Next
    If $lastRow < $rowCnt + 1 Then
        $lastRow = $rowCnt+1
    EndIf
    Sleep( 500 )
WEnd
Link to comment
Share on other sites

I had the same buffer overflow problem with WinGetText(). But after reading this topic I got some new ideas which I'd like to share.

Instead of reading the entire text chunk at once, try read row by row.

Dim $rowCnt, $lastRow = 1, $row, $rows,
While True  
    $rowCnt = ControlCommand( "Windows-application-window-title", "", 101, "GetLineCount" ) 
; I used the AutoIt Window Tool to find our the control id 101 above 
    $rows = ""
    For $i=$lastRow To $rowCnt Step 1
        $row = ControlCommand( "Windows-application-window-title", "", 101, "GetLine", $i )
        $rows = $rows & $row
    Next
    If $lastRow < $rowCnt + 1 Then
        $lastRow = $rowCnt+1
    EndIf
    Sleep( 500 )
WEnd
I would think that using the ControlGetHandle and then using the following would be better then reading row by row.

_GUICtrlEdit_GetLineCount

_GUICtrlEdit_GetLine

The above 2 functions are from the latest beta, which will work with external edit control, you should be able to retrieve and line from the edit control with-out reading the whole content.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I would think that using the ControlGetHandle and then using the following would be better then reading row by row.

_GUICtrlEdit_GetLineCount

_GUICtrlEdit_GetLine

The above 2 functions are from the latest beta, which will work with external edit control, you should be able to retrieve and line from the edit control with-out reading the whole content.

OK.

But just for some clarifcation on my script, it prevents me from getting buffer overflow. Each loop only reads the unread lines and allows me to execute logic on only those lines.

By the way, when will the _<functions> be added to docs?

Thanks for your support!

Link to comment
Share on other sites

OK.

But just for some clarifcation on my script, it prevents me from getting buffer overflow. Each loop only reads the unread lines and allows me to execute logic on only those lines.

By the way, when will the _<functions> be added to docs?

Thanks for your support!

There should be no buffer overflow with UDF functions, they use the API calls.

They are already in the Beta Docs, look in the UDF section of the help file of the Beta.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I have been searching for this but have not found an answer.

What's the easiest way to get the text size in the edit Window such that we can use the WinGetText if under 64k and read line by line otherwise.

For downloads of many screens / files I would think the WinGetText would run much faster.

At this point I am using wingettext then looking at the file size then re-downloading / overwriting if there was a risk of cropping.

Is there an easier way?

Thanks.

Link to comment
Share on other sites

Actually Ignore Last Post..

What I was trying to do is not working (I was looking at the string length after WinGetText) then deciding whether to do line by line extraction and file write or simply write full text to file if it was under a threshold.

Anyway, _GUICtrlEditGetLineCount and _GUICtrlEditGetLine are not working for me (and I may be using them incorrectly). I am not sure the control I am looking at is an edit control. AutoIt Window Info says the Class of the control is "RICHEDIT" - it is basically a text only result window where search results apear.

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...