Jump to content

Recommended Posts

This UDF is because I'm tired of trying to use UI Automation and Send to automate Adobe Acrobat. I often need to read the contents of PDFs and Acrobat is not easy to work with as a window.  The functions are based on the API Reference from Adobe located here.

Acrobat Pro is required for all functions.

It's very beta right now, but it still seems to work. Currently, the functions are based around page level manipulation of PDF documents: re-arranging, swapping, deleting, and moving pages as this is what I use the most.

Please feel free to request/suggest features! :)

 

 

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites

You mean that you can't create a AcroExch.PDDoc without Pro? (_Acro_DocOpen would return error 1) I can't test this at work as I have Pro installed everywhere 😐

I guess I assumed that Reader would use the reference too. I might be able to work on this at home where I don't own Pro, but I'm not nearly as familiar with Reader

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites

TIL: Adobe Acrobat Pro is required for creating objects through AcroExch.App and AcroExch.PDDoc :(

There may be a way to automate Reader through DDE messages, but I'm unclear on what that is and if it's possible. Looking into it.

Edit: Read way too much on Reader...

Adobe Reader implements a different interface, resulting in a different set of functionality (Read: greatly reduced). I'm running out of ideas with Reader, but I'm pretty sure it implements IAcroAxDocShim (and a few more? C has multiple inheritance?) and can be created with AcroPDF.PDF or AcroPDF.PDF.1 - I think both, but it's something to do with the version of the type library you have.

I also found that not all of the methods are documented. There are three that I found: execCommand, postMessage, and messageHandler (get/set). I have no idea what they are/do. You'll see the methods if you find "Adobe PDF Reader" in the OLE/COM Object Viewer under "Object Classes\Grouped By Component Category\Automation Objects\" and right click to "View Type Information". From there, select 'Dispinterface IAcroAXDocShim' to see the methods available.

Aaand that's enough for now. I'll be dreaming in code tonight for sure.

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites

Updated to version 0.0.0.2. I found that the JavaScript Object can be accessed and used, meaning that bookmarks are edit-able and so much more.

Added Functions:

  • _Acro_DocDisplay
  • _Acro_PageRotate
  • _Acro_AppShow
  • _Acro_DocJSObject
  • _Acro_DocBookmarkAdd

Fixed:

  • _Acro_PageCount - Actually returns page count now

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites
  • 3 weeks later...

Bug: _Acro_PageGetText uses the wrong values to get the size of a page... dyslexia at work again...

Local $oRect = __Acro_Rect(0, $aPoint[0], 0, $aPoint[1])
;            Should be
Local $oRect = __Acro_Rect(0, $aPoint[1], 0, $aPoint[0])

Yeah... that's a good one. I'll try to update this soon. End of the month in accounting with a slow network. Nuff said? :D

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites
  • 3 months later...

Updated to version 1.0.0.0

Added _Acro_DocAppend, which is my most used function now. I'm constantly combining PDFs at work using this. :)

If you have any suggestions or notice any issues, don't hesitate to let me know!

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites
  • 2 weeks later...

seadoggie01

I can't seem to get _Acro_PageMove to work.  I have Acrobat 8 Pro.  Here's the code.  I'm not sure why it's not working.  I'm using the iac_api_reference.pdf file for checking but also just created a simple 4 page pdf to try it with the same result.  Any help/hints appreciated.

;Acro.au3 test program
#AutoIt3Wrapper_run_debug_mode=Y    ; use this to debug in console window <--- LOOK


#include <Acro.au3>

MsgBox(0, "Test", "Testing Acro UDF")

;Reverse order of pages e.g. 1,2,3,...,n-1,n to n,n-1,...3,2,1  - ALWAYS work from bottom to top
;open it
;$sFullPath = "C:\Program Files (x86)\AutoIt3\AH Code\PDF Processing\Acro UDF\Reverse test document pp 1-4.pdf"
$sFullPath = "C:\Program Files (x86)\AutoIt3\AH Code\PDF Processing\Acro UDF\iac_api_reference - WORKING COPY.pdf"
$oPdDoc = _Acro_DocOpen($sFullPath)
If $oPdDoc = False Then
    If @error = 1 Then MsgBox(0, "Error", "Could not find file: '" & $sFullPath &"'")
    If @error = 2 Then MsgBox(0, "Error", "Document not opened: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", "Document opened: '" & $sFullPath &"'")
EndIf


;get page count so we do all pages
$iPages = _Acro_PageCount($oPdDoc)
If $iPages = False Then
    If @error = 1 Then MsgBox(0, "Error", "$oPdDoc isn't a PDDoc object: '" & $sFullPath &"'")
    If @error = 2 Then MsgBox(0, "Error", "Can't get number of pages in: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", $iPages & " pages in document: '" & $sFullPath &"'")
EndIf

$j = 1  ;init value
For $i = $iPages to 2 Step -1   ;skip last move
    $iFromPage = $iPages    ;always move from last page
    $iToPage = $j
    $x = _Acro_PageMove($oPdDoc, $iFromPage, $iToPage)
    If $x = False Then
        If @error = 1 Then MsgBox(0, "Error", "$oPdDoc isn't a PDDoc object: '" & $sFullPath &"'")
        If @error = 2 Then MsgBox(0, "Error", "Unable to move page: " & $iFromPage & " to page: " & $iToPage & " in: '" & $sFullPath &"'")
    Else
        MsgBox(0, "Okay", "Old Page: " & $iFromPage & " moved to New Page: " & $iToPage & " in document: '" & $sFullPath &"'")
    EndIf
    $j = $j + 1     ;increment to next $iToPage
Next
MsgBox(0, "Status", "Reversed pages in: '" & $sFullPath &"'")


;be polite and close document
;close document
$x = _Acro_DocClose($oPdDoc)
If $x = False Then
    If @error = 1 Then MsgBox(0, "Error", "$oDoc isn't an AV/PD Doc object: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", "Document closed: '" & $sFullPath &"'")
EndIf


Exit

 

Reverse test document pp 1-4.pdf

Link to post
Share on other sites

The pages in a PDF document are 0-based, so try changing this:

$x = _Acro_PageMove($oPdDoc, $iFromPage, $iToPage)
; To this...
$x = _Acro_PageMove($oPdDoc, $iFromPage - 1, $iToPage - 1)

You'll also want to call _Acro_DocSave before closing the document, otherwise your changes won't be saved.

And finally, you do want to move that first page to the end if you're truly trying to reverse the whole document, otherwise you'll end up with pages like (1, 4, 3, 2) instead :)

(I'll make sure to add a note to the UDF on the next release about 0 or 1 based pages! Sorry for the confusion there :()

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites

seadoggie01,

Okay more confusion on my part.  I indeed get 1,4,3,2, however I don't understand why.

Here's what I thought the move sequence would look like.

original order    after 1st move     after 2nd move        after 3rd move

1                                   4                             4                               4

2                                   1                             3                               3

3                                   2                             1                               2

4                                   3                             2                               1

 

Here's the code.  (Also not sure why _Acro_DocSave isn't saving file as "-saved.pdf")

;
;Acro.au3 test program
#AutoIt3Wrapper_run_debug_mode=Y    ; use this to debug in console window <--- LOOK

#include <Acro.au3>

MsgBox(0, "Test", "Testing Acro UDF")

;Reverse order of pages e.g. 1,2,3,...,n-1,n to n,n-1,...3,2,1  - ALWAYS work from bottom to top
;from seadoggie01 PDF pages are Zero based so for n pages we have 0,1,2,...,n-2,n-1 to n-1,n-2,...,2,1,0
;open it
$sFullPath = "C:\Program Files (x86)\AutoIt3\AH Code\PDF Processing\Acro UDF\Reverse test document pp 1-4.pdf"
$oPdDoc = _Acro_DocOpen($sFullPath)
If $oPdDoc = False Then
    If @error = 1 Then MsgBox(0, "Error", "Could not find file: '" & $sFullPath &"'")
    If @error = 2 Then MsgBox(0, "Error", "Document not opened: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", "Document opened: '" & $sFullPath &"'")
EndIf


;get page count so we do all pages      ;page count is Zero based!! SO it goes from 0 to $iPage-1
$iPages = _Acro_PageCount($oPdDoc)
If $iPages = False Then
    If @error = 1 Then MsgBox(0, "Error", "$oPdDoc isn't a PDDoc object: '" & $sFullPath &"'")
    If @error = 2 Then MsgBox(0, "Error", "Can't get number of pages in: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", $iPages & " pages in document: '" & $sFullPath &"'")
EndIf

$j = 1  ;init value
For $i = $iPages to 2 Step -1   ;skip last move
    $iFromPage = $iPages    ;always move from last page
    $iToPage = $j
    MsgBox(0, "Debug", "moving["& $iFromPage - 1 &"] to ["& $iToPage -1 & "]")
    $x = _Acro_PageMove($oPdDoc, $iFromPage - 1, $iToPage -1)   ;-1 because Zero based
    If $x = False Then
        If @error = 1 Then MsgBox(0, "Error", "$oPdDoc isn't a PDDoc object: '" & $sFullPath &"'")
        If @error = 2 Then MsgBox(0, "Error", "Unable to move page: " & $iFromPage & " to page: " & $iToPage & " in: '" & $sFullPath &"'")
    Else
        MsgBox(0, "Okay", "Old Page: " & $iFromPage & " moved to New Page: " & $iToPage & " in document: '" & $sFullPath &"'")
    EndIf
    $j = $j + 1     ;increment to next $iToPage
Next
MsgBox(0, "Status", "Reversed pages in: '" & $sFullPath &"'")


;save the document
$sFullPath = StringTrimRight($sFullPath, 4) & "-saved.pdf"  ;name it "-saved.pdf"
MsgBox(0, "Debug", "$sFullPath = '" & $sFullPath &"'")
$x = _Acro_DocSave($oPdDoc, $sFullPath)
MsgBox(0, "Debug", "$x = '" & $x &"'")
If $x = False Then
    If @error = 1 Then MsgBox(0, "Error", "$oPdDoc isn't a PDDoc object: '" & $sFullPath &"'")
    If @error = 2 Then MsgBox(0, "Error", "Document not saved: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", "Document saved: '" & $sFullPath &"'")
EndIf


;be polite and close document
;close document
$x = _Acro_DocClose($oPdDoc)
If $x = False Then
    If @error = 1 Then MsgBox(0, "Error", "$oDoc isn't an AV/PD Doc object: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", "Document closed: '" & $sFullPath &"'")
EndIf


Exit

 

Link to post
Share on other sites

Because the pages are 0-based, you'll need to subtract 1 from the number of pages in your For loop (For $i = $iPages -1 To 2 Step -1)

What do you mean by "_Acro_DocSave isn't saving file as "-saved.pdf"? Is it returning an error? 

There's an error in _Acro_DocSave: it won't return True if there's not an error. I'll add that to my ToDo-list when I get back from vacation :) 

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites
  • 2 weeks later...

@ahha I got back from vacation and completely forgot about this, my sincere apologies. Fortunately, I think I may have solved your _Acro_DocSave issue... there's a minor note in the documentation that explains the PDSaveLinearized flag. In order to use the flag, it appears that changes to the document cannot be made. So, try saving your document like this instead:

_Acro_DocSave($oPdDoc, $sFullPath, $PDSaveFull)

This overrides my default value of $PDSaveFull + $PDSaveLinearized, which worked for me when my documents weren't saving. :) I'll add a note about the flag and the lack of an error when using the flag as well as change the default in my next release. Hopefully I can get that out next week.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites

seadoggie01,

How do I add a sub bookmark?

Like this

Page 1   <-- main top level bookmark

     Page 2   <-- 1st sub bookmark

          Page 3   <-- 2nd sub bookmark

                Page 4   <-- 3rdsub bookmark

Is it the $oParent somehow?

Here's what I've got.

Thanks

;
;v1k - trying to add bookmarks
;v1j - messing around
;v1i - updated _Acro_DocSave($oPdDoc, $sFullPath, $PDSaveFull) see https://www.autoitscript.com/forum/topic/202026-acroau3-udf/?tab=comments#comment-1449581
;Acro.au3 test program
#AutoIt3Wrapper_run_debug_mode=Y    ; use this to debug in console window <--- LOOK

#include <Acro.au3>

MsgBox(0, "Test", "Testing Acro UDF")

;open it
$sFullPath = "C:\Program Files (x86)\AutoIt3\AH Code\PDF Processing\Acro UDF\Bookmark test document pp 1-4.pdf"
$oPdDoc = _Acro_DocOpen($sFullPath)
If $oPdDoc = False Then
    If @error = 1 Then MsgBox(0, "Error", "Could not find file: '" & $sFullPath &"'")
    If @error = 2 Then MsgBox(0, "Error", "Document not opened: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", "Document opened: '" & $sFullPath &"'")
EndIf


;get page count so we do all pages      ;page count is Zero based!! SO it goes from 0 to $iPage-1
$iPages = _Acro_PageCount($oPdDoc)
If $iPages = False Then
    If @error = 1 Then MsgBox(0, "Error", "$oPdDoc isn't a PDDoc object: '" & $sFullPath &"'")
    If @error = 2 Then MsgBox(0, "Error", "Can't get number of pages in: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", $iPages & " pages in document: '" & $sFullPath &"'")
EndIf

;v1k - add bookmarks
;For $i = 0 to $iPages-1    ;zero based ;Note works BUT with this 0,...,n-1 the order in the BM panel is n-1,..0 - really want it reversed so start at bottom and work to top BM
For $i = $iPages-1  to 0 step -1    ;zero based
    $sName = $i + 1     ;just bookmark with the page number
    $iPage = $i
    $iIndex = 0         ;zero based - this shifts the BM panel presentation order  ;$iIndex=0 gives 1,2,3,4     ;$iIndex=1 gives 4,1,2,3
    $oParent = Default  ;? (top level) - not sure how to declare an object parent for a bookmark (page?)
    $x = _Acro_DocBookmarkAdd($oPdDoc, $sName, $iPage, $iIndex, $oParent)
    MsgBox(0, "Debug", "$x = '" & $x &"'" & " @error = '" & @error & "'")
    If $x = False Then
        If @error = 1 Then MsgBox(0, "Error", "$oPdDoc isn't a PDDoc object: '" & $sFullPath &"'")
        If @error = 2 Then MsgBox(0, "Error", "_Acro_DocJSObject returned an error: @extended set to it's @error." & @CRLF & "@extended = '"& @extended & "'")
    Else
        MsgBox(0, "Okay", "Page: " & $i & " should be bookmarked with '" & $sName &"'") ;skipped because $x='' and @error ='0'
    EndIf
Next


;save the document
$sFullPath = StringTrimRight($sFullPath, 4) & "-saved.pdf"  ;name it "-saved.pdf"
MsgBox(0, "Debug", "$sFullPath = '" & $sFullPath &"'")
$x = _Acro_DocSave($oPdDoc, $sFullPath, $PDSaveFull)    ;v1i using $PDSaveFull
MsgBox(0, "Debug", "$x = '" & $x &"'")
If $x = False Then
    If @error = 1 Then MsgBox(0, "Error", "$oPdDoc isn't a PDDoc object: '" & $sFullPath &"'")
    If @error = 2 Then MsgBox(0, "Error", "Document not saved: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", "Document saved: '" & $sFullPath &"'")
EndIf


;be polite and close document
;close document
$x = _Acro_DocClose($oPdDoc)
If $x = False Then
    If @error = 1 Then MsgBox(0, "Error", "$oDoc isn't an AV/PD Doc object: '" & $sFullPath &"'")
Else
    MsgBox(0, "Okay", "Document closed: '" & $sFullPath &"'")
EndIf


Exit

 

Bookmark test document pp 1-4.pdf

Link to post
Share on other sites

I haven't actually implemented that yet :D I was hoping that the result of _Acro_DocBookmarkAdd would return the bookmark object, but it appears to return nothing or something else undocumented that relates to JavaScript. If you check out the methods inside of that function, you'll see that I'm accessing the JavaScript object of the document to get access to bookmarks. I haven't had much time to play around with them yet, so currently there isn't a built-in way to manipulate them. 

You can get access to the JavaScript object through _Acro_DocJSObject and manipulate it through something like this (untested code):

Local $oPdDoc = _Acro_DocOpen("file")
Local $oJS    = _Acro_DocJSObject($oPdDoc)  ; $oJS is now equal to "this" in the JavaScript reference

; Get the root level bookmark, an imaginary bookmark that doesn't display, but holds all other top level bookmarks
Local $oRootBkmk = $oJS.bookmarkRoot

; Get a 1-d array of child bookmark objects
Local $aoChildBkmk = $oRootBkmk.children

For $i=0 To Ubound($aoChildBkmk) - 1
    
    ; Print the name
    ConsoleWrite($aoChildBkmk[$i].name)
    
    ; Add a child bookmark to it (Name, Javascript to execute when clicked, index of parent)
    $aoChildBkmk[$i].createChild($aoChildBkmk[$i].name & "'s - Child", "this.pageNum++", 0)
Next

I haven't added much code related to bookmarks yet, but I'm happy to add some when I get some time, let me know if you're interested :) I've been thinking about doing this lately anyways.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Hermes
      Hi, I am struggling in setting the value of a textarea based on the value of clipboard (that contains a long web page source codes). If I use _WD_SetElementValue, it freezes after some time, or appears to be pressing tab and goes out of focus. I can also use send keys but i need the script to run in the background.
      Here is the full script:
      #Include "Chrome.au3" #Include "wd_core.au3" #Include "wd_helper.au3" #Include "WinHttp.au3" #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <GDIPlus.au3> #include <Excel.au3> Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "http://demo.borland.com/testsite/stadyn_largepagewithimages.html") _WD_LoadWait($sSession) Global $sSource = _WD_GetSource($sSession) Local $Paste = ClipPut($sSource) Local $sData = ClipGet() Local $aArray = 0, _ $iOffset = 1 While 1 $aArray = StringRegExp($sData, '(?s)<p>.*</p>', $STR_REGEXPARRAYMATCH, $iOffset) If @error Then ExitLoop $iOffset = @extended For $i = 0 To UBound($aArray) - 1 Local $Paste = ClipPut($aArray[$i]) Local $sRegExData = ClipGet() ;MsgBox(0, "", "$sRegExData = " & $sRegExData) Next WEnd _WD_Navigate($sSession, "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_textarea_placeholder") _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "iframe#iframeResult") Local $sElement1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "iframe#iframeResult") _WD_FrameEnter($sSession, $sElement1) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/textarea") $textarea = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/textarea") _WD_ElementAction($sSession, $textarea, 'click') ;WD SetElementValue(SsSession, Stextarea, $sRegExData) <-- I can do this but the focus goes out, or the browser freezes _WD_FrameLeave($sSession) sleep(2000) Send("^v") _WD_LoadWait($sSession) _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome Can someone help me please, or re-direct me to the right path? TIA!
    • By Hermes
      Hi, I am trying to select elements in print page (dialog window) for a specific web page. But when trying to do so, it looks like it does not allow me to do it.
      So far, this is what I have:
      _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") Local $mainpagebody = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") _WD_HighlightElement($sSession, $mainpagebody, 2) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "img.print-button") Local $printbutton = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "img.print-button") _WD_ElementAction($sSession, $printbutton, 'click') _WD_LoadWait($sSession) Sleep(3000) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") Local $printpagebody = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") _WD_HighlightElement($sSession, $printpagebody, 2) The script above highlights the main web page "body" element, then clicks a tag to print a specific part of the page, then it will open a print page window where i am trying to highlight the body of that print page - but it looks like it is dropping from the session because it opens up another chrome page chrome://print.
       
      Below is the output log:
      __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"img.print-link"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"img.print-link"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element/eb9e4673-4dec-4d4c-be6a-b7967743394b/click; $sData={"id":"eb9e4673-4dec-4d4c-be6a-b7967743394b"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_ElementAction: {"value":null}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"return document.readyState", "args":[]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)... __WD_Post ==> Webdriver Exception: {"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C63733+2504499]\n\tOrdinal0 [0x00BFC401+2081793]\n\tOrdinal0 [0x00B024F0+1058032]\n\tOrdinal0 [0x00B55685+1398405]\n\tOrdinal0 [0x00B45E83+1334915]\n\tOrdinal0 [0x00B54CDB+1395931]\n\tOrdinal0 [0x00B45D4B+1334603]\n\tOrdinal0 [0x00B222B4+1188532]\n\tOrdinal0 [0x00B23149+1192265]\n\tGetHandleVerifier [0x00DDFB8C+1512252]\n\tGetHandleVerifier [0x00E8B0DF+2214031]\n\tGetHandleVerifier [0x00CE4BC3+484211]\n\tGetHandleVerifier [0x00CE3E69+480793]\n\tOrdinal0 [0x00C0218D+2105741]\n\tOrdinal0 [0x00C066E8+2123496]\n\tOrdinal0 [0x00C06827+2123815]\n\tOrdinal0 [0x00C0FB73+2161523]\n\tBaseThreadInitThunk [0x75EB62C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77C11B69+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77C11B34+1028]\n"}} _WD_ExecuteScript: {"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)... _WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500 _WD_LoadWait ==> Webdriver Exception __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}...  
      Is it even possible to select elements in print page?

    • By walec
      Hello
      How can I export a sheet to pdf using the OOoCalc.au3 UDF?
      Thank you for any hints or possibly other solutions / functions.
    • By p4sCh
      Hello everyone,
      I've created a UDF for basic communication with SSH servers. I know there is already such a UDF, but I wasn't satisfied with it for my purpose, so I created a new one.
      This UDF also acts as a wrapper for the plink executable. Its essential functions are _SSHConnect, _SSHSend, _SSHRecv and _SSHCloseSocket.
      It does support multiple simultaneous connections and aims to be pretty robust. Feel free to share your opinions
      Two of the included examples use a slightly modified version of Vintage Terminal by @Chimp
      Download
      The download includes ssh.au3 (UDF), plink.exe (necessary), vintage terminal and code examples:
      Version 1.0.1
      - fixed rare _SSHConnect bug where "ssh-host-key prompt" was not answered
      SSH UDF 1.0.1.zip
       
    • By water
      I have started to rewrite the PowerPoint UDF similar to the Word, Excel and Outlook UDF. The new UDF will not be compatible with the existing one.
      I will add examples, documentation, a section in the wiki etc.
      So far the following functions have been coded - more are on the ToDo list.
      _PPT_Open: Open a connection to a running instance of PowerPoint or start a new one _PPT_Close: Close a PowerPoint instance _PPT_CommentAdd: Add a Comment anywhere on a Slide or connected to a Shape (version 1.5.0.0 2021-08-31) _PPT_CommentDelete: Delete a single Comment from a Slide or all Comments from a SlideRange (version 1.5.0.0 2021-08-31) _PPT_CommentList: Get a list of all Comments in a Presentation (version 1.5.0.0 2021-08-31) _PPT_ConvertUnits: Convert units (like centimeters) to other units (like points) (version 1.3.0.0 2021-08-17) _PPT_HeaderFooterList: Returns a list of Headers and Footers for a Presentation (version 1.1.0.0 2021-07-25, removed with version 1.4.0.0 2021-08-25) _PPT_HeaderFooterSet: Sets the Header/Footer for a Slide/Slides or the Slide-/Notes-/Handout-/Title-Master of the Presentation (version 1.2.0.0 2021-08-09) _PPT_PresentationAttach: Attach to an already opened Presentation _PPT_PresentationClose: Close a Presentation _PPT_PresentationExport: Export one/multiple/all Slides as PDF or XPS. _PPT_PresentationExportGraphic: Export one/multiple/all Slides in a graphic format. _PPT_PresentationList: Returns a list of currently open Presentations (version 1.0.0.0 2021-07-20) _PPT_PresentationNew: Create a new Presentation _PPT_PresentationOpen: Open an existing Presentation _PPT_Print: Print one/multiple/all Slides of a Presentation (version 1.0.0.0 2021-07-20) _PPT_PresentationSave: Save a Presentation _PPT_PresentationSaveAs: Save a Presentation to another location or with another type _PPT_ShapeAdd: Add a Shape to a single or multiple Slides (version 1.1.0.0 2021-07-25) _PPT_ShapeAlignDistribute: Aligns and distributes the Shapes in the specified ShapeRange (version 1.6.0.0 - to be released) _PPT_ShapeCopyMove: Copy/move a Shape(s) of a single Slide to a Slide(s) in the same or a different Presentation (version 1.1.0.0 2021-07-25) _PPT_ShapeDelete: Delete a Shape or Shapes from a single or multiple Slides (version 1.1.0.0 2021-07-25) _PPT_SlideAdd: Add slide(s) to a Presentation _PPT_SlideCopyMove: Copy, move, duplicate Slide(s) _PPT_SlideDelete: Delete Slide(s) _PPT_SlideShow: Show a Presentation _PPT_TableGet: Extract data from a PowerPoint Table Shape to an array (version 1.3.0.0 2021-08-17) _PPT_TableSet: Write data to a PowerPoint Table Shape (version 1.3.0.0 2021-08-17) _PPT_TextFindReplace: Find & replace text throughout entire PowerPoint presentation (version 1.0.0.0 2021-07-20) _PPT_TextSet: Sets/modifies the Text of a Shape or Shapes of a single or multiple Slides (version 1.2.0.0 2021-08-09 Which functions do you want me to add to the UDF?
      ToDo list:
      create slide (JLogan3o13) - Done: _PPT_SlideAdd Apply template to slide (JLogan3o13) - Done: _PPT_SlideAdd Apply theme to slide (JLogan3o13) Cut/Copy/Duplicate/Move/Delete slide(s) (JLogan3o13) - Done: _PPT_SlideCopyMove, _PPT_SlideDelete Export slides (JLogan3o13) - Done: _PPT_PresentationExport Cut/Copy/Duplicate/Move/Delete shape(s) (JLogan3o13): Done : _PPT_ShapeCopyMove, _PPT_ShapeDelete (version 1.1.0.0 2021-07-25) ApplyAnimation, Select, SetDefaultProperties, and zOrder for shape(s) (JLogan3o13) Searching and replacing text (pcjunki) - Done: _PPT_TextFindReplace (version 1.0.0.0 2021-07-20) Export slides in a graphic format (JPG, GIF, PNG ...) (UEZ) - Done: _PPT_PresentationExportGraphic The UDF can be downloaded from the download forum.
       
×
×
  • Create New...