Jump to content
UBot Underground

Problem With Timing Of Windows Commands Used With Save As


Recommended Posts

I am in desperate need for some help with this problem I can't seem to resolve.  All I am trying to do is use the Windows Commands and save a report.

 

The following code will click the `Download` button, which opens the `Save As` dialog, but the plugin command fails presumably because it runs too quickly:

 

navigate("http://www.reports.propertyline.ca/pdfjs/web/viewer.html?file=%2FReport%2F%3FSessionID%3D8a5616d7-bc3d-4b3d-a339-c279178b7dba%26ReportID%3D246214%2C%26InvoiceID%3D430019%26InvoiceItemID%3D470627%26Type%3DBasic%20Report%26Agent%3D2%26NoImg%3Dfalse%26AddMap%3Dtrue","Wait")
wait(2)
click($element offset(<id="download">,0),"Left Click","No")
plugin command("WindowsCommands.dll""click dialog button""Save As""Save")

 

To solve the problem, I tried to insert a `wait(5)` command before the plugin command like this:

 

navigate("http://www.reports.propertyline.ca/pdfjs/web/viewer.html?file=%2FReport%2F%3FSessionID%3D8a5616d7-bc3d-4b3d-a339-c279178b7dba%26ReportID%3D246214%2C%26InvoiceID%3D430019%26InvoiceItemID%3D470627%26Type%3DBasic%20Report%26Agent%3D2%26NoImg%3Dfalse%26AddMap%3Dtrue","Wait")
wait(2)
click($element offset(<id="download">,0),"Left Click","No")
wait(5)
plugin command("WindowsCommands.dll""click dialog button""Save As""Save")

 

For some reason, this causes a problem and the `Save As` dialog no longer appeals once I add the wait(5) command after the button click.  

 

This is driving me nuts.  Can someone please show me what needs to be done to download and save this report?  I would really appreciate the help on this.  I have asked a couple of questions already related to this same issue but no one has given me any ideas as to what I should try.  Thanks in advance for your help.

Link to post
Share on other sites

This should save a copy in the folder your bot is saved in,so get as far as the page with the pdf,get the URL and put that into the PdfDownload command,I dont know if login credentials are required but it looks like the sessionID is enough

define PdfDownload(#url) {
    plugin command("SocketCommands.dll", "socket container") {
        plugin command("SocketCommands.dll", "socket download file", $replace(#url,"/pdfjs/web/viewer.html?file=",""), "{$special folder("Application")}\\report.pdf")
    }
}
PdfDownload("http://www.reports.propertyline.ca/pdfjs/web/viewer.html?file=/Report/?SessionID=8a5616d7-bc3d-4b3d-a339-c279178b7dba&ReportID=246214,&InvoiceID=430019&InvoiceItemID=470627&Type=Basic Report&Agent=2&NoImg=false&AddMap=true")

Link to post
Share on other sites

Thanks for trying, but unfortunately this does not work because there is no "page with the pdf".  If the URL was a link directly to the PDF then your code would work perfectly, but the URL in question is not directly to the PDF.  The URL is for the pdfjs web viewer page, not the PDF itself.  When I try to download the report.pdf, it does not actually download the PDF.  It only downloads the HTML of the page that displays the PDF.  Here is a link to the HTML file that is downloaded.  You can see that what we are getting is the pdfjs web viewer control stuff, and not the PDF itself.

 

It seems like the only way to get the PDF is to click on the download button, which generates the PDF and opens the Save As dialog.

 

Any more ideas?

Link to post
Share on other sites

'their is "page with the pdf"'

 

Yes there is a page,if you take /pdfjs/web/viewer.html?file= out of the URL string in chrome for example,the file downloads automatically,the string even tells you to load this file into the webviewer

Your URL
http://www.reports.propertyline.ca/pdfjs/web/viewer.html?file=/Report/?SessionID=8a5616d7-bc3d-4b3d-a339-c279178b7dba&ReportID=246214,&InvoiceID=430019&InvoiceItemID=470627&Type=BasicReport&Agent=2&NoImg=false&AddMap=true

becomes

http://www.reports.propertyline.ca/Report/?SessionID=8a5616d7-bc3d-4b3d-a339-c279178b7dba&ReportID=246214,&InvoiceID=430019&InvoiceItemID=470627&Type=BasicReport&Agent=2&NoImg=false&AddMap=true
 
open this page above in chrome,and a file is immediately downloaded to your downloads called "Basic Report" WITHOUT any page opening.You need to rename this to end with .pdf,as it is just a file downloaded with no extension

 

I have added a pic below,to the left is the url above and to the right,the pdf file downloaded from the URL below

http://imgur.com/5s1fLtE

 

You put the URL into my code
 
just go to the page where the pdf is and and run this code exactly as it is below please,I have edited the code to URL decode,whatever is the browser,maybe that was the problem

plugin command("SocketCommands.dll", "socket container") {
    plugin command("SocketCommands.dll", "socket download file", $plugin function("SocketCommands.dll", "$url decode", $replace($url,"/pdfjs/web/viewer.html?file=","")), "{$special folder("Application")}\\report.pdf")
}
  • Like 1
Link to post
Share on other sites

Save as dialog opens right up for me:

http://screencast.com/t/ind7V0gYmxVO

 

Thanks for taking a look.  I agree with you that the Save As dialog opens up a few seconds after you click the download button, but what I need to do next is specify the filename, and click the Save button.  When I add the following lines, it does not work for me:

 

wait(5)

plugin command("WindowsCommands.dll""set dialog text""Save As""File name:""blue.pdf")

wait(5)

plugin command("WindowsCommands.dll""click dialog button""Save As""Save")

 

I see now that another ubotter (a2mateit) has made a suggestion that the Save As dialog may in fact be there, but for some reason I cannot see it.  Perhaps I should give that a try...

Link to post
Share on other sites

Sorry about that.  What I meant to say was that we are so close I can almost taste it!  You've made me realize that it is in fact possible to get to the "PDF page" directly by modifying the URL as you suggested.  I followed your suggestion and manually modified the URL and I was able to download the PDF.  That is awesome!  Thank you so much for that.

 

I then went to implement your suggestion within my larger code, and I received this error:

 

http://i827.photobucket.com/albums/zz196/Daniel_Attard/uBot%20error_zpsirsbqurd.png

 

Do you have any reason why I might be getting this error?  I used these lines of your code:

 

     plugin command("SocketCommands.dll""socket container") {
        plugin command("SocketCommands.dll""socket download file"$plugin function("SocketCommands.dll""$url decode"$replace($url,"/pdfjs/web/viewer.html?file=","")), "{$special folder("Application")}\\report.pdf")
    }

 

and dropped them into another define, and this was the error.  Maybe it has something to do with the $url decode command that might be causing the protocol violation.  I'll keep playing with it for now and see what I can find out.  If you have any ideas, please keep them coming.

Edited by APTS
Link to post
Share on other sites

thats great well for the mean time use this instead,plugin Advanced Shell is free if you do not have(thanks Dev of this)

 

plugin command("Advanced Shell.dll""shell batch hidden""start chrome \"{$replace($plugin function("SocketCommands.dll""$url decode", $url),"/pdfjs/web/viewer.html?file=","")}\"""Yes")

 

that will open chrome,and as you said chrome automatically downloads it,be sure to keep the url decoding their,that is important

 

I have no idea what causes that error as my computer is fine

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...