In this post, I will tell on how to quickly duplicate and paste massive quantities of textual content into fields once we get it from other source like database. The idea inception came from the problem when I was trying to automate a JNLP based application.The problem with sendKeys was, it was taking huge time to send a large text.This post talks about How to Copy a Large file in AutoIT.
As usual I was looking for a solution in google as well as stackoverflow to resolve this issue. Stackoverflow showed a way. They suggested to try AutoIT. I checked AutoIT documentation. The documentation made my job easy. Even the similar problem was mentioned in superuser forum.
As per Superuser forum:
AutoIt is a freeware Basic-like scripting language. Among its tricks, it can send fake keypresses to another program. This means that in principle, you could write a script that opens SQL Developer, waits for it to wake up, opens the right window, and does batches of those insert commands with a timed delay in between to give Developer a chance to catch up and empty the keyboard queue.
You can do some similar tricks with VBScript and the Windows Scripting Host, which you should already have, but I found AutoIt easier. I use it to automate a few jobs that would be a pain otherwise.
I still agree with Paul, though – it should be possible to load and run that script directly in SQL Developer. If you’re trying to avoid learning how for the moment, you’ll end up doing much more work learning other things to avoid it.
Another popular forum stackexchange also has the similar problem listed.
As per stackexchange:
AutoIt is a script language which allow you to automate the Windows’s user interface, and then to by-pass your security restriction.
To cover your needs AutoIt provides basic file access function (like you did it in Python I think) to read your .txt files’ content. Then with its Windows gui’s automation you can write the content into your Excell file (I recommend to use key trigger instead of mouse one’s) like a human would do it.
It’s a programming script language, so it’s very powerful, but it could be complicated for an uninitiated public, but you seem to be comfortable with programmation. Actually a macro recorder is provided, very useful for learning it.
AutoIt is well known for the large amount of game bots created with it. Personally I used it for automating text copy/paste and sending it through the network.
At this point, I was convinced that my issue can be resolved via AutoIT. I started learning the AutoIT codes. Few AutoIT forum post also suggested the solution. Please refer the AutoIT forum posts here:
Below are the consolidated effort I learned from all these forums:How to Copy a Large file in AutoIT.
The Syntax of Send() function is as follows:
Where parameter (i.e. flag) ‘1’ in the function indicates data is sent raw. The default is ‘0’ which is outlined as “Textual content incorporates special figures like + and ! to indicate Shift and ALT crucial-presses”.
AutoIt: ClipPut(), Positioning Contents to Clipboard
Nonetheless, this definitely is not the most productive technique to deliver large bodies of text to, say, notepad or to a form’s fields. The steps are as follows:
- Fetch the data.
- Put in the variable.
- Call the below function.
Func printOutput() Local $fTest $fTest = ClipPut($outputArrayRS) 'get benefit of table's area by index Run("notepad.exe") WinWaitActive("Untitled - Notepad") Ship("^v") EndFunc
The ClipPut perform locations the textual content in our clipboard. Then all we want to do is Deliver() the keys Manage+v as:
AutoIt: ClipGet(), Get Contents of Clipboard
I attempted to use the ClipGet purpose however, this did not work for me. ClipGet functionality does return the worth when using the MsgBox function. So with MsgBox() this performs:
Func printOutput() Local $fTest $fTest = ClipPut($outputArrayRS) 'get value of table's discipline by index MsgBox(, "myTest2", ClipGet())
Now to execute the operate all we will need to do is:
AutoIt: copy File as in Explorer
If you desire to duplicate a file as you would in Explorer then use the FileCopy perform:
The structure to use this perform is:
FileCopy ( "resource", "dest" [, flag] )
There are a number of flags that you can use with the FileCopy purpose:
[optional] this flag is a mix or a person of the next:
0= (default) do not overwrite present data files
1 = overwrite current files
8 = Produce spot listing construction if it doesn’t exist.
If we want to mix the flags then add the values with each other. In other terms, if we desire to overwrite an existing file in the desired destination and look at if the desired destination directory exists or not and if it does not then build the directory, then would use ‘9’ as the flag.
So the flag would be applied as:
FileCopy("C:\file_to_duplicate.txt", "D:\mydir\file_to_copy.txt", 9)
You can use wildcards in copying files these kinds of as ‘*’ which denotes zero or additional figures and ‘?’ which denotes zero or 1 character. So if you wished to duplicate all information in the temp directory (i.e. C:\temp) and then duplicate them to another directory you would use the pursuing code:
Be aware that you can not have have much more than just one wildcard in the filename and extension. So this will NOT get the job done:
You would want to use regular expressions to accomplish this a lot more advanced job.
An additional be aware that applies specially the extension is matches will be manufactured for the very first 3 people of the extension. In other words and phrases, this:
will copy all information with the extension ‘txt’ as well any extension as ‘txt*’. So extension ‘txt1’, ‘txt2’, ‘txt3’ will also by copied.