# encoding: ascii
# api: powershell
# title: CapsLock Notifier
# description: Displays Capslock status icon in the Taskbar Notification area. Shows balloon tip if status has been changed.
# version: 1.0
# type: script
# author: Bryan Jaudon
# license: CC0
# function: Hide-PowerShell
# x-poshcode-id: 3736
# x-archived: 2016-08-09T22:30:10
# x-published: 2013-11-01T09:36:00
#
#
<#

    .NOTES
    Name     : CapsLockNotifier.ps1
    Author   : Bryan Jaudon <bryan.jaudon@gmail.com>
    Version  : 1.0
    Date     : 10/25/2012

    .Description
    Adds a notification icon to show current CapsLock status. Double clicking or by using the context menu, allows for 
    toggling of the CapsLock status.


#>

#requires -version 2

param([switch]$Debug)

function CheckCapsLock {
    $CapsLockStatus=[console]::CapsLock
    Write-Debug "CheckCapsLock - Previous Reading: $Script:PreviousCapsLock - Current Reading: $CapsLockStatus"
    if ($PreviousCapsLock -ne $CapsLockStatus) {
        if ($CapsLockStatus -eq $True) {
            Write-Debug "CheckCapsLock - Update CapsLock NotificationIcon to ON"
            $NotifyIcon.Icon = $IconOn 
            $NotifyIcon.BalloonTipTitle = "CapsLock is On"
            $NotifyIcon.Text="CapsLock Status - On"
            $NotifyIcon.BalloonTipText = "CapsLock status has changed to On."
        }
        else { 
            Write-Debug "CheckCapsLock - Update CapsLock NotificationIcon to OFF"
            $NotifyIcon.Icon = $IconOff 
            $NotifyIcon.BalloonTipTitle = "CapsLock is Off"
            $NotifyIcon.Text="CapsLock Status - Off"
            $NotifyIcon.BalloonTipText = "CapsLock status has changed to Off."
        }
        Write-Debug "CheckCapsLock - Show NotificationIcon BaloonTip"
        $NotifyIcon.BalloonTipIcon = "Info"  
        $NotifyIcon.Visible = $True 
        $NotifyIcon.ShowBalloonTip(50000)  
    }
    $Script:PreviousCapsLock=$CapsLockStatus
}

function ToggleCapsLock {
    $wshObject=New-Object -ComObject "WScript.Shell"
    $wshObject.SendKeys('{CapsLock}')
    Write-Debug "ToggleCapsLock - wshObject Sendkeys(CapsLock)"
}

Function Hide-PowerShell { $null = $showWindowAsync::ShowWindowAsync((Get-Process -PID $pid).MainWindowHandle, 0) }

[void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
[void][reflection.assembly]::loadwithpartialname("System.Drawing")

[string]$IconOnb64=@"
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAK
T2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AU
kSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXX
Pues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgAB
eNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAt
AGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3
AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dX
Lh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+
5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk
5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd
0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA
4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzA
BhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJg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oao458aCFBEC7z1ePYpi1Q6UOUTBcKSSYj6xcXYDAAwAOOfoS5+rG1eJ
TLRtEWttrgMMHNEjxBLnvfIxK98TAFXF45l205SDMkmSkCQJIpIDyIa3HrVKaEN6vW7ejsOAgZxW
VSVbYxw445zDOYcRQ5RELP+xzLP1Z4QTIbZikbJgKxYtKkE1wBYsnU6Hly9fYoylVCpRLpcJCyET
ExO0223a7TbFYjFfJE3TsZ6xrQKlUonr16+TJAnv3r3j6dOnbG1tUalUaDQanD17lpWVFS5dukSn
02FpaYkrV66wuLjIq1evmJ2dZXV1FYBms8nFixc5duwYcRzvWAERIe8C7z2tVou5uTkOHjzI3bt3
WV5e5sGDB7RaLW7cuMGdO3d4+PAhpVKJKIp4vvace/fu0Ww2uXbtGmEYEscxt27dot1uY63NzWhH
CoZN5MKFCywtLbGxscGpU6c4d+5cXr75+Xnm5uY4dOgQ+/fvp1AocP/P+5w5c4ZSqcTly5dpNBpM
T0+zsLBAHMf5ouMqkFv24uJic9++fbWpqSnCMByU5b2DWWt59OgRMzMzVCqV3N3SNKVQKNDv93PB
ZWoffsY5x+bmJm/fvuX169ccPXqUWq2WA4rjuBVkXy8iJEnyQZlmZ2dzPzfGYK1FRHJu/R6seCcN
AIMuGH1xOPr9/vaXP/EIN+wD47rAZAj3HPLpVrybBj5agQ8zfuTAMNJmQC7kcQAC730upoyz0STD
AzEYEXTkfj4/ooFer8ewzobnBvuOqo+iiPX1daampsbylJVxYMeDRMPCy+aHKykiNBoN6vV6vmVn
uYe28F4wOTn5V71e/+nNmzc0Go0PAIwDtNMxbTSyrkrTlCAIKBaLOch+v0+lUrkt9Xr9m9XV1Z9b
rdYPqmrZO8V70oC1liiKOHDggNRqtW6aph3AVqvV+6dPn16QL39GXwD87wH8MwBTzNLUBSl3TAAA
AABJRU5ErkJggg==
"@

$IconOnstream=[System.IO.MemoryStream][System.Convert]::FromBase64String($IconOnb64)
$IconOnbmp=[System.Drawing.Bitmap][System.Drawing.Image]::FromStream($IconOn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QBaK0RSULj6lVkGO7Y
RClV6EAC9sgRRBQXrfIpK98TAGstGIOemsKpVEjTlDRNEUIUAPKhjEFhUa5Lr9ct2rEMGCjKaq2l
2GMIOKm17jMgJWkY8sfyMhvPnzPmulSVoiIEVaXwraXmOHhKEUURr169QkpFEARUKhVcz2VsbIxO
p0On08H3/WKTLMuGesYOBoIg4MaNG6RpyocPH3j27BlbW1tUq1WazSZnz55ldXWVS5cuEUURS0tL
XLlyhcXFRV6/fs3MzAxra2sAtFotLl68yLFjx4jjeCQDQgiKLjDG0G63mZ2d5eDBg9y7d4/l5WUe
PHhAu93m5s2b3L17l4cPHxIEAWEY8mL9Bffv36fVanHt2jVc1yWOYxYWFuh0OiilCjMaWYKyiVy4
cIGlpSXevXvHqVOnOHfuXEHf3Nwcs7OzHDp0iPHxcTzPY+XPFc6cOUMQBFy+fJlms8nU1BTz8/PE
2z6RO+IggMKyFxcXW/v3769PTk7ium6flm0HU0rx+PFjpqenqVarhbtlWYbneSRJUgguV3v5P1pr
Njc3ef/+PW/evOHo0aPU6/UCUBzHbSd/eiEEaZp+RNPMzEzh51JKlFIIIYramj1Y8SgNAP0uGFxY
jiRJdi7+zCNc2QeGdYHMEe45xOdb8W4a+CQDH2f8xIFhoM2AQsjDADjGmEJMec0Gk5QHQiKFwA7c
L+YHNNDr9SjrrDwH4FhrTRiGbGxsMDk5ObROOY19O+4nKgsvny8zKYSg2WzSaDSKV3aeu/QK7zkT
ExN/NRqNX96+fUuz2fwIwDBAo45pg5F3VZZlOI6D7/sFyCRJqFard0Sj0fhubW3t13a7/ZO1VrH3
Eu9JA0opwjDkwIEDol6vd7MsiwBVq9VWTp8+PS++fhl9BfC/B/DPAHixztivq7qsAAAAAElFTkSu
QmCC
"@

$IconOffstream=[System.IO.MemoryStream][System.Convert]::FromBase64String($IconOffb64)
$IconOffbmp=[System.Drawing.Bitmap][System.Drawing.Image]::FromStream($IconOffstream)
$IconOffhandle=$IconOffbmp.GetHicon()
$IconOff=[System.Drawing.Icon]::FromHandle($IconOffhandle)

$form1 = New-Object System.Windows.Forms.form
$NotifyIcon= New-Object System.Windows.Forms.NotifyIcon
$ContextMenu = New-Object System.Windows.Forms.ContextMenu
$MenuItemToggle = New-Object System.Windows.Forms.MenuItem
$MenuItemExit = New-Object System.Windows.Forms.MenuItem
$Timer = New-Object System.Windows.Forms.Timer

$form1.ShowInTaskbar = $false
$form1.WindowState = "minimized"

$NotifyIcon.ContextMenu = $ContextMenu
$NotifyIcon.contextMenu.MenuItems.AddRange($MenuItemToggle)
$NotifyIcon.contextMenu.MenuItems.AddRange($MenuItemExit)
$NotifyIcon.Visible = $True
$NotifyIcon.add_DoubleClick({ Write-Debug "NotifyIcon - DoubleClickEvent: ToggleCapsLock"; ToggleCapsLock })

$Timer.Interval =  1000
$Timer.add_Tick({ CheckCapsLock })
$Timer.start()

$MenuItemToggle.Index = 0
$MenuItemToggle.Text = "&Toggle CapsLock"
$MenuItemToggle.add_Click({ Write-Debug "NotifyIcon - MenuItemEvent: ToggleCapsLock"; ToggleCapsLock })

$MenuItemExit.Index = 1
$MenuItemExit.Text = "E&xit"
$MenuItemExit.add_Click({ Write-Debug "NotifyIcon - ExitEvent"; $Timer.stop(); $NotifyIcon.Visible = $False; $form1.close() })

$script:showWindowAsync = Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"@ -name Win32ShowWindowAsync -namespace Win32Functions -PassThru

if ($host.name -ne "Windows PowerShell ISE Host") { 
    if ($Debug -ne $True) { Hide-PowerShell }
    else { $DebugPreference="Continue" }
}

$Script:PreviousCapsLock=[console]::CapsLock
if ($Script:PreviousCapsLock -eq $True) {
    Write-Debug "Initilization - CapsLock On"
    $NotifyIcon.Icon = $IconOn 
    $NotifyIcon.Text="CapsLock Status - On"
}
else {
    Write-Debug "Initilization - CapsLock Off"
    $NotifyIcon.Icon = $IconOff 
    $NotifyIcon.Text="CapsLock Status - Off"
}

[void][System.Windows.Forms.Application]::Run($form1)
