Webbrowser control application: Play the pptfile

Source: Internet
Author: User

The first thought was to useWebformTo useIFRAMELoad the filePPTSave filesHtmAnd then play the video. But later I found thatProgramIt is not easy to control, so useWinform.

InWinformYou can directly generateOfficeOfPPTOfAppellationObject, and you can play it as you like, and edit it dynamically. However, for small projects, it is a little troublesome. Later I chose to useWebbrowderControl.

WebbrowserControls are really fun.Htm, There are no problems with many formats. Picture,WordAh, everything can run.PPTNaturally,Flash,AviAlso (just embed it once ), In addition to asking whether to enable it during the first playback, it is not a problem to play it in the future.

WebbrowserThe reason why the control can be played is actually the component installed on the client called.

However, when we do this, we have a problem:PPTOnly to the second page, and then it cannot be automatically played cyclically. SavedPPSFile. Later, I found that it was okay to click the next page with the mouse.

There are two solutions:

1: Why does debugging stop and stop playing.

InOnnavigatingDetected in the event,Each playbackPPTThe actual address is as follows:Path/xx.ppt #3, Later3The current page number. This is similar to playingHtmUploadIDSomething similar. Based on this information, it is no problem to actively call a page. This is an unexpected discovery. Continue debugging. When loading the page for the first time, it seems everything is normal, that is, it stops playing automatically after the second one.

Based on the transfer address format, I tried to play the second page at the beginning, but the results were the same, and the third page was stopped. It seems that it is not the problem starting from the page, but that he can only play to the second page and then stop.

at this time, I want to see if I can use webbrowser the loaded component is processed. Generally, for example, to load a HTM page, webbrowser. document the object is the content of HTM , then, you can traverse the entire HTM object and perform some operations. If webbrowser loads PPT what is the document attribute? Can I use this object to perform PPT playback? He should provide the API .

So I tracked it and found that it was nothing.Null. InWebbrowserPlayback not foundPPTObject, that is, it cannot be called.APINow (inWebbrowserYou can findBaseOfDocmObject, but cannot be used ).

2: Simulate mouse clicks.

The first method cannot be solved.XA little, simulate the mouse click. After each loadPPTClick "Next page ". This button is all inWebbrowserControl.

The simulation method is simple.User32.dllAnd then assemble it.

This is simple.Code:

Public Class Virtualmouse

{

[Dllimport("User32.dll")]

Static Extern BoolSetcursorpos (IntX,IntY );

[Dllimport("User32.dll")]

Static Extern VoidMouse_event (MouseeventflagFlags,IntDX,IntDy,UintData,UintptrExtrainfo );

[Flags]

Public Enum Mouseeventflag:Uint

{

Move = 0x0001,

Leftdown = 0x0002,

Leftup-to-date = 0x0004,

Rightdown = 0x0008,

Rightup = 0x0010,

Middledown = 0x0020,

Middleup = 0x0040,

Xdown = 0x0080,

X up = 0x0100,

Wheel = 0x0800,

Virtualdesk = 0X4000,

Absolute = 0x8000

}

Public VoidSetcursorposition (IntX,IntY)

{

Virtualmouse. Setcursorpos (x, y );

}

Public VoidMouseevent (MouseeventflagFlag)

{

Mouse_event (flag, 0, 0 ,(Uint) 0 ,(Uintptr) 0 );

}

}

The remaining problems are simple. You can directly calculate the button location and click it,Done.

VirtualmouseVm =New Virtualmouse();

VM. setcursorposition (x, y );

VM. mouseevent (Virtualmouse.Mouseeventflag. Leftdown );

System. threading.Thread. Sleep (500 );

VM. mouseevent (Virtualmouse.Mouseeventflag. Leftup );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.