Jump to content

Reading Massive Text Amounts From Edit Controls?


Recommended Posts

I am trying to find the fastest way to read/copy huge amounts of text from Edit-windows. To read and write line by line is kinda slow, at least the way I made it (GetLine/FileWriteLine).

ControlGetText cant handle more than 64 kB? - May there be a quick way by reading/writing the Edit partially?

The program got this Edit control and there is no way of saving the text with the program or so... I have to simply read it and rewrite it to a file. Anyone got any ideas?

Link to comment
Share on other sites

why don't you use GUICtrlRead() and FileWrite()?

$text = GUICtrlRead($edit)
FileOpen("file.txt", 8)
FileWrite("file.txt", $text)

instead of this

FileOpen("file.txt", 8)
For $line = 1 To _GUICtrlEditGetLineCount($edit)
   ControlCommand("Edit", GUICtrlRead($edit), $edit, "GetLine", $line)
   FileWrite("file.txt", $text)
Next

EDIT:

but how much text ist in the editbox, that it woukld be 2MB? that must be billions of lines!

Edited by Lord_Doominik
Link to comment
Share on other sites

why don't you use GUICtrlRead() and FileWrite()?

$text = GUICtrlRead($edit)
FileOpen("file.txt", 8)
FileWrite("file.txt", $text)

instead of this

FileOpen("file.txt", 8)
For $line = 1 To _GUICtrlEditGetLineCount($edit)
   ControlCommand("Edit", GUICtrlRead($edit), $edit, "GetLine", $line)
   FileWrite("file.txt", $text)
Next

EDIT:

but how much text ist in the editbox, that it woukld be 2MB? that must be billions of lines!

May GUICtrlRead() be used for reading other applications than AutoIt-ones? For instance Notepad. If so... how?

And yes... 2 MB is a lot :)

Link to comment
Share on other sites

  • 3 weeks later...
  • Moderators

Anyone who could help please?

Can you copy and paste it?

Edit:

This worked quickly:

$GetText = ControlGetText('Untitled - Notepad', '', 'Edit1')
ControlSetText('SetTextTest.txt - Notepad', '', 'Edit1', $GetText)
I opened notepad, copied the contents to the clipboard, put the contents in a test.txt. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I don't know the best way, I have no way to test for myself... No program to look at, no text, no edit control, etc.... Help us to help you.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

OK.

This is what I can do:

Select/Delete/Edit text manually.

Select the whole text (lots) and put it in clipboard and paste it all to Notepad manually.

This is what I can't do:

Use some sort of "save function".

Use short-cut keys to "select all".

It is pretty the same as notepad, but without functions... Any other info that would help you?

Edited by spanga
Link to comment
Share on other sites

  • Moderators

Have you tried something like this:

WinActivate('Untitled - Notepad')
ControlSend('Untitled - Notepad', '', 'Edit1', '^a^c')
WinActivate('SetTextTest.txt')
ControlSend('SetTextTest.txt - Notepad', '', 'Edit1', '^v')
Although I don't know why this would work and the other wouldn't.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

As I mentioned short-cut keys like that don't work. But it is possible to select it manually and have all the text in clipboard. I guess it is a limitation in the ControlGetText function resulting in only 32,768 chars get put in to clipboard.

Link to comment
Share on other sites

  • Moderators

Maybe you can create an object to read it, I'm sure it would be more proficient... of course we don't know what the applications name is that your guarding so tightly... so that's something you would have to do on your own.

Edit:

BTW... ControlGetText() only got 32,766 chars on my tests, so you were 2 chars ahead of me :think:

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Do you have to select it from a control? if its a text file it would be easier to do a filereadline or such.

Also I have recently been working with a 1.7MB text file and I noticed that if I try to dump all the information into one variable a line at a time it gets REALLY SLOW. So I split it up so there are 500 lines of data in a variable and then it dumps another 500 lines into the next variable and so on. I could not belive how much time that saved on running it. It will take quite a bit more coding and you will have to Dim an Array to like [250] so you don't run out of variables.

Let me know if you need any more help.

Mike

Edited by MikeOsdx
Link to comment
Share on other sites

Try this, it worked for me....

I have a prog I made (encryption), which generated an insane amount of encrypted text vs. the input text. And one problem I faced was saving this from the $editbox to a file, THEN reopening the file to decrypt during testing only to find that all of it wasn't there. I would start with a file that was say, originally 1.01 KB and ended up with a 1.01 MB file.

At the top of your code add:

Dim $EM_SETLIMITTEXT = 0x00C5
Dim $EditBufSize = 500000000;<--Example large number... don't know what buffer limit is

And in the GUI portion (if there is one) add this:

$Edit_1 = GuiCtrlCreateEdit("", 10, 10, 640, 260);<--Example
$eOutput = $Edit_1
GUICtrlSendMsg ($eOutput, $EM_SETLIMITTEXT, $EditBufSize, 0)

Hope that helps....

Link to comment
Share on other sites

  • 4 weeks later...

Try this, it worked for me....

I have a prog I made (encryption), which generated an insane amount of encrypted text vs. the input text. And one problem I faced was saving this from the $editbox to a file, THEN reopening the file to decrypt during testing only to find that all of it wasn't there. I would start with a file that was say, originally 1.01 KB and ended up with a 1.01 MB file.

At the top of your code add:

Dim $EM_SETLIMITTEXT = 0x00C5
Dim $EditBufSize = 500000000;<--Example large number... don't know what buffer limit is

And in the GUI portion (if there is one) add this:

$Edit_1 = GuiCtrlCreateEdit("", 10, 10, 640, 260);<--Example
$eOutput = $Edit_1
GUICtrlSendMsg ($eOutput, $EM_SETLIMITTEXT, $EditBufSize, 0)

Hope that helps....

The program I am reading from isn't a Au3-script. It's the same as reading from Notepad's edit window.
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...