Hi all,
I occasionally either have my taskbar hidden or a full-screen game on so I can't always see the little envelope in there from outlook to tell me I have new mail. So I decided to use something else to catch my eye, and decided on the scroll lock light (a blinking light catches my eye much more than an icon in the taskbar; I didn't want a popup or anything like that).
So I wrote one. Anyone think this would be useful?
Also, testing in a different version than outlook 2k sr1 would be appreciated
You'll need to use the ThisOutlookSession class module, as well as a new class module called "vBlinkerCls", and a standard code module.
ThisOutlookSession:
[vba]'***** Start ThisOutlookSession code *****
Option Explicit
Dim BlinkMail As vBlinkerCls
Sub Application_Startup()
Set BlinkMail = New vBlinkerCls
End Sub
Private Sub Application_Quit()
Set BlinkMail = Nothing
End Sub
'***** End ThisOutlookSession code *****[/vba]
vBlinkerCls:
[vba]'***** Start vBlinkerCls code - Class Module *****
Option Explicit
Private WithEvents ThisApp As Outlook.Application
Private WithEvents ActivExplorer As Outlook.Explorer
Public HasFocus As Boolean
Public ScrollOn As Boolean
Private Const BLINK_MILLISECONDS As Long = 500
Private Const VK_SCROLL = &H91
Private Sub ActivExplorer_Activate()
HasFocus = True
End Sub
Private Sub ActivExplorer_Deactivate()
HasFocus = False
End Sub
Private Sub ThisApp_NewMail()
If Not HasFocus Then
StartFlash
Do Until HasFocus
DoEvents
Loop
StopFlash
End If
End Sub
Sub StartFlash()
If Not KeepGoing Then
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
ScrollOn = keys(VK_SCROLL)
End If
KeepGoing = True
SetTimer 0&, 0&, BLINK_MILLISECONDS&, AddressOf PressScrollLock
End Sub
Sub StopFlash()
KeepGoing = False
DoEvents
Sleep BLINK_MILLISECONDS
DoEvents
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
If keys(VK_SCROLL) <> ScrollOn Then
keybd_event VK_SCROLL, &H45, 0, 0
keybd_event VK_SCROLL, &H45, &H2, 0
End If
End Sub
Private Sub Class_Initialize()
Set ThisApp = Application
Set ActivExplorer = ThisApp.ActiveExplorer
End Sub
Private Sub Class_Terminate()
Set ActivExplorer = Nothing
Set ThisApp = Nothing
End Sub
'***** End vBlinkerCls code *****[/vba]
Standard code module:
[vba]'***** Start vBlinkerMdl code - Standard Module *****
Option Explicit
Private Const VK_SCROLL = &H91
Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan _
As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal _
nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal _
nIDEvent As Long) As Long
Public KeepGoing As Boolean
Sub PressScrollLock(ByVal hWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, _
ByVal dwTimer As Long)
If KeepGoing Then
keybd_event VK_SCROLL, &H45, 0, 0
keybd_event VK_SCROLL, &H45, &H2, 0
End If
If Not KeepGoing Then KillTimer 0&, nIDEvent
End Sub
'***** End vBlinkerMdl code *****[/vba]
Also attaching exported versions of these
Any thoughts/suggestions? It works for me as I need it but others might have a better idea or a better way of doing some of it.
Matt