Find all our projects in development below.
All source code is GNU General Public License (GPL)
Browsing Utility/MainMod.bas (28.38 KB)
Attribute VB_Name = "MainMod"
Private Const GWL_WNDPROC = (-4)
Private Const WM_DISPLAYCHANGE = &H7E
Private Const WM_GETFONT = &H31
Private Const WM_HOTKEY = &H312
Private Const WM_TIMER = &H113
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private AppWnd As Long
Private Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal lpString As String) As Integer
Private Declare Function GlobalDeleteAtom Lib "kernel32" (ByVal nAtom As Integer) As Integer
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hDC As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function FillRect Lib "user32" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hDC As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As SIZE) As Long
Private Declare Function RedrawWindow Lib "user32" (ByVal hWnd As Long, lprcUpdate As RECT, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetBkMode Lib "gdi32" (ByVal hDC As Long, ByVal nBkMode As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hDC As Long, ByVal crColor As Long) As Long
Private Const RDW_INVALIDATE = &H1
Private Const RDW_ALLCHILDREN = &H80
Private Const RDW_UPDATENOW = &H100
Private Const TRANSPARENT = 1
Private Const DT_MODIFYSTRING = &H10000
Private Const DT_END_ELLIPSIS = &H8000
Public Type SIZE
cx As Long
cy As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private MainVolRect As RECT
Private SubVolRect As RECT
Private ShowVolRect As RECT
Private ShowWATitleRect As RECT
Private ScreenWidth As Long
Private ScreenHeight As Long
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 Const ShowVolumeTimerID = 100
Private iShowVolumeTimer As Long
Private Const ShowWATitleTimerID = 200
Private iShowWATitleTimer As Long
Private Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long) As Long
Private Const MOD_ALT = &H1
Private Const MOD_CONTROL = &H2
Private Const MOD_SHIFT = &H4
Private Const MOD_WIN = &H8
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private PrevWindowProc As Long
Private bVolumeInitialized As Boolean
Private iAtom_PreviousBtn As Long
Private iAtom_PlayPauseBtn As Long
Private iAtom_StopBtn As Long
Private iAtom_NextBtn As Long
Private iAtom_VolUpBtn As Long
Private iAtom_VolDownBtn As Long
Private iAtom_MuteBtn As Long
Private iAtom_HelpBtn As Long
Private iAtom_InternetBtn As Long
Private iAtom_EmailBtn As Long
Private iAtom_ShortcutBtn As Long
Private iAtom_SleepBtn As Long
Private iAtom_BackwardHotkey As Long
Private iAtom_ForwardHotkey As Long
Private iAtom_WAVolUpHotkey As Long
Private iAtom_WAVolDownHotkey As Long
Private iAtom_UCaseSelectionHotkey As Long
Private iAtom_LCaseSelectionHotkey As Long
Private iAtom_IndentTextHotkey As Long
Private iAtom_UnIndentTextHotkey As Long
Private iAtom_SelLenHotkey As Long
Private iAtom_CloseMSNPopupsHotkey As Long
Private Const RegAppRoot = "Software\Jason's PC Software\Gateway Multi-function Keyboard Utility\"
Private Function HiWord(wParam As Long) As Long
HiWord = wParam \ &H10000 And &HFFFF
End Function
Private Function LoWord(wParam As Long) As Long
If wParam And &H8000& Then
LoWord = &H8000& Or (wParam And &H7FFF&)
Else
LoWord = wParam And &HFFFF&
End If
End Function
Private Function SetRect(ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, Optional bNoCalc As Boolean) As RECT
SetRect.Left = X
SetRect.Top = Y
If bNoCalc = False Then
SetRect.Right = X + cx
SetRect.Bottom = Y + cy
Else
SetRect.Right = cx
SetRect.Bottom = cy
End If
End Function
Sub ShowVolume(iVolLevel As Long)
Dim bRegErr As Boolean
Dim DrawOffsetX As Long
Dim DrawOffsetY As Long
Dim DrawRect As RECT
Dim DrawBrush As Long
Dim ScreenDC As Long
Dim BackColor As Long
BackColor = Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Volume Display Color", bRegErr))
If bRegErr Then BackColor = &HC00000
DrawBrush = CreateSolidBrush(BackColor)
If iShowVolumeTimer Then RedrawWindow GetDesktopWindow, ShowVolRect, 0, RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_UPDATENOW
ScreenDC = GetDC(0)
DrawOffsetX = 50
DrawOffsetY = ScreenHeight - 107
DrawRect = SetRect(DrawOffsetX, DrawOffsetY, MainVolRect.Right, MainVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
If iVolLevel >= 5 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 10 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 15 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 20 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY, MainVolRect.Right, MainVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 25 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 30 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 35 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 40 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY, MainVolRect.Right, MainVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 45 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 50 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 55 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 60 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY, MainVolRect.Right, MainVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 65 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 70 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 75 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 80 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY, MainVolRect.Right, MainVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 85 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 90 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 95 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY + SubVolRect.Top, SubVolRect.Right, SubVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
If iVolLevel >= 100 Then
DrawOffsetX = DrawOffsetX + (DrawRect.Right - DrawRect.Left) + 7
DrawRect = SetRect(DrawOffsetX, DrawOffsetY, MainVolRect.Right, MainVolRect.Bottom)
FillRect ScreenDC, DrawRect, DrawBrush
End If
ShowVolRect = SetRect(50, DrawOffsetY, DrawOffsetX, MainVolRect.Bottom)
DeleteObject DrawBrush
ReleaseDC 0, ScreenDC
If iShowVolumeTimer Then iShowVolumeTimer = KillTimer(AppWnd, ShowVolumeTimerID)
iShowVolumeTimer = SetTimer(AppWnd, ShowVolumeTimerID, 1500, 0)
End Sub
Sub Main()
If App.PrevInstance Then
MsgBox "The Gateway Multi-function Keyboard Utility is already running.", vbInformation
End
End If
Load DummyForm
bVolumeInitialized = InitGetVolume
AppWnd = FindWindow("ThunderRT6Main", App.Title)
If AppWnd = 0 Then
MsgBox "An error occurred while initializing the Gateway Multi-function Keyboard Utility application.", vbCritical
End
End If
MainVolRect = SetRect(0, 0, 17, 57)
SubVolRect = SetRect(0, 24, 17, 9)
ScreenWidth = Int(Screen.Width / Screen.TwipsPerPixelY)
ScreenHeight = Int(Screen.Height / Screen.TwipsPerPixelY)
DummyForm.FontSize = Int((ScreenWidth / 58) + 0.5)
iAtom_PreviousBtn = GlobalAddAtom("PreviousBtn Hotkey")
RegisterHotKey AppWnd, iAtom_PreviousBtn, MOD_ALT Or MOD_CONTROL Or MOD_WIN, 80
iAtom_PlayPauseBtn = GlobalAddAtom("PlayPauseBtn Hotkey")
RegisterHotKey AppWnd, iAtom_PlayPauseBtn, MOD_ALT Or MOD_CONTROL Or MOD_WIN, 68
iAtom_StopBtn = GlobalAddAtom("StopBtn Hotkey")
RegisterHotKey AppWnd, iAtom_StopBtn, MOD_ALT Or MOD_CONTROL Or MOD_WIN, 83
iAtom_NextBtn = GlobalAddAtom("NextBtn Hotkey")
RegisterHotKey AppWnd, iAtom_NextBtn, MOD_ALT Or MOD_CONTROL Or MOD_WIN, 78
iAtom_VolUpBtn = GlobalAddAtom("VolUpBtn Hotkey")
RegisterHotKey AppWnd, iAtom_VolUpBtn, MOD_CONTROL Or MOD_WIN, 86
iAtom_VolDownBtn = GlobalAddAtom("VolDownBtn Hotkey")
RegisterHotKey AppWnd, iAtom_VolDownBtn, MOD_SHIFT Or MOD_WIN, 86
iAtom_MuteBtn = GlobalAddAtom("MuteBtn Hotkey")
RegisterHotKey AppWnd, iAtom_MuteBtn, MOD_WIN, 86
iAtom_HelpBtn = GlobalAddAtom("HelpBtn Hotkey")
RegisterHotKey AppWnd, iAtom_HelpBtn, MOD_ALT Or MOD_CONTROL Or MOD_WIN, 77
iAtom_InternetBtn = GlobalAddAtom("InternetBtn Hotkey")
RegisterHotKey AppWnd, iAtom_InternetBtn, MOD_ALT Or MOD_CONTROL Or MOD_WIN, 84
iAtom_EmailBtn = GlobalAddAtom("EmailBtn Hotkey")
RegisterHotKey AppWnd, iAtom_EmailBtn, MOD_CONTROL Or MOD_WIN, 90
iAtom_ShortcutBtn = GlobalAddAtom("ShortcutBtn Hotkey")
RegisterHotKey AppWnd, iAtom_ShortcutBtn, MOD_ALT Or MOD_CONTROL Or MOD_WIN, 82
iAtom_SleepBtn = GlobalAddAtom("SleepBtn Hotkey")
RegisterHotKey AppWnd, iAtom_SleepBtn, MOD_ALT Or MOD_WIN, 44
iAtom_BackwardHotkey = GlobalAddAtom("Backward Hotkey")
RegisterHotKey AppWnd, iAtom_BackwardHotkey, MOD_CONTROL, 37
iAtom_ForwardHotkey = GlobalAddAtom("Forward Hotkey")
RegisterHotKey AppWnd, iAtom_ForwardHotkey, MOD_CONTROL, 39
iAtom_WAVolUpHotkey = GlobalAddAtom("WAVolUp Hotkey")
RegisterHotKey AppWnd, iAtom_WAVolUpHotkey, MOD_CONTROL, 38
iAtom_WAVolDownHotkey = GlobalAddAtom("WAVolDown Hotkey")
RegisterHotKey AppWnd, iAtom_WAVolDownHotkey, MOD_CONTROL, 40
iAtom_UCaseSelectionHotkey = GlobalAddAtom("UCaseSelection Hotkey")
RegisterHotKey AppWnd, iAtom_UCaseSelectionHotkey, MOD_ALT, 38
iAtom_LCaseSelectionHotkey = GlobalAddAtom("LCaseSelection Hotkey")
RegisterHotKey AppWnd, iAtom_LCaseSelectionHotkey, MOD_ALT, 40
iAtom_IndentTextHotkey = GlobalAddAtom("IndentText Hotkey")
RegisterHotKey AppWnd, iAtom_IndentTextHotkey, MOD_ALT, 39
iAtom_UnIndentTextHotkey = GlobalAddAtom("UnIndentText Hotkey")
RegisterHotKey AppWnd, iAtom_UnIndentTextHotkey, MOD_ALT, 37
iAtom_SelLenHotkey = GlobalAddAtom("SelLenHotkey Hotkey")
RegisterHotKey AppWnd, iAtom_SelLenHotkey, MOD_ALT, 32
iAtom_CloseMSNPopupsHotkey = GlobalAddAtom("CloseMSNPopupsHotkey Hotkey")
RegisterHotKey AppWnd, iAtom_CloseMSNPopupsHotkey, MOD_CONTROL, vbKeyDelete
PrevWindowProc = SetWindowLong(AppWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Private Sub ShowWATitle()
Dim bRegErr As Boolean
Dim hOldFont As Long
Dim ScreenDC As Long
Dim TextSize As SIZE
Dim TextRect As RECT
Dim WASongTitle As String
Dim BackColor As Long
WASongTitle = WAGetSongTitle
If WASongTitle = "" Then Exit Sub
BackColor = Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Winamp Song Title Display Color", bRegErr))
If bRegErr Then BackColor = &HC00000
If iShowWATitleTimer Then RedrawWindow GetDesktopWindow, ShowWATitleRect, 0, RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_UPDATENOW
ScreenDC = GetDC(0)
hOldFont = SelectObject(ScreenDC, SendMessage(DummyForm.hWnd, WM_GETFONT, 0&, 0&))
SetBkMode ScreenDC, TRANSPARENT
SetTextColor ScreenDC, BackColor
GetTextExtentPoint32 ScreenDC, WASongTitle, Len(WASongTitle), TextSize
ShowWATitleRect = SetRect(ScreenWidth - 40 - TextSize.cx, ScreenHeight - 40 - TextSize.cy, ScreenWidth - 40, ScreenHeight, True)
If ShowWATitleRect.Left < 0 Then ShowWATitleRect.Left = 40
If ShowWATitleRect.Top < 0 Then ShowWATitleRect.Top = 0
TextRect = SetRect(40, 0, ScreenWidth - 80, TextSize.cy)
DrawText ScreenDC, WASongTitle, -1, TextRect, DT_MODIFYSTRING Or DT_END_ELLIPSIS
DrawText ScreenDC, WASongTitle, -1, ShowWATitleRect, 0
DeleteObject hOldFont
ReleaseDC 0, ScreenDC
If iShowWATitleTimer Then iShowWATitleTimer = KillTimer(AppWnd, ShowWATitleTimerID)
iShowWATitleTimer = SetTimer(AppWnd, ShowWATitleTimerID, 1500, 0)
End Sub
Public Sub UnregisterHotkeys()
UnregisterHotKey AppWnd, iAtom_PreviousBtn
GlobalDeleteAtom iAtom_PreviousBtn
UnregisterHotKey AppWnd, iAtom_PlayPauseBtn
GlobalDeleteAtom iAtom_PlayPauseBtn
UnregisterHotKey AppWnd, iAtom_StopBtn
GlobalDeleteAtom iAtom_StopBtn
UnregisterHotKey AppWnd, iAtom_NextBtn
GlobalDeleteAtom iAtom_NextBtn
UnregisterHotKey AppWnd, iAtom_VolUpBtn
GlobalDeleteAtom iAtom_VolUpBtn
UnregisterHotKey AppWnd, iAtom_VolDownBtn
GlobalDeleteAtom iAtom_VolDownBtn
UnregisterHotKey AppWnd, iAtom_MuteBtn
GlobalDeleteAtom iAtom_MuteBtn
UnregisterHotKey AppWnd, iAtom_HelpBtn
GlobalDeleteAtom iAtom_HelpBtn
UnregisterHotKey AppWnd, iAtom_InternetBtn
GlobalDeleteAtom iAtom_InternetBtn
UnregisterHotKey AppWnd, iAtom_EmailBtn
GlobalDeleteAtom iAtom_EmailBtn
UnregisterHotKey AppWnd, iAtom_ShortcutBtn
GlobalDeleteAtom iAtom_ShortcutBtn
UnregisterHotKey AppWnd, iAtom_SleepBtn
GlobalDeleteAtom iAtom_SleepBtn
UnregisterHotKey AppWnd, iAtom_BackwardHotkey
GlobalDeleteAtom iAtom_BackwardHotkey
UnregisterHotKey AppWnd, iAtom_ForwardHotkey
GlobalDeleteAtom iAtom_ForwardHotkey
UnregisterHotKey AppWnd, iAtom_WAVolUpHotkey
GlobalDeleteAtom iAtom_WAVolUpHotkey
UnregisterHotKey AppWnd, iAtom_WAVolDownHotkey
GlobalDeleteAtom iAtom_WAVolDownHotkey
UnregisterHotKey AppWnd, iAtom_UCaseSelectionHotkey
GlobalDeleteAtom iAtom_UCaseSelectionHotkey
UnregisterHotKey AppWnd, iAtom_LCaseSelectionHotkey
GlobalDeleteAtom iAtom_LCaseSelectionHotkey
UnregisterHotKey AppWnd, iAtom_IndentTextHotkey
GlobalDeleteAtom iAtom_IndentTextHotkey
UnregisterHotKey AppWnd, iAtom_UnIndentTextHotkey
GlobalDeleteAtom iAtom_UnIndentTextHotkey
UnregisterHotKey AppWnd, iAtom_SelLenHotkey
GlobalDeleteAtom iAtom_SelLenHotkey
UnregisterHotKey AppWnd, iAtom_CloseMSNPopupsHotkey
GlobalDeleteAtom iAtom_CloseMSNPopupsHotkey
End Sub
Public Sub UnSubclass()
If iShowVolumeTimer Then iShowVolumeTimer = KillTimer(AppWnd, ShowVolumeTimerID)
If iShowWATitleTimer Then iShowWATitleTimer = KillTimer(AppWnd, ShowWATitleTimerID)
SetWindowLong AppWnd, GWL_WNDPROC, PrevWindowProc
End Sub
Private Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
Dim VolValue As Long
Dim ShellEXE As String
If hWnd = AppWnd Then
If uMsg = WM_HOTKEY Then
Select Case wParam
Case iAtom_PreviousBtn
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Winamp Support")) = 1 Then WATrackPrev
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "WMP Support")) = 1 Then WMPPrev
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "CDPlayer Support")) = 1 Then WCDPlayerTrackPrev
Case iAtom_PlayPauseBtn
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Winamp Support")) = 1 Then
If WAPlaybackStatus = 0 Then
WATrackPlay
ElseIf WAPlaybackStatus = 1 Then
WATrackPause
ElseIf WAPlaybackStatus = 2 Then
WATrackPlay
ElseIf WAPlaybackStatus = 3 Then
WATrackPlay
End If
End If
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "WMP Support")) = 1 Then WMPPlayPause
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "CDPlayer Support")) = 1 Then WCDPlayerTrackPlayPause
Case iAtom_StopBtn
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Winamp Support")) = 1 Then WATrackStop
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "WMP Support")) = 1 Then WMPStop
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "CDPlayer Support")) = 1 Then WCDPlayerTrackStop
Case iAtom_NextBtn
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Winamp Support")) = 1 Then WATrackNext
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "WMP Support")) = 1 Then WMPNext
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "CDPlayer Support")) = 1 Then WCDPlayerTrackNext
Case iAtom_VolUpBtn
VolValue = Int((GetVolumeValue(SetVolHmixer, SetVolCtrl) * 100) / 65535) + 5
If VolValue > 100 Then VolValue = 100
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Volume")) = 1 Then ShowVolume VolValue
SetVolumeControl SetVolHmixer, SetVolCtrl, VolValue * 65535 / 100
Case iAtom_VolDownBtn
VolValue = Int((GetVolumeValue(SetVolHmixer, SetVolCtrl) * 100) / 65535) - 5
If VolValue < 0 Then VolValue = 0
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Volume")) = 1 Then ShowVolume VolValue
SetVolumeControl SetVolHmixer, SetVolCtrl, VolValue * 65535 / 100
Case iAtom_MuteBtn
If GetVolumeValue(SetVolHmixer, SetMuteCtrl) Then
SetVolumeControl SetVolHmixer, SetMuteCtrl, 0
VolValue = Int((GetVolumeValue(SetVolHmixer, SetVolCtrl) * 100) / 65535)
If VolValue < 0 Then VolValue = 0
If VolValue > 100 Then VolValue = 100
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Volume")) = 1 Then ShowVolume VolValue
Else
SetVolumeControl SetVolHmixer, SetMuteCtrl, 1
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Volume")) = 1 Then ShowVolume 0
End If
Case iAtom_HelpBtn
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title")) = 1 And _
Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title Hotkey")) = 0 Then
ShowWATitle
Exit Function
End If
ShellEXE = GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Help Button")
If ShellEXE <> "" Then
Shell ShellEXE, vbNormalFocus
If Err.Number Then MsgBox "Error running program:" + vbCrLf + ShellEXE + vbCrLf + vbCrLf + "Run setup to fix this error.", vbCritical
End If
Case iAtom_InternetBtn
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title")) = 1 And _
Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title Hotkey")) = 1 Then
ShowWATitle
Exit Function
End If
ShellEXE = GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Internet Button")
If ShellEXE <> "" Then
Shell ShellEXE, vbNormalFocus
If Err.Number Then MsgBox "Error running program:" + vbCrLf + ShellEXE + vbCrLf + vbCrLf + "Run setup to fix this error.", vbCritical
End If
Case iAtom_EmailBtn
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title")) = 1 And _
Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title Hotkey")) = 2 Then
ShowWATitle
Exit Function
End If
ShellEXE = GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Email Button")
If ShellEXE <> "" Then
Shell ShellEXE, vbNormalFocus
If Err.Number Then MsgBox "Error running program:" + vbCrLf + ShellEXE + vbCrLf + vbCrLf + "Run setup to fix this error.", vbCritical
End If
Case iAtom_ShortcutBtn
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title")) = 1 And _
Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title Hotkey")) = 3 Then
ShowWATitle
Exit Function
End If
ShellEXE = GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Shortcut Button")
If ShellEXE <> "" Then
Shell ShellEXE, vbNormalFocus
If Err.Number Then MsgBox "Error running program:" + vbCrLf + ShellEXE + vbCrLf + vbCrLf + "Run setup to fix this error.", vbCritical
End If
Case iAtom_SleepBtn
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title")) = 1 And _
Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Display Winamp Song Title Hotkey")) = 4 Then
ShowWATitle
Exit Function
End If
ShellEXE = GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Sleep Button")
If ShellEXE <> "" Then
Shell ShellEXE, vbNormalFocus
If Err.Number Then MsgBox "Error running program:" + vbCrLf + ShellEXE + vbCrLf + vbCrLf + "Run setup to fix this error.", vbCritical
End If
Case iAtom_BackwardHotkey
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Winamp Support")) = 1 Then WATrackFRewind
Case iAtom_ForwardHotkey
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Winamp Support")) = 1 Then WATrackFForward
Case iAtom_WAVolUpHotkey
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Winamp Support")) = 1 Then WAVolRaise
Case iAtom_WAVolDownHotkey
If Val(GetRegString(HKEY_LOCAL_MACHINE, RegAppRoot, "Winamp Support")) = 1 Then WAVolLower
Case iAtom_UCaseSelectionHotkey
UpperCaseEditBox
Case iAtom_LCaseSelectionHotkey
LowerCaseEditBox
Case iAtom_IndentTextHotkey
IndentEditBoxText
Case iAtom_UnIndentTextHotkey
OutdentEditBoxText
Case iAtom_SelLenHotkey
ShowSelectionCount
Case iAtom_CloseMSNPopupsHotkey
CloseMSNPopups
End Select
ElseIf uMsg = WM_DISPLAYCHANGE Then
ScreenWidth = LoWord(lParam)
ScreenHeight = HiWord(lParam)
DummyForm.FontSize = Int((ScreenWidth / 58) + 0.5)
ElseIf uMsg = WM_TIMER Then
Select Case wParam
Case ShowVolumeTimerID
RedrawWindow GetDesktopWindow, ShowVolRect, 0, RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_UPDATENOW
iShowVolumeTimer = KillTimer(AppWnd, ShowVolumeTimerID)
iShowVolumeTimer = 0
Case ShowWATitleTimerID
RedrawWindow GetDesktopWindow, ShowWATitleRect, 0, RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_UPDATENOW
iShowWATitleTimer = KillTimer(AppWnd, ShowWATitleTimerID)
iShowWATitleTimer = 0
End Select
End If
End If
WindowProc = CallWindowProc(PrevWindowProc, hWnd, uMsg, wParam, lParam)
End Function