Implement workaround for unblanking bug in powerpoint 2010

This commit is contained in:
Tomas Groth 2015-04-30 14:38:55 +02:00
parent 54fbaf3a4f
commit 1333c2ff43
2 changed files with 22 additions and 5 deletions

View File

@ -244,7 +244,8 @@ class Controller(object):
"""
log.debug('Live = %s, stop' % self.is_live)
# Save the current slide number to be able to return to this slide if the presentation is activated again.
self.doc.slidenumber = self.doc.get_slide_number()
if self.doc.is_active():
self.doc.slidenumber = self.doc.get_slide_number()
self.hide_mode = HideMode.Screen
if not self.doc:
return

View File

@ -37,6 +37,8 @@ if is_win():
import winreg
import win32ui
import pywintypes
import win32con
import win32api
from openlp.core.lib import ScreenList
from openlp.core.lib.ui import UiStrings, critical_error_message_box, translate
@ -225,10 +227,24 @@ class PowerpointDocument(PresentationDocument):
"""
log.debug('unblank_screen')
try:
self.presentation.SlideShowSettings.Run()
# ppSlideShowRunning = 1
self.presentation.SlideShowWindow.View.State = 1
self.presentation.SlideShowWindow.Activate()
# Powerpoint 2010 (14.0) has a bug that prevents unblanking from working,
# so we have to works around it by sending a keystroke to Powerpoint.
# The keystroke 'U' should not have any bindings in Powerpoint so we use that
if float(self.presentation.Application.Version) == 14.0:
loops = 0
while self.presentation.SlideShowWindow.View.State == 3:
if loops >= 10:
log.warning('Tried to unblank 10 times, break to avoid hang, leaving presentation blanked.')
break
log.debug('Unblanking by sending "U"')
self.presentation.SlideShowWindow.Activate()
win32api.keybd_event(ord('U'), 0, 0, 0)
time.sleep(0.01)
win32api.keybd_event(ord('U'), 0, win32con.KEYEVENTF_KEYUP, 0)
loops += 1
else:
# ppSlideShowRunning = 1
self.presentation.SlideShowWindow.View.State = 1
except (AttributeError, pywintypes.com_error) as e:
log.exception('Caught exception while in unblank_screen')
log.exception(e)