perl+ VBA:在 Powerpoint 幻灯片中嵌入的按钮上引发单击事件



这里有一个PowerPoint 2010演示文稿。在一张幻灯片上有一个嵌入式Windows媒体播放器OCX控件。作为一个简单的 GUI,我在同一张幻灯片上放置了 3 个标记为播放、暂停、停止的按钮。

使用Perl的Win32::OLE模块,我想测试"Play"上的单击事件是否在嵌入式窗口媒体播放器中播放文件。

用鼠标引发 Click 事件,它确实如此。

使用下面的代码,它不起作用。为什么?

note "Slide $i: " . $slide->{Name};
# switch to "full-screen presentation mode"
PowerpointHelpers::launch_slideshow_from_slide($ole->ActivePresentation, $i);
sleep 3;
#does not work
$btnplay->{OLEFormat}->Object()->btnPlay_Click();
sleep 3;
# return to slide edit-mode
# PowerpointHelpers::exit_show($ole);

这是应该运行的 VBA 过程:

Public Sub btnPlay_Click()
    Init
    PlayVideo (Player.URL)
End Sub

如您所见,这只是调用两个播放 avi 文件的自定义函数。它在交互式使用中确实可以正常工作。但不是通过 VBA 自动化.

同时,我尝试了相当多的线路变体

 $btnplay->{OLEFormat}->Object()->btnPlay_Click();

但没有一个有效。

下面是$btnplay对象的转储:

OLE object's properties:
Accelerator .............................
AutoSize ................................ 0
BackColor ............................... 8421504
BackStyle ............................... 1
Caption ................................. Video abspielen
Enabled ................................. 1
Font .................................... [IFont]
ForeColor ............................... 0
Height .................................. 28.375
Left .................................... 18.75
Locked .................................. 0
MouseIcon ............................... <undef>
MousePointer ............................ 0
Name .................................... btnPlay
Picture ................................. <undef>
PicturePosition ......................... 7
TakeFocusOnClick ........................ 1
Top ..................................... 382.875
Visible ................................. 1
Width ................................... 124.75
WordWrap ................................ 0
ZOrderPosition .......................... 9

行得通!

my $s = $ole->ActivePresentation->SlideShowWindow->View->Slide;
$s->Application->Run('btnPlay_Click', '');

这不起作用,它是为了完整性。我在评论中提到了这段代码。

这是我的perl代码,我尝试直接调用btnPlay_Click事件处理程序:

my $s = $ole->SlideShowWindows(1)->View->Slide;
PowerpointHelpers::_dump_ole_obj($s, 1);
Win32::OLE->Option(Warn => 3);
$s->btnPlay_Click();  ### DOES NOT WORK (for me)
Win32::OLE->Option(Warn => 0);

错误输出为 btnPlay_Click();

Win32::OLE(0.1709) error 0x80020003: "Member not found"
    in METHOD/PROPERTYGET "" at 06-mediaplayer--button-clicks-ok.t line 127

幻灯片对象:_dump_ole_obj的输出

OLE object's properties:
Application ............................. [_Application]
Background .............................. [ShapeRange]
BackgroundStyle ......................... 0
ColorScheme ............................. [ColorScheme]
Comments ................................ [Comments]
CustomLayout ............................ [CustomLayout]
CustomerData ............................ [CustomerData]
Design .................................. [Design]
DisplayMasterShapes ..................... -1
FollowMasterBackground .................. 0
HasNotesPage ............................ -1
HeadersFooters .......................... [HeadersFooters]
Hyperlinks .............................. [Hyperlinks]
Layout .................................. 1
Master .................................. [_Master]
Name .................................... Slide7
NotesPage ............................... [SlideRange]
Parent .................................. [_Presentation]
PrintSteps .............................. 1
Shapes .................................. [Shapes]
SlideID ................................. 262
SlideIndex .............................. 24
SlideNumber ............................. 24
SlideShowTransition ..................... [SlideShowTransition]
Tags .................................... [Tags]
ThemeColorScheme ........................ [ThemeColorScheme]
TimeLine ................................ [TimeLine]
sectionIndex ............................ 1
More Funcnames:
Cut()
Duplicate()
Export()
GetTypeInfo()
Invoke()
MoveToSectionStart()
QueryInterface()
Release()
SectionNumber()

相关内容

  • 没有找到相关文章

最新更新