darkwalk Posted September 1, 2009 Share Posted September 1, 2009 I have the following script that opens acrobat pro and makes pdf from webpages. It works 80% of the time. The rest, however, does not. The "ControlSend" command sometimes will replace "http://66.82.3.80" with "http;//66.82.3.80". Notice the ";". Also, once in a blue moon, it will replace the numbers "32" with "#@". It looks like the shift key was depressed, but I don't touch the keyboard when the script is running. Any help is appreciated. Thanks! Dim $urls[10] $urls[0] = "http://66.82.3.80" $urls[1] = "http://66.82.3.80" $urls[2] = "http://66.82.3.73" Dim $urlNames[10] $urlNames[0] = "c32NLVNV" $urlNames[1] = "c33NLVNV" $urlNames[2] = "c63BOIID" Dim $path = "\\127.0.0.1\mrtgTmp\" Dim $fullPath Opt("SendKeyDelay", 50) ShellExecute("Acrobat.exe") For $i = 0 to 9 step 1 WinWait("Adobe Acrobat Pro") sleep(2000) Send("+^o") WinWait("Create PDF from Web Page") ControlSend("Create PDF from Web Page", "", "", $urls[$i]) ************** Problem area *********************** ControlClick ( "Create PDF from Web Page", "", "[CLASS:Button; INSTANCE:8]") WinWait("Download Status"); WinWaitClose("Download Status"); sleep(200) Send("+^s") WinWait("Save As") $fullPath = $path & $urlNames[$i] & ".pdf" ************** Problem area *********************** ControlFocus("Save As", "", 1148 ) ControlSend("Save As","","",$fullPath) ControlClick("Save As","","[CLASS:Button; INSTANCE:2]") sleep(100) Send("!y") WinWait($urlNames[$i] & ".pdf","",2) sleep(200) Send("^w") sleep(200) ;WinWaitClose("Adobe Acrobat Pro", 3) ;sleep( 1000 ) Next Send("^q") Link to comment Share on other sites More sharing options...
WolfWorld Posted September 1, 2009 Share Posted September 1, 2009 Dude, see the SendKeyDelay set it at 250 if it does not then 300 then 350 and keep on. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
darkwalk Posted September 4, 2009 Author Share Posted September 4, 2009 Not working. I've tried all the way up to 500ms. It seems to fail in the first iteration of the script. Then, if I manually start it again, its okay. I'm blocked by this. Is there anything else for me to try? Thanks. Link to comment Share on other sites More sharing options...
GEOSoft Posted September 4, 2009 Share Posted September 4, 2009 (edited) A couple of tips to get you started with controls and arraysAlways set the ControlID parameter instead of using an empty stringTry ControlSetText() instead of ControlSend()Try Not to use Dim and definitly don't use it to declare a non-array variable. Dim = Dim(ension) Use Global or Local insteadCreate your Arrays as a single 2-Dimension array instead (See Below)You don't need the Step 1. That's the default. Just use For $i = 0 to Ubound(<array>) -1This is just off the top of my head so double-check it against the help file.Global $aURL[3][2] = [["http://66.82.3.80", "http://66.82.3.80", "http://66.82.3.73"]["c32NLVNV", "c33NLVNV", "c63BOIID"]] ;; Watch out for line wrap ;;To Call the Array Elements your lines would change to ControlSetText("Create PDF from Web Page", "", <controlID>, $aURL[$i][0]);; ************** Problem area ;;And $fullPath = $path & $aURL[$i][1] & ".pdf";; ************** Problem areaEdit: Oooops, forgot one. If you are going to use ControlSend() anyway, set the flag to 1 (raw) in case there are "special" characters in the string. Edited September 4, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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