Jump to content

Recommended Posts

Posted

Hello,

still learning and trying to understand AutoIT but having problem in filling my PDF file.

 

So my code looks like similar to this:

Global $1 = "text text 44444444"
Global $2 = "texting2 texting2"
Global $3 = "newtext3 next3"


ShellExecute ("C:\Users\XXX\Desktop\myPDF.pdf")
WinWaitActive("MyPDF.pdf - Adobe Acrobat Reader DC")
Send ("{TAB}")
ClipPut($1)
Send ("^v")
Send ("{TAB 3}")
ClipPut($2)
Send("^v")
Send ("{TAB}")
ClipPut($3)
Send("^v")

So its fill my PDF form, the first field looks good, the code add the text text 4444, then second should be $2 with texting2 texting2 but for some reason the code uses for second and third field after TAB only variable $3.

So, I receive in $2 and $3 for some reason same newtext3 next3 in both, why its skipping the variable $2? Maybe there also much better solution for instant text? Because Send writes with delay by letters which I don't like.

Thanks!

Posted
8 minutes ago, Danp2 said:

Also, have you considered dropping the use of ClipPut and just send the variable contents?

I do not have Acrobat Reader installed, but the approach from @Danp2 seems plausible to me.

Global $1 = "text text 44444444"
Global $2 = "texting2 texting2"
Global $3 = "newtext3 next3"

ShellExecute ("C:\Users\XXX\Desktop\myPDF.pdf")
WinWaitActive("MyPDF.pdf - Adobe Acrobat Reader DC")
Send ("{TAB}")
Send ($1)
Send ("{TAB 3}")
Send ($2)
Send ("{TAB}")
Send ($3)

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
6 hours ago, Danp2 said:

I've seen where you need a delay following ClipPut to give the item time to "appear" on the clipboard. Also, have you considered dropping the use of ClipPut and just send the variable contents?

You mean with Send()?

If yes, then it takes time while Send writes all the text and Opt SendKeyDownDelay, SendKeyDelay doesn't work here with 0 or 1 delay.

Posted
44 minutes ago, diff said:

Opt SendKeyDownDelay, SendKeyDelay doesn't work here with 0 or 1 delay.

The value sets the time in milliseconds to pause (default=5)(0 removes the delay completely). It is not an on/off switch. Try to set the value to 50 or 100. For testing purposes you can also place Sleep(xxx) commands between the sends. Not the most elegant solution, but give it a try.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
24 minutes ago, Musashi said:

The value sets the time in milliseconds to pause (default=5)(0 removes the delay completely). It is not an on/off switch. Try to set the value to 50 or 100. For testing purposes you can also place Sleep(xxx) commands between the sends. Not the most elegant solution, but give it a try.

Yeah I understand that it's not on/off, I tried random ms to set but it was still writing too long.

Looks like ClipPut works better if I add delay at least Sleep(200) about which was talking @Danp2. So, probably I solved my problem by adding everywhere Sleep(200) after ClipPut()

  • 4 years later...
Posted

I have found the delay of 200 ms after ClipPut is helpful to make it work correctly.  It seems to me that there are some steps that AutoIt should be doing during the execution of ClipPut (or blocking until the OS has done them) which it isn't doing, so we have to introduce an artificial delay so that OS can do it instead.  I was hoping there would be some AutoIt designers watching this forum to see what might need fixing.

Is there a forum here for reports of possible bugs? Improvements? Enhancements? Any "Open Source" kind of collaboration we can do?

  • Developers
Posted (edited)
28 minutes ago, Dave_Scotese said:

It seems to me that there are some steps that AutoIt should be doing during the execution of ClipPut (or blocking until the OS has done them) which it isn't doing, so we have to introduce an artificial delay so that OS can do it instead

Funny, so you register and post this feeling have about AutoIt in an 4 years old thread.

AutoIt3 uses mostly the standard windows calls, so how would exactly would this be an AutoIt3 issue? No blocking should be done internally and you as script developer need to handle any timing or race conditions yourself.

Just my 2 cents.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Ha!  As soon as I asked, I looked, and found https://www.autoitscript.com/trac/autoit

I started working on a script to demonstrate this bug and have come to the conclusion that ClipPut (as it should) relies on the program providing the clipboard contents, and if that code expects to be dealing with a human (not a machine), then it can rely on a little extra time even after returning.  This is basically what Jos is pointing to, I think.

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
×
×
  • Create New...