xolomon Posted May 8, 2013 Posted May 8, 2013 Dear all, I am using the Autoit to encrypt PDF files. I would like to open several pdf files one by one, encrypt them and save in another folder. I would like to limit the user actions during these operations. I have tried the method, BlockInput(1) but in this case, I cannot access to the acrobat reader menu by sending commands as the inputs are blocked. What can be an alternative in this case either to avoid user interaction or run this process in background? Can you provide me examples? Here is my code that basically opens a pdf file and saves in another folder. O.S. : Windows XP Professional X64 Adobe Acrobat Reader X 10.0 Professional Autoit: 3.3.8.0 #cs Define Environment #ce ;Debugingmodus wird aktiviert AutoItSetOption("TrayIconDebug",1) $acrobatPfad= "C:\Program Files\\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe" $d = 500 ;Delay between commands $filepath = "Z:\2013\01_PDF_Schutz\Testdaten" $file = "262000_____0000.pdf" $fileopen = $filepath & "\" & $file #cs Start Acrobat Reader with file #ce $title = $file & " - Adobe Reader" $handle = WinGetHandle("[CLASS:AcrobatSDIWindow]", "") Run($acrobatPfad & " " & $fileopen) sleep($d) WinWaitActive($title) Sleep($d) Send("{ALT}") Sleep($d) Send("{DOWN}") Sleep($d) Send("{DOWN}") Sleep($d) Send("{DOWN}") Sleep($d) Send("{ENTER}") Sleep($d) Send($file & "_active.pdf") Sleep($d) Send("{ENTER}") Sleep($d) ProcessClose("AutoIt3.exe")
water Posted May 8, 2013 Posted May 8, 2013 A few remarks.Please wrap your script in [autoit][/autoit] tags. Enhances readability!Don't use Send use Control* functionsDon't use Sleep after the run statement. Wait for the Window to pop up (WinWait)Remove ProcessClose. "Exit" is enough. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
xolomon Posted May 8, 2013 Author Posted May 8, 2013 Dear Water, thank you for your remarks. I have updated my code depending on your remarks as follows: expandcollapse popup#cs Define Environment #ce ;Debugingmodus wird aktiviert AutoItSetOption("TrayIconDebug",1) $acrobatPfad = "C:\Program Files\\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe" Opt("SendKeyDelay", 500) ;5 milliseconds $filepath = "Z:\01_PDF_Schutz\Testdaten" $file = "62000_____0000.pdf" $fileopen = $filepath & "\" & $file BlockInput(1) #cs Start Acrobat Reader X with file #ce $title = $file & " - Adobe Reader" $handle = WinGetHandle("[CLASS:AcrobatSDIWindow]", "") Run($acrobatPfad & " " & $fileopen) WinWaitActive($title) ControlSend($title,"","","{ALT}") ControlSend($title,"","","{DOWN 3}") ControlSend("[CLASS:AcrobatSDIWindow]","","","{ENTER}") ControlSetText("[CLASS:AcrobatSDIWindow]","","",$file & "_active.pdf") ControlSend("[CLASS:AcrobatSDIWindow]","","","{ENTER}") BlockInput(0) Exit I have the problem that when I use the blockinput, the commands that I sent to acrobat reader starting with "alt" command are not any more executed. Without blockinput works correctly. What can be the problem in this case? (I use windows xp professional sp2)
water Posted May 8, 2013 Posted May 8, 2013 Try to remove BlockInput. Shouldn't be necessary any more. Only Send statements can interfere with user input. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
xolomon Posted May 8, 2013 Author Posted May 8, 2013 Dear Water, I want to avoid the user interruption during the script execution. I have thought two possibilities, one to use block input and the second to start the acrobat reader either in minimized version or hide it as here. Run($acrobatPfad & " " & $fileopen, @SW_HIDE) The block input function didn't worked correctly, after sending the "alt" command it is stoped. While running in "hide" mode, I didn't get any reaction after running the script. What would you recommend in this case?
water Posted May 10, 2013 Posted May 10, 2013 Which command (encrypt PDF files) do you try to automate? I can't find anything about encryption? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
xolomon Posted May 13, 2013 Author Posted May 13, 2013 I am doing the encryption (setting password) using the menu operations of the Acrobat Reader. I start the acrobat reader and select the related menu where you can setup a password and then save the file.
BrewManNH Posted May 13, 2013 Posted May 13, 2013 Where in Reader are you able to set a password? Are you sure you don't need Adobe Acrobat for that? Reader is just for reading PDFs. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
BrewManNH Posted May 13, 2013 Posted May 13, 2013 Well, your script is looking for the Reader window, not the Acrobat window, which is probably most of the issue you're having. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Moderators JLogan3o13 Posted May 13, 2013 Moderators Posted May 13, 2013 Not to mention you have several times stated you were trying to do this in Acrobat reader. Not exactly helping us help you "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
xolomon Posted May 14, 2013 Author Posted May 14, 2013 Sorry for the misunderstanding, but the problem is that I am using at work acrobat reader professional and at home acrobat reader. That is the reason for the confusion . Thanks for your help.
Moderators JLogan3o13 Posted May 14, 2013 Moderators Posted May 14, 2013 As has been pointed out though, Acrobat Reader cannot do what Acrobat can - so your script is never going to work the same in both places. Are you trying to encrypt them at work, and then open them and input the password at home? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
xolomon Posted May 14, 2013 Author Posted May 14, 2013 I am working on setting the keyword at work with the professional version. For me the problem is to perform acrobat menu actions while acrobat is running in either hidden or minized mode. For this reason I try with acrobat reader more basic operations like opening a file and saving it to a location with another name. Currently I am trying to use the "WinMenuSelectItem" function to send file open command to the acrobat reader and couldn't manage. What can be the reason for that? (I tried with acrobat reader 9) Run($acrobatPath) WinWait("Acrobat Reader") WinMenuSelectItem("Acrobat Reader", "", "&File", "&Open...")
BrewManNH Posted May 14, 2013 Posted May 14, 2013 I don't believe that Reader menus will work with that command, you might try doing a ControlSend to the window with the shortcut key that Reader/Acrobat uses. I did this to fire off the File/Open menu item. ControlSend("Adobe Reader", "", "", "^o") If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
xolomon Posted May 14, 2013 Author Posted May 14, 2013 Yes, using the control send there is no problem, thanks. I have another question, when I start the acrobat reader in the hidden or minimized mode and send the file open command, acrobat reader becomes visible with the "Open" window activated. I have tried to hide the open file window but it doesn't work. WinWait("[TITLE:Öffnen]", "", 10) WinSetState("[TITLE:Öffnen]", "", @SW_HIDE)
jdelaney Posted May 14, 2013 Posted May 14, 2013 Unfortunatly the menu items can only be grabbed on the first level (file, help, etc)...the menu's under them hide all information. I was playing around with the _GuiCtrlMenu functions... $hwnd = WinGetHandle("[CLASS:AcrobatSDIWindow]") WinActivate($hwnd) $hMenu = _GUICtrlMenu_GetMenu($hwnd) $iFile = _GUICtrlMenu_FindItem($hMenu, "File") $hFileMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, $iFile) For $i = 0 To _GUICtrlMenu_GetItemCount($hMenu) - 1 ConsoleWrite(_GUICtrlMenu_GetItemText($hMenu,$i) & " " & @error & @CRLF) Next ConsoleWrite($hFileMenu & @CRLF) For $i = 0 To _GUICtrlMenu_GetItemCount($hFileMenu) - 1 ConsoleWrite(_GUICtrlMenu_GetItemText($hFileMenu,$i, True) & " " & @error & @CRLF) Next output: &File 0 &Edit 0 &View 0 &Window 0 &Help 0 0 0x0F760E03 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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