Sign in to follow this  
Followers 0
mLipok

Acrobat Reader - ActiveX Viewer

5 posts in this topic

Today, in the end as well, worked out using the Acrobat Reader ActiveX COM Object "AcroPDF.PDF.1"

#include-once
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <MenuConstants.au3>
#include <WinAPI.au3>

;~ Thanks to BrewManNH
;~ http://www.autoitscript.com/forum/topic/134878-guiregistermsg-replacement-for-guictrlsetonevent-and-guigetmsg/
;~ Thanks to mikell
;~ http://www.autoitscript.com/forum/topic/161985-how-to-close-gui-with-guiregistermsg/


; Install a custom error handler
Global $oMyError = ObjEvent("AutoIt.Error", "_ComErrFunc")

Global $__hExampleGUI
Global $__idOPEN
Global $_fExit

Global $__hACROBAT_GUI = ''
Global $__idACROBAT_GUI_CTRL_AX = ''
Global $__oACROBAT_READER = ''

#include <GUIConstantsEx.au3>

;~ GUIRegisterMsg($WM_ERASEBKGND, "_WM_EXTRACTOR")
;~ GUIRegisterMsg($WM_PAINT, "_WM_EXTRACTOR")
;~ GUIRegisterMsg($WM_ACTIVATE, "_WM_EXTRACTOR")
;~ GUIRegisterMsg($WM_CAPTURECHANGED, "_WM_EXTRACTOR")
;~ GUIRegisterMsg($WM_DEVICECHANGE, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_EXITSIZEMOVE, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_COMMAND, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_HSCROLL, "_WM_EXTRACTOR")

_ExampleProgram_Gui()

While 1
    Sleep(10)
    If $_fExit Then
        _ACROBAT_GUI_DELETE()
        DeleteGui()
        Exit
    EndIf
WEnd


Func DeleteGui()
    GUIDelete($__hExampleGUI)
EndFunc   ;==>DeleteGui

Func _ExampleProgram_Gui()
    ; Create a GUI with various controls.
    $__hExampleGUI = GUICreate("Example")
    $__idOPEN = GUICtrlCreateButton("&Open", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $__hExampleGUI)
EndFunc   ;==>_ExampleProgram_Gui



#Region ACROBAT FUNCTION
Func _AcrobatInit()
    $__oACROBAT_READER = ObjCreate("AcroPDF.PDF.1");
    Return $__oACROBAT_READER.GetVersions
EndFunc   ;==>_AcrobatInit

Func _Acrobat_Events(ByRef $aMSG)
    If $aMSG[1] = $__hACROBAT_GUI Then
        Switch $aMSG[0]
            Case $GUI_EVENT_CLOSE
                _ACROBAT_GUI_DELETE()
        EndSwitch
    EndIf
EndFunc   ;==>_Acrobat_Events

Func _ACROBAT_Destroy()
    $__oACROBAT_READER = ""
;~  MsgBox(1,'test','destroyed')
EndFunc   ;==>_ACROBAT_Destroy

Func _AcrobatShow($sFile, $sTitle = "PDF ", $iLeft = 50, $iTop = 0, $iWidth = 1000, $iHeight = 700)
    If FileExists($sFile) Then
        _AcrobatInit()

        ; Set option
        $__oACROBAT_READER.src = $sFile
        $__oACROBAT_READER.SetLayoutMode(4)
        $__oACROBAT_READER.SetPageMode(1)
        $__oACROBAT_READER.SetShowToolbar(0)
        $__oACROBAT_READER.SetView(1)

        ; Create GUI
        $__hACROBAT_GUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))
        $__idACROBAT_GUI_CTRL_AX = GUICtrlCreateObj($__oACROBAT_READER, 5, 5, $iWidth - 20, $iHeight - 10)
        GUICtrlSetStyle($__idACROBAT_GUI_CTRL_AX, $WS_VISIBLE)

        GUISetState()
    EndIf
EndFunc   ;==>_AcrobatShow


Func _ACROBAT_Refresh()
    If IsObj($__oACROBAT_READER) Then
        Local $hPreviouslyGui = GUISwitch($__hACROBAT_GUI)
        GUISetState(@SW_LOCK)
        Local $iGUI_PDFWidth = WinGetPos($__hACROBAT_GUI)[2] - 20
        Local $iGUI_PDFHeight = WinGetPos($__hACROBAT_GUI)[3] - 40
        Local $sFile = $__oACROBAT_READER.src

        ; this below line do not works with Acro Reader
        ; Local $iCurrentPage = $__oACROBAT_READER.GetNumber
        Local $iCurrentPage = 0
        _ACROBAT_Destroy()
        GUICtrlDelete($__idACROBAT_GUI_CTRL_AX)
        _AcrobatInit()
        $__idACROBAT_GUI_CTRL_AX = GUICtrlCreateObj($__oACROBAT_READER, 5, 5, $iGUI_PDFWidth, $iGUI_PDFHeight)
        $__oACROBAT_READER.src = $sFile
;~      $__oACROBAT_READER.SetCurrentPage($iCurrentPage)
        GUISetState(@SW_UNLOCK)
        GUISwitch($hPreviouslyGui)
    EndIf
EndFunc   ;==>_ACROBAT_Refresh

Func _ACROBAT_GUI_DELETE()
    _ACROBAT_Destroy()
    if IsHWnd($__hACROBAT_GUI) then GUIDelete($__hACROBAT_GUI)
EndFunc   ;==>_ACROBAT_GUI_DELETE

#EndRegion ACROBAT FUNCTION

#Region MSG and ERROR  HANDLER
Func _WM_EXTRACTOR($hWnd, $iMsg, $wParam, $lParam)
;~  ConsoleWrite('! $hWnd = ' & $hWnd & '    $iMsg = ' & $iMsg & '('&HEX($iMsg)&')'& '    $wParam = ' & $wParam & '    $lParam = ' & $lParam & @CRLF)
    If $hWnd = ControlGetHandle($__hACROBAT_GUI, '', $__idACROBAT_GUI_CTRL_AX) Then
        ConsoleWrite('! --------------  $hWnd = ' & $hWnd & '    $iMsg = ' & $iMsg & '(' & Hex($iMsg) & ')' & '    $wParam = ' & $wParam & '    $lParam = ' & $lParam & @CRLF)
    EndIf
    If $hWnd = $__hACROBAT_GUI Then
        Switch $iMsg
            Case $WM_COMMAND
                #cs
                    Case $WM_ACTIVATE
                    Local $test = BitAND($wParam, 0x00000004)
                    if $test <> 0 then
                    MsgBox(1,'$WM_ACTIVATE','test')
                    _ACROBAT_Refresh()
                    EndIf
                    Case $WM_ERASEBKGND
                    WinGetHandle("[ACTIVE]")
                    if $__hACROBAT_GUI <> _WinAPI_GetWindow ( $__hACROBAT_GUI, $GW_HWNDPREV ) then
                    ConsoleWrite('!  Case $WM_ERASEBKGND' & @CRLF)
                    _ACROBAT_Refresh()
                    _WinAPI_RedrawWindow($__hACROBAT_GUI,0,0,$RDW_NOERASE)
                    EndIf
                    Case $WM_PAINT
                    _WinAPI_RedrawWindow($__hACROBAT_GUI,0,0,$RDW_NOERASE)
                    Case $WM_CAPTURECHANGED
                    _ACROBAT_Refresh()
                    Case $WM_DEVICECHANGE
                    _ACROBAT_Refresh()
                #CE
            Case $WM_EXITSIZEMOVE
                _ACROBAT_Refresh()
            Case $WM_SYSCOMMAND
;~              Local $test = BitAND($wParam, 0xFFF0)
                Local $test = BitAND($wParam, 0x0000FFFF)
                Switch $test
                    Case $SC_CLOSE
                        _ACROBAT_GUI_DELETE()
                    Case $SC_CONTEXTHELP
                    Case $SC_DEFAULT
                    Case $SC_HOTKEY
                    Case $SC_HSCROLL
                    Case $SC_KEYMENU
                    Case $SC_MAXIMIZE
                        _ACROBAT_Refresh()
                    Case $SC_MINIMIZE
                    Case $SC_MONITORPOWER
                    Case $SC_MOUSEMENU
                    Case $SC_MOVE
;~                      _ACROBAT_Refresh()
                    Case $SC_NEXTWINDOW
;~                      _ACROBAT_Refresh()
                    Case $SC_PREVWINDOW
;~                      _ACROBAT_Refresh()
                    Case $SC_RESTORE
                        _ACROBAT_Refresh()
                    Case $SC_SCREENSAVE
                    Case $SC_SIZE
                    Case $SC_TASKLIST
                    Case $SC_VSCROLL
                EndSwitch
        EndSwitch
    EndIf


    If $hWnd = $__hExampleGUI Then
        Switch $iMsg
            Case $WM_COMMAND
                Local $nID = BitAND($wParam, 0x0000FFFF)
                Local $hCtrl = $lParam
                Switch $nID
                    Case $__idOPEN
                        if not IsObj($__oACROBAT_READER) then
                            _AcrobatShow(FileOpenDialog("Choose PDF", "C:\Temp", "PDF Files(*.pdf)", 3)) ; put your own start folder here)
                        EndIf
                EndSwitch

            Case $WM_SYSCOMMAND
                Local $test = BitAND($wParam, 0xFFF0)
                Switch $test
                    Case $SC_CLOSE
                        $_fExit = True
                    Case $SC_CONTEXTHELP
                    Case $SC_DEFAULT
                    Case $SC_HOTKEY
                    Case $SC_HSCROLL
                    Case $SC_KEYMENU
                    Case $SC_MAXIMIZE
                    Case $SC_MINIMIZE
                    Case $SC_MONITORPOWER
                    Case $SC_MOUSEMENU
                    Case $SC_MOVE
                    Case $SC_NEXTWINDOW
                    Case $SC_PREVWINDOW
                    Case $SC_RESTORE
                    Case $SC_SCREENSAVE
                    Case $SC_SIZE
                    Case $SC_TASKLIST
                    Case $SC_VSCROLL
                EndSwitch
        EndSwitch
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_EXTRACTOR

Func _ComErrFunc()
    Local $HexNumber = Hex($oMyError.number, 8)
    MsgBox(0, "AutoItCOM Test", _
            "We intercepted a COM Error !" & @CRLF & @CRLF & _
            "err.description is: " & @TAB & $oMyError.description & @CRLF & _
            "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
            "err.number is: " & @TAB & $HexNumber & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
            "err.source is: " & @TAB & $oMyError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
    SetError(1)
EndFunc   ;==>_ComErrFunc

#EndRegion MSG and ERROR  HANDLER

Any comments are welcome.

Cheers

mLipok

1 person likes this

February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Below I would like to introduce a new version of "AcrobatReaderViewer.au3," which uses my new UDF file:

"GUIRegisterMsg_API.au3"

 

mLipok

 

EDIT: added link

EDIT: I forgot about example:

#include "AcrobatReaderViewer.au3"
#include "GUIRegisterMsg_API.au3"

Global $oMyError = ObjEvent("AutoIt.Error", "_ComErrFunc")

Global $_hExampleGUI
Global $_idOPEN
Global $_bExit

Main()

Func Main()
    _GUIRegisterMsg_API_Start()
    ; here you add support for _MY_CURRENT_GUI_WM_EXTRACTOR
    _GUIRegisterMsg_API_AddFunc(_MY_CURRENT_GUI_WM_EXTRACTOR)
    ; here you add support for _ACROBAT_WM_EXTRACTOR
    _GUIRegisterMsg_API_AddFunc(_ACROBAT_WM_EXTRACTOR)

    ; here you can chceck what happen when you remove Remove Function from $__aGUIRegisterMsg_API[] by using _GUIRegisterMsg_API_RemoveFunc
    ; _GUIRegisterMsg_API_RemoveFunc(_ACROBAT_WM_EXTRACTOR)

    _ExampleProgram_Gui()

    While 1
        Sleep(10)
        If $_bExit Then
            _ACROBAT_GUI_DELETE()
            DeleteGui()
            Exit
        EndIf
    WEnd

EndFunc   ;==>Main
Exit

#Region EXAMPLE GUI
Func DeleteGui()
    GUIDelete($_hExampleGUI)
EndFunc   ;==>DeleteGui

Func _ExampleProgram_Gui()
    ; Create a GUI with various controls.
    $_hExampleGUI = GUICreate("Example")
    $_idOPEN = GUICtrlCreateButton("&Open", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $_hExampleGUI)
EndFunc   ;==>_ExampleProgram_Gui
#EndRegion EXAMPLE GUI

#Region _MY_CURRENT_GUI_WM_EXTRACTOR
Func _MY_CURRENT_GUI_WM_EXTRACTOR($hWnd, $iMsg, $wParam, $lParam)
    If $hWnd = $_hExampleGUI Then
        Switch $iMsg
            Case $WM_COMMAND
                Local $nID = BitAND($wParam, 0x0000FFFF)
                Local $hCtrl = $lParam
                Switch $nID
                    Case $_idOPEN
                        If Not IsObj($__oACROBAT_READER) Then
                            _AcrobatShow(FileOpenDialog("Choose PDF", "C:\Temp", "PDF Files(*.pdf)", 3)) ; put your own start folder here)
                        EndIf
                EndSwitch

            Case $WM_SYSCOMMAND
                Local $test = BitAND($wParam, 0xFFF0)
                Switch $test
                    Case $SC_CLOSE
                        $_bExit = True
                    Case $SC_CONTEXTHELP
                    Case $SC_DEFAULT
                    Case $SC_HOTKEY
                    Case $SC_HSCROLL
                    Case $SC_KEYMENU
                    Case $SC_MAXIMIZE
                    Case $SC_MINIMIZE
                    Case $SC_MONITORPOWER
                    Case $SC_MOUSEMENU
                    Case $SC_MOVE
                    Case $SC_NEXTWINDOW
                    Case $SC_PREVWINDOW
                    Case $SC_RESTORE
                    Case $SC_SCREENSAVE
                    Case $SC_SIZE
                    Case $SC_TASKLIST
                    Case $SC_VSCROLL
                EndSwitch
        EndSwitch
    EndIf


EndFunc   ;==>_MY_CURRENT_GUI_WM_EXTRACTOR

#EndRegion _MY_CURRENT_GUI_WM_EXTRACTOR

btw.

_EXAMPLE_RegisterMsg() is not used so I removed them.

AcrobatReaderViewer.au3.Download.html

Edited by mLipok

February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

No.

This is just a viewer based on Acrobat Reader ActiveX control.

But you  can try to use my Debenu Quick PDF UDF


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

I tried that before, but I couldn't do much with the eval version, thanks though


What is what? What is what.

Share this post


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
Sign in to follow this  
Followers 0

  • Similar Content

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning guys
      I'd like to know if there is a way to convert a PDF in CSV or, eventually, in TXT, in order to read from it, like a database...
      I have a PDF and I think ( I dind't search a lot on the forum ) with AutoIt, but I'd like work with Excel styles...
      Does anyone know a good program which convert PDF to CSV? 
      PS: the PDF file is 5 MB, and it contains 439 pages...
      Thanks everyone for the help
       
    • YellowLab
      By YellowLab
      I am having a very unique, but repeatable problem with ImageMagick COM interface. Here are the applicable lines of code:
      $oIM=ObjCreate("ImageMagickObject.MagickImage.1")
      and then later on...
      $oIM.Convert(String($arFileList[$nFileIndex])&'[0]',"-alpha", "remove",@TempDir&"\temp.jpg")
      the array points to a pdf file with the "convert" command converting the first page of the pdf to a jpg with any alpha layer removed.
      Every time, without fail, the first time I run the script on a freshly booted machine it crashes on the $oIM.Convert command. It does this if it isn't compiled and says there is an error executing the command on the object. If compiled, i get an error that autoit has stopped responding. Anytime I run the script, compiled or not, after this initial crash everything works perfectly fine.
      I am totally at a loss as to why this is occurring and how to correct it.
    • Javik
      By Javik
      Is there a way to read data directly from the Windows Component Object Model (COM) interface?
      I am trying to make a really simple disk space reporter tool for accounts on an Active Directory domain, to read the disk quota limit for the logged on user's home directory, and report how much disk space they are currently using.
      ,
      MSDN:  IDiskQuotaUser interface
      https://msdn.microsoft.com/en-us/library/windows/desktop/aa365033(v=vs.85).aspx
      GetQuotaLimit
      GetQuotaUsed
       
       
    • MagicFlute
      By MagicFlute
      Hi guys
      Looking to automate...I have PDF files...Need to convert them all to 2 pages each but more specifically, retain only the first and last.
      Searched a lot and hitting the wall....Any ideas? Just directions would do...
      Not sure how to "print to file" and I believe |ShellExecuteWait($sFilePath, " /h /p", "", "print", @SW_HIDE)| doesn't give options of what pages...
    • WoodGrain
      By WoodGrain
      Hi All,
      I've coded the small script below, but it can't seem to get the instance of Windows Media player as it keeps going to @error, I've not used com objects before so any assistance would be appreciate. I already have WMP open and minimised. I retrieved "WMPlayerApp" from the AutoIT info tool, I've included a copy below.
      I'm using these sources:
      https://msdn.microsoft.com/en-us/library/dd564085.aspx
      https://msdn.microsoft.com/en-us/library/dd564018.aspx
      $oWMP = ObjGet("", "WMPlayerApp") If @error Then MsgBox(0, "Can't get WMP", "Couldn't connect to the WMP instance") Exit EndIf $wmpPlayState = $oWMP.playState MsgBox(0, "Play State", $wmpPlayState) $wmpSongName = $oWMP.currentMedia.name MsgBox(0, "Play State", $wmpSongName) I've also seen references to the below, but I want to get an existing open WMP:
      ObjCreate("wmplayer.OCX") and have looked at the WMP.udf but can't see how it will do either of the functions I've coded above.