Jump to content

Unable to save to a specific path in system.


Recommended Posts

I have written a code to automate Adobe Printing a file to PDF function using AutoIT, the requirement is, "when we open Adobe pdf document and run the below script, it should automatically print it to pdf and save it to a specific location".

But when I run the below Autoit script file, instead of saving to the given path, it is saving just a folder before the given file path. Not the end point folder in the given path.

 "C:\u1\home\Audits_ABC\Completed_Audits\Server_Upload\" is the specific path.

But, it is saving the pdf in folder "C:\u1\home\Audits_ABC\Completed_Audits\" and skipping the last "Server_Upload" folder

I'm new to AutoIt, Does the ControlSend command have a limitation for taking the complete file path? Is there an alternative to it?

Or am I making a mistake in writing the code. Please help :)

PS: Ignore the long sleep pauses in the code.

 

MouseClick("Left",75,167)
Sleep(2000)
Send("^p")
Sleep(3000)
Send("A")
Sleep(2000)
ControlCommand("Print","","ComboBox","Selectstring",'Microsoft Print to PDF')
ControlClick("Print","","Button50")
Sleep(5000)
ControlClick("Save Print Output As","","ToolbarWindow324")
Sleep(2000)
ControlClick("Save Print Output As","","Edit2")
Sleep(2000)
Send("^a")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
ControlSend("Save Print Output As","","Edit2","C:\u1\home\Audits_DTS\Completed_Audits\Server_Upload")
Sleep(5000)
ControlClick("Save Print Output As","","Button2")
Sleep(1000)

 

 

Link to comment
Share on other sites

5 minutes ago, Drake said:

I have written a code to automate Adobe Printing a file to PDF function using AutoIT, the requirement is, "when we open Adobe pdf document and run the below script, it should automatically print it to pdf and save it to a specific location".

But when I run the below Autoit script file, instead of saving to the given path, it is saving just a folder before the given file path. Not the end point folder in the given path.

 "C:\u1\home\Audits_ABC\Completed_Audits\Server_Upload\" is the specific path.

But, it is saving the pdf in folder "C:\u1\home\Audits_ABC\Completed_Audits\" and skipping the last "Server_Upload" folder

I'm new to AutoIt, Does the ControlSend command have a limitation for taking the complete file path? Is there an alternative to it?

Or am I making a mistake in writing the code. Please help :)

PS: Ignore the long sleep pauses in the code.

 

MouseClick("Left",75,167)
Sleep(2000)
Send("^p")
Sleep(3000)
Send("A")
Sleep(2000)
ControlCommand("Print","","ComboBox","Selectstring",'Adobe PDF')
ControlClick("Print","","Button50")
Sleep(5000)
ControlClick("Save Print Output As","","ToolbarWindow324")
Sleep(2000)
ControlClick("Save Print Output As","","Edit2")
Sleep(2000)
Send("^a")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
ControlSend("Save Print Output As","","Edit2","C:\u1\home\Audits_DTS\Completed_Audits\Server_Upload")
Sleep(5000)
ControlClick("Save Print Output As","","Button2")
Sleep(1000)

 

 

 

Link to comment
Share on other sites

If I were to wager a guess, I suspect "Server_Upload" is being considered as the PDF file name.  Perhaps add the filename after the full path you need.

ControlSend("Save Print Output As","","Edit2","C:\u1\home\Audits_DTS\Completed_Audits\Server_Upload\pdf_filename.pdf")

 

Link to comment
Share on other sites

36 minutes ago, spudw2k said:

If I were to wager a guess, I suspect "Server_Upload" is being considered as the PDF file name.  Perhaps add the filename after the full path you need.

ControlSend("Save Print Output As","","Edit2","C:\u1\home\Audits_DTS\Completed_Audits\Server_Upload\pdf_filename.pdf")

 

Thank you for the reply spudw2k. Actually, the scenario here is the PDF file is already open in Adobe and I am doing 'CTRL + P' to print it. For saving, the file name is already populated by the system and I am only clicking SAVE button. The issue is, the file is not being saved to the end folder 'Server_Upload' in the path, instead it is being saved to 'Completed_Audits'. Is the path too long for the 'ControlSend' to send it?

Any help would be appreciated.

Link to comment
Share on other sites

I doubt it is a path length issue.  You should be able to tell this by skipping the ControlClick at the end.  If the full text shows up in the Edit2 field, then it is likely not a length issue. 

Tell you what, if you put in the path yourself, i.e. copy and paste, does it behave as expected, or does the file end up in the parent folder (Completed_Audits)?   

edit: To clarify what I mean, perform the same last two steps of your script  (type in the path into Edit2 and then Click Button2), but manually.

Edited by spudw2k
Link to comment
Share on other sites

On 7/10/2023 at 8:43 PM, spudw2k said:

I doubt it is a path length issue.  You should be able to tell this by skipping the ControlClick at the end.  If the full text shows up in the Edit2 field, then it is likely not a length issue. 

Tell you what, if you put in the path yourself, i.e. copy and paste, does it behave as expected, or does the file end up in the parent folder (Completed_Audits)?   

edit: To clarify what I mean, perform the same last two steps of your script  (type in the path into Edit2 and then Click Button2), but manually.

Thank you, but I shortened the path and it is working.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...