none
mouse cursor disappears problem

    Question

  • Hello,

    I'm working on a wpf application to control powerpoints presentations from my application running in background.

    For this purpose I send from my application the required shortcuts to trigger the events in powerpoint, using System.Windows.Forms.SendKeys.SendWait("{F5}"); for instance to start the presentation. (I am just sending shortcuts, not escpecially to powerpoint, so powerpoint needs to be my active window).

    My problem is that then when I close my presentation from my application (sending the Escape key), my mouse cursor doesn't appear anymore in the powerpoint window, like if my mouse is hidden behind the window. The cursor is visible when I put it out of the powerpoint window (if I hover the bottom windows bar for instance). This lasts as long as powerpoint is still my active window.

    However, if I close the presentation using the escape key directly, I don't have this problem.

    Does anyone have any idea of what might be causing that, and would have a solution to suggest?

    Thank you

    Wednesday, July 25, 2012 4:28 PM

Answers

  • Unfortunately I think you will have a difficult time working around these sorts of problems. You might be able to find a fix for the mouse issue in particular, but the SendKeys method is incredibly unreliable and is likely to cause a lot of sleepless nights for you in the future. The implementation is brittle, relies on the shortcuts never changing, assumes the program doesn't use any other important input signals, assumes that issues don't occur and exceptions never come up, etc.

    If you want to automate PowerPoint, the recommended solution is to use the classes in the Microsoft.Office.Interop.PowerPoint namespace. These classes expose methods to create, open, edit, and display presentations. For example, you can use the SlideShowSettings interface (from the SlideShowSettings property of the Presentation) to modify animations and run a slide show. This works around all of the problems above, and as a bonus PowerPoint doesn't have to be the focus anymore. In fact, PowerPoint doesn't even have to be visible - you can do all of this and keep it completely invisible to the user if you want to.

    Wednesday, July 25, 2012 5:08 PM

All replies

  • Unfortunately I think you will have a difficult time working around these sorts of problems. You might be able to find a fix for the mouse issue in particular, but the SendKeys method is incredibly unreliable and is likely to cause a lot of sleepless nights for you in the future. The implementation is brittle, relies on the shortcuts never changing, assumes the program doesn't use any other important input signals, assumes that issues don't occur and exceptions never come up, etc.

    If you want to automate PowerPoint, the recommended solution is to use the classes in the Microsoft.Office.Interop.PowerPoint namespace. These classes expose methods to create, open, edit, and display presentations. For example, you can use the SlideShowSettings interface (from the SlideShowSettings property of the Presentation) to modify animations and run a slide show. This works around all of the problems above, and as a bonus PowerPoint doesn't have to be the focus anymore. In fact, PowerPoint doesn't even have to be visible - you can do all of this and keep it completely invisible to the user if you want to.

    Wednesday, July 25, 2012 5:08 PM
  • Ok, I didn't know about this, I'll have a look at it.

    Thank you!!

    Thursday, July 26, 2012 1:22 PM
  • No problem, come back and ask questions if you have any trouble. I forgot to mention that you'll need to add the Microsoft PowerPoint Object Library under the COM menu of the Add Project Reference dialog before that namespace shows up.
    Thursday, July 26, 2012 1:25 PM
  • Hello,

    Thanks again, that's exactly what I needed.

    But now I have some problems I can't solve.

    The first one is that I'm using objPres.SlideShowWindow.View.Next(); in order to go to next slide (objPres is my Presentation object). This works fine when I'm in the presentation mode, but not any more if the presentation is not started, and visual studio gives me this COMException: " Presentation (unknown member) : Invalid request.  There is currently no slide show view for this presentation." Do you have any solution for that? I'd like to be able to navigate in the presentation even when it's not running in full screen.

    I'd also would like to be able to start the presentation from the current slide. For that I tried to get the current slide number using

    currentSlide = objPres.SlideShowWindow.View.CurrentShowPosition;

    and then do

    objPres.SlideShowSettings.Run();
    objPres.SlideShowWindow.View.GotoSlide(currentSlide);

    But I get the same exception.

    Thanks for your help

    Luc

    Friday, July 27, 2012 10:26 AM
  • Hello,

    Thanks again, that's exactly what I needed.

    But now I have some problems I can't solve.

    The first one is that I'm using objPres.SlideShowWindow.View.Next(); in order to go to next slide (objPres is my Presentation object). This works fine when I'm in the presentation mode, but not any more if the presentation is not started, and visual studio gives me this COMException: " Presentation (unknown member) : Invalid request.  There is currently no slide show view for this presentation." Do you have any solution for that? I'd like to be able to navigate in the presentation even when it's not running in full screen.

    I'd also would like to be able to start the presentation from the current slide. For that I tried to get the current slide number using

    currentSlide = objPres.SlideShowWindow.View.CurrentShowPosition;

    and then do

    objPres.SlideShowSettings.Run();
    objPres.SlideShowWindow.View.GotoSlide(currentSlide);

    But I get the same exception.

    Thanks for your help

    Luc

    Friday, July 27, 2012 10:27 AM
  • Hi Luc ,

    Welcome to MSDN Forum .

    Since this is a post disconnected from the original thread. Please start a new thread if you have a new question , so others can help you out. In addition , for WPF related questions , please refer to :

    http://social.msdn.microsoft.com/forums/en/wpf/threads/

    I will mark Tim's reply as answer .

    Thanks for your understanding and support .

    Regards,


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, August 06, 2012 1:49 AM