spanga Posted March 22, 2006 Share Posted March 22, 2006 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 More sharing options...
Lord_Doominik Posted March 22, 2006 Share Posted March 22, 2006 (edited) 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 March 22, 2006 by Lord_Doominik Link to comment Share on other sites More sharing options...
spanga Posted March 22, 2006 Author Share Posted March 22, 2006 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 More sharing options...
spanga Posted April 9, 2006 Author Share Posted April 9, 2006 Anyone who could help please? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 9, 2006 Moderators Share Posted April 9, 2006 (edited) 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 April 10, 2006 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 More sharing options...
spanga Posted April 9, 2006 Author Share Posted April 9, 2006 It only gets 32,768 bytes (way from total) but I guess this will be the best way to do it? Reading and writing it partially in chunks of 32kB Or is there an even better way? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 10, 2006 Moderators Share Posted April 10, 2006 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 More sharing options...
spanga Posted April 10, 2006 Author Share Posted April 10, 2006 (edited) 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 April 10, 2006 by spanga Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 10, 2006 Moderators Share Posted April 10, 2006 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 More sharing options...
spanga Posted April 10, 2006 Author Share Posted April 10, 2006 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 More sharing options...
Moderators SmOke_N Posted April 10, 2006 Moderators Share Posted April 10, 2006 (edited) 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 Edited April 10, 2006 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 More sharing options...
BigDaddyO Posted April 12, 2006 Share Posted April 12, 2006 (edited) 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 April 12, 2006 by MikeOsdx Link to comment Share on other sites More sharing options...
nfwu Posted April 12, 2006 Share Posted April 12, 2006 For some reason 32,768 is a very nice number, the maximum value of a C++'s short... #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
b1t5tR3@m Posted April 12, 2006 Share Posted April 12, 2006 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 More sharing options...
spanga Posted May 4, 2006 Author Share Posted May 4, 2006 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 More sharing options...
nfwu Posted May 5, 2006 Share Posted May 5, 2006 Can't you save the file then read it from the saved file? #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now