Option Explicit
Private Type KEYBDINPUT
wVk As Integer
wScan As Integer
dwFlags As Long
time As Long
#If VBA7 Then
dwExtraInfo As LongPtr
#Else
dwExtraInfo As Long
#End If
padding As Currency
End Type
Private Type tagINPUT
INPUTTYPE As Long
ki As KEYBDINPUT
End Type
#If VBA7 Then
Private Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr, ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As LongPtr
Private Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr) As Long
Private Declare PtrSafe Function SendInput Lib "USER32.DLL" (ByVal cInputs As Long, pInputs As Any, ByVal cbSize As Integer) As Long
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
#Else
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Function SendInput Lib "USER32.DLL" (ByVal cInputs As Long, pInputs As Any, ByVal cbSize As Integer) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If
Private bShowEnd As Boolean
Private oAppEvents As CAppEvents
' _________________________________ PUBLIC ROUTINE ________________________________________
Public Sub MyAutoOpen()
'XML on_Load Procedure.
Set oAppEvents = New CAppEvents
Set oAppEvents.oAppEvents = Application
End Sub
Public Sub MonitorScreenTips(ByVal bMonitor As Boolean)
If bMonitor Then
Call SetTimer(FindWindow("PPTFrameClass", vbNullString), 0&, 0, AddressOf ScreenTipsMonitorProc)
Else
bShowEnd = True
End If
End Sub
' _________________________________ PRIVATE ROUTINES ________________________________________
Private Sub ScreenTipsMonitorProc()
If bShowEnd Then GoTo ReleaseTimer
Call HoldDownShiftKey
Exit Sub
ReleaseTimer:
Call KillTimer(FindWindow("PPTFrameClass", vbNullString), 0)
bShowEnd = False
Debug.Print "Done - Timer safely released."
End Sub
Private Sub HoldDownShiftKey()
Const KEYEVENTF_KEYUP = &H2, KEYEVENTF_UNICODE = &H4, VK_SHIFT = &H10
ReDim InputArray(2&) As tagINPUT
InputArray(0&).INPUTTYPE = 1&
InputArray(0&).ki.wVk = VK_SHIFT
InputArray(0&).ki.dwFlags = KEYEVENTF_UNICODE
InputArray(1&).INPUTTYPE = 1&
InputArray(1&).ki.wVk = VK_SHIFT
InputArray(1&).ki.dwFlags = KEYEVENTF_UNICODE + KEYEVENTF_KEYUP
Call SendInput(2&, InputArray(0&), LenB(InputArray(0&)))
End Sub