Sign in to follow this  
Followers 0
redpicker

Problem with pasting in Adobe Reader open window

4 posts in this topic

I have written a very simple script that takes an Excel spreadsheet, copies the acitve cell, switches to Adobe Reader, sends the file/open command and pastes the copied cell into the open window, selects all text in Adobe, copies the text, switches back to Excel to paste the contents in the spreadsheet, then copies the next value from Excel. Repeat for 200 times.

WinActivate("Microsoft Excel  Book 1")
For $i =1 to 200 step 1

Send("^c")
Send("{DOWN}")
WinActivate("Adobe Reader")
Sleep(100)
send("^o")
WinWaitActive("Open")
send("^v")
Sleep(500)
Send("{ENTER}")
Send("^a")
Sleep(200)
Send("^c")
Sleep(100)
Send("^w")
Sleep(100)
WinActivate("Microsoft Excel  Book 1")
Sleep(100)
Send("^{PGDN}")
Sleep(100)
Send("^v")
Sleep(100)
Send("{RIGHT}")
Sleep(100)
Send("^{PGUP}")
Sleep(100)
Next

The first sheet in the spreadsheet is a list of .PDF filenames that comes from a copied print-out of the directory that Adobe Reader is set-up to look at when opening the file, so this list can only contain valid .PDF filenames that exist in the directory that Reader is looking at. That is, each copied value from the first page in Excel is a valid filename for the directory opened by Adobe.

The second sheet in the spreadsheet is the copied contents of the .PDF file, each column being the contents of a single .PDF file.

The script works OK, but every so often, it will somehow paste the contents of the .PDF file in the open window of Adobe Reader instead of the cell it copied from Excel 6 lines earlier. When this happens, I can verify that "filename.PDF" was, in fact, copied from the Excel sheet, but for some reason, when the <send("^v")> command is executed in the open window of Reader, it doesn't paste the data it copied in the prior <Send("^c")> command, it pastes the data it copied from Reader in the previous loop.

Can anyone tell me why it is doing this or how I can stop it? The whole purpose of this script is to copy the text from hundreds of .PDF flies so I can extract certian data from them. Doing this manually is a real chore, but this script doesn't help much if I have to watch it and stop it every time it decides to paste the wrong value (which can be anywhere from around once in 10 times to over 100).

Thanks,

rp

Share this post


Link to post
Share on other sites



Sometimes it takes longer time to copy data with ^c so if you copy from one document and then try to copy from other and paste it it will still have data from previous loop if timing is too short and if it is working with alot of data on clipboard

my sugestion is to try ClipPut("") to have emty clipboard before ^c and then while clipget() <> "" sleep, and to try longer sleep comand after winactive and before and after ^c.

The other posible solytion is to sleep while specific mouse icon is active "sand watch" MouseGetCursor

Or wait to see if someone other have better sugestion, or more sutible solution for your problem to help y.


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Thanks for the replys. I think I found the problem. It has to do with Excel's autoRecover function.

As near as I can tell, if the autoRecover starts, Excel is disabled momentarily and the keystrokes from my script would land in a buffer (waiting on the autosave to complete). The script would move on, however, and when it pasted into Reader, it hadn't copied from the Excel sheet, yet. However, by the time the open box timed-out because it couldn't find the file (the only way I could tell it wasn't working right), Excel had caught-up, so the correct data did exist in the clipboard.

Anyway, disabling autoRecover (Tools/Options/Save tab) fixed it.

Thanks to all.

rp

Share this post


Link to post
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
Sign in to follow this  
Followers 0