Functions/Test-IsScrollLock.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
function Test-IsScrollLock { <# .SYNOPSIS Sets the state of the ScrollLock button. If you pass $true to function it will turn on ScrollLock. .DESCRIPTION Sets the state of the ScrollLock button. If you pass $true to function it will turn on ScrollLock. It first determines the state of the ScrollLock and then acts accordingly. .PARAMETER State A switch parameter to determine if you want the ScrollLock to be $true or $false. .EXAMPLE Set-ScrollLock -State Will turn on the ScrollLock .EXAMPLE Set-ScrollLock -State:$false Will turn off the ScrollLock .INPUTS None .OUTPUTS bool .NOTES Inspiration: # Inspired by https://gallery.technet.microsoft.com/on-off-keyboad-lock-keys-6ba9885c #> [CmdletBinding(ConfirmImpact='None')] [OutputType('bool')] Param() begin { Write-Verbose -Message "Starting [$($MyInvocation.Mycommand)]" } process { write-verbose -Message 'Determining the state of [ScrollLock]' $ReturnVal = [System.Windows.Forms.Control]::IsKeyLocked('Scroll') Write-Output -InputObject $ReturnVal } end { Write-Verbose -Message "Ending [$($MyInvocation.Mycommand)]" } } |