Jump to content
Sign in to follow this  

PPT viewer

Recommended Posts


Hello all,

I was very happy to found the ppt wrapper:

But unfortunately it is not working for PPT VIEWER 2010 (free from Microsoft)


So I wrote this script to be able to run the ppt on a second screen automatically

(It works with the normal PPT 2010 as well !):


I got the _GetMonitors() on this forum as well (not shure where...)


Global $__MonitorList[1][5], $MonL[5], $MonT[5]

#region Detect Monitor
$Monitor = _GetMonitors()
If $Monitor[0][0] = 2 Then
If ($Monitor[1][1] = 0) And ($Monitor[1][2] = 0) Then; According to Microsoft, the Main Monitor has the coordinates 0,0, ..., ...
  $MonL[2] = $Monitor[2][1] ; Monitor 1 Main - Monitor 2 Display
  $MonT[2] = $Monitor[2][2]
  $MonL[1] = $Monitor[1][1]
  $MonT[1] = $Monitor[1][2]
  $Mon = 1
  $MonL[2] = $Monitor[1][1] ; Monitor 2 Main - Monitor 1 Display
  $MonT[2] = $Monitor[1][2]
  $MonL[1] = $Monitor[2][1]
  $MonT[1] = $Monitor[2][2]
  $Mon = 2
$Mon = 1 ; Only 1 Monitor
#endregion Detect Monitor

ShellExecute(@WorkingDir&'\sitemp3.ppt',"",Default,Default,  @SW_MINIMIZE )

WinWaitActive("[CLASS:PPTFrameClass]" )
ControlSend("[CLASS:PPTFrameClass]", "", "[CLASSNN:paneClassDC1]", "{F5}")
WinSetTrans ( "[CLASS:screenClass]", "", 0 )
WinWaitActive("[CLASS:screenClass]" ) ;full screen mode
WinSetTrans ( "[CLASS:screenClass]", "", 0 )
WinMove("[CLASS:screenClass]" , "" , $MonL[2] , $MonT[2] , Default, Default, 1)
WinSetTrans ( "[CLASS:screenClass]", "", 255 )
While WinExists ("[CLASS:screenClass]" )
Sleep ("100")
WinClose ("[CLASS:PPTFrameClass]" )
; Function Name:   _GetMonitors()
; Description:: Load monitor positions
; Parameter(s): n/a
; Return Value(s): 2D Array of Monitors
;                      [0][0] = Number of Monitors
;                      [i][0] = HMONITOR handle of this monitor.
;                      [i][1] = Left Position of Monitor
;                      [i][2] = Top Position of Monitor
;                      [i][3] = Right Position of Monitor
;                      [i][4] = Bottom Position of Monitor
; Note:         [0][1..4] are set to Left,Top,Right,Bottom of entire screen
;                 hMonitor is returned in [i][0], but no longer used by these routines.
;                 Also sets $__MonitorList global variable (for other subs to use)
; Author(s):       xrxca (autoit@forums.xrx.ca)
Func _GetMonitors()
$__MonitorList[0][0] = 0 ;  Added so that the global array is reset if this is called multiple times
Local $handle = DllCallbackRegister("_MonitorEnumProc", "int", "hwnd;hwnd;ptr;lparam")
DllCall("user32.dll", "int", "EnumDisplayMonitors", "hwnd", 0, "ptr", 0, "ptr", DllCallbackGetPtr($handle), "lparam", 0)
Local $i = 0
For $i = 1 To $__MonitorList[0][0]
  If $__MonitorList[$i][1] < $__MonitorList[0][1] Then $__MonitorList[0][1] = $__MonitorList[$i][1]
  If $__MonitorList[$i][2] < $__MonitorList[0][2] Then $__MonitorList[0][2] = $__MonitorList[$i][2]
  If $__MonitorList[$i][3] > $__MonitorList[0][3] Then $__MonitorList[0][3] = $__MonitorList[$i][3]
  If $__MonitorList[$i][4] > $__MonitorList[0][4] Then $__MonitorList[0][4] = $__MonitorList[$i][4]
Return $__MonitorList
EndFunc   ;==>_GetMonitors
; Function Name:   _MonitorEnumProc($hMonitor, $hDC, $lRect, $lParam)
; Description:: Enum Callback Function for EnumDisplayMonitors in _GetMonitors
; Author(s):       xrxca (autoit@forums.xrx.ca)
Func _MonitorEnumProc($hMonitor, $hDC, $lRect, $lParam)
Local $Rect = DllStructCreate("int left;int top;int right;int bottom", $lRect)
$__MonitorList[0][0] += 1
ReDim $__MonitorList[$__MonitorList[0][0] + 1][5]
$__MonitorList[$__MonitorList[0][0]][0] = $hMonitor
$__MonitorList[$__MonitorList[0][0]][1] = DllStructGetData($Rect, "left")
$__MonitorList[$__MonitorList[0][0]][2] = DllStructGetData($Rect, "top")
$__MonitorList[$__MonitorList[0][0]][3] = DllStructGetData($Rect, "right")
$__MonitorList[$__MonitorList[0][0]][4] = DllStructGetData($Rect, "bottom")
Return 1 ; Return 1 to continue enumeration
EndFunc   ;==>_MonitorEnumProc

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  

  • Similar Content

    • zetaimmersion
      By zetaimmersion
      Hi all. 
      I am trying to do 2 things but i cannot seem to get any traction on how to read/implement this idea.
      Premise: PowerPoint file in C\temp\presentation.pptx that contains on the first slide 2 entries as "<one>" and "<two>" which need to be replaced with "user1" and "user2", then a silent Outlook send mail containing the file with a predefined body and subject.
      I narrowed it down to COM objects as the Office does not like intrusive open AutoIt functions. I installed OLE/COM Object Viewer to understand how to create the commands but i am still stuck. So far i am trying to user water's code but i suck
      COM object i was originally trying to modify
      Dim $oPPT, $oPres $oPPT = ObjCreate("PowerPoint.Application") $oPPT.Visible = True $oPres = $oPPT.Presentations.Read Water's code below (0.1% modified)
      #include <File.au3> #include "PowerPoint.au3" #include <misc.au3> Global $sFile = "C:\temp\presentation.pptx" Global $sString2Search = "<username>", $sString2Replace = "Password", $iReplaceOnce = 1, $sFullLogFile = "C:\temp\pptxlog.txt" _ProcessPpt($sFile) Func _ProcessPpt($sFile) $oApp = _PPT_PowerPointApp() Local $bChange = False Local $oInterface = $oApp.Presentations Local $oPresentation = $oInterface.Open($sFile, False, False, False) If @error Then _FileWriteLog($sFullLogFile, "E Error " & @error & " opening File " & $sFile) Return SetError(1, 0, 0) EndIf ;it does not even open my file and from here not sure how to read the text and replace it EndFunc ;==>_ProcessPpt  
    • water
      By water
      Fourth Alpha version of the PowerPoint UDF.
      Something for you to play with.
      Lot of things still missing: Lot of functions, help file etc.
      If you want to discuss the functions please post here.
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    • water
      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_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_PresentationNew: Create a new presentation _PPT_PresentationOpen: Open an existing presentation _PPT_PresentationSave: Save a presentation _PPT_PresentationSaveAs: Save a presentation to another location or with another type _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 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) ApplyAnimation, Select, SetDefaultProperties, and zOrder for shape(s) (JLogan3o13) Searching and replacing text (pcjunki) Export slides in a graphic format (JPG, GIF, PNG ...) (UEZ) - Done: _PPT_PresentationExportGraphic Added the Alpha version to the download forum.
    • DHL
      By DHL
      Hi, I'm getting this error while trying to initialize a com event handler for Office PowerPoint events. The PowerPoint file is displayed correctly, but no events are captured as the ObjEvent() fails :

      err.number is: -2147316576 err.windescription: Type mismatch. err.description is: err.source is: err.helpfile is: err.helpcontext is: 0 err.lastdllerror is: 0 err.scriptline is: 23 err.retcode is: 0

      The sourcecode is:

      Local $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler Func MyErrFunc($oError) ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc Local $AppPowerPoint = ObjCreate("PowerPoint.Application") If Not IsObj($AppPowerPoint) Then MsgBox(0, "Error", "$AppPowerPoint is not an Object.") Else MsgBox(0, "Error", "Successfully created Object $AppPowerPoint.") EndIf Local $pptEvt = ObjEvent($AppPowerPoint, "PowerPointEvent_") ; Initialize PowerPoint COM event handlers Local $OpenPresentation = $AppPowerPoint.Presentations.Open("C:\Users\DagHendrik\Desktop\test.ppt",True, False, False) $OpenPresentation.SlideShowSettings.ShowPresenterView = 0 $OpenPresentation.SlideShowSettings.ShowType = 1 Local $SlideShowWindow = $OpenPresentation.SlideShowSettings.Run() While True Sleep(10) WEnd Func PowerPointEvent_SlideShowNextSlide($obj) ConsoleWrite("GetCurrentSlide = " & ($SlideShowwindow.View.Slide.SlideIndex-1) & "<"& @LF) EndFunc Func PowerPointEvent_SlideShowOnNext($obj) ConsoleWrite("GetCurrentSlide = " & ($SlideShowwindow.View.Slide.SlideIndex-1) & "<"& @LF) EndFunc

      The script continues fine, but no event are fired as the line with
      Local $pptEvt = ObjEvent($AppPowerPoint, "PowerPointEvent_") ; Initialize PowerPoint COM event handlers fails.

      I'm using the latest autoit (v3.3.8.1, 32 bit) And I'm running Office PowerPoint 2013 32bit on a Windows 8 Pro 64 bit installation.

      Any idea why the ObjEvent() fails?

      (EDIT: changed to autoit code formatting)

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.