This skin comes from a discussion on another thread regarding how to control mouse sensitivity (analogous to using the Control Panel Mouse applet).
With assistance from JSMorley and after a lot of poking around, here is a method based on a PowerShell script found on the Microsoft TechNet website here, with additional cribbing from JSMorley's PowerShellTime skin.
PowerShellMouseSpeed.ini:
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
[Variables]
Speed=1
;
; measures
;
; initialize the Speed variable with the Control Panel setting from the registry
[MeasureGetSpeed]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Control Panel\Mouse
RegValue=MouseSensitivity
IfCondition=MeasureGetSpeed <> #Speed#
IfTrueAction=[!SetVariable Speed ([&MeasureGetSpeed])]
UpdateDivider=-1
; when executed, this measure will change the mouse sensitivity and update the regsitry
[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell.exe
OutputType=ANSI
Parameter=-NoProfile -ExecutionPolicy Bypass -Command ". .\MouseSpeed.ps1 #Speed#"
State=Hide
DynamicVariables=1
OnFinishAction=[!Update *][!Redraw]
;
; meters
;
[MeterShowSpeed]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text="Mouse Sensitivity: #Speed#"
DynamicVariables=1
[MeterSpeedUp]
Meter=String
MeterStyle=MeterShowSpeed
StringAlign=Center
X=16R
Y=0r
W=12
Text="+"
MouseLeaveAction=[!SetOption MeterSpeedUp SolidColor "47,47,47,255"][!UpdateMeter MeterSpeedUp][!Redraw]
MouseOverAction=[!SetOption MeterSpeedUp SolidColor "180,47,47,255"][!UpdateMeter MeterSpeedUp][!Redraw]
LeftMouseUpAction=[!SetVariable Speed (Min(#Speed#+1,20))][!Update *][!CommandMeasure MeasureRun "Run"]
[MeterSpeedDown]
Meter=String
MeterStyle=MeterShowSpeed
StringAlign=Center
X=5R
Y=0r
W=12
Text="-"
MouseLeaveAction=[!SetOption MeterSpeedDown SolidColor "47,47,47,255"][!UpdateMeter MeterSpeedDown][!Redraw]
MouseOverAction=[!SetOption MeterSpeedDown SolidColor "180,47,47,255"][!UpdateMeter MeterSpeedDown][!Redraw]
LeftMouseUpAction=[!SetVariable Speed (Max(#Speed#-1,1))][!Update *][!CommandMeasure MeasureRun "Run"]
[MeterSpeedInfo]
Meter=String
MeterStyle=MeterShowSpeed
FontSize=8
X=([MeterShowSpeed:X])
Y=30r
Text="Range is 1 to 20, default is 10. Click here to reset."
LeftMouseUpAction=[!SetVariable Speed 10][!Update *][!CommandMeasure MeasureRun "Run"]
Code: Select all
<#
.SYNOPSIS
Sets the mouse speed.
.DESCRIPTION
Sets the mouse speed via the SystemParametersInfo SPI_SETMOUSESPEED
and stores the speed in the registry
.PARAMETER Speed
Integer between 1 (slowest) and 20 (fastest). A value of 10 is the default.
.EXAMPLE
Sets the mouse speed to the defautl value.
PS C:\> Set-MouseSpeed -Speed 10
.INPUTS
System.int
.NOTES
See Get-MouseSpeed also.
.LINK
about_functions_advanced
.LINK
about_comment_based_help
.LINK
https://msdn.microsoft.com/en-us/library/ms724947(v=VS.85).aspx
#>
function Set-MouseSpeed() {
[cmdletbinding()]
Param(
[Parameter(ValueFromPipeline=$true)]
[ValidateRange(1,20)]
[int]
$Speed = 10
)
$MethodDefinition = @"
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
"@
$User32 = Add-Type -MemberDefinition $MethodDefinition -Name "User32Set" -Namespace Win32Functions -PassThru
$User32::SystemParametersInfo(0x0071,0,$Speed,0) | Out-Null
Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name MouseSensitivity -Value $Speed
}
<#
.SYNOPSIS
Gets the mouse speed.
.DESCRIPTION
Gets the mouse speed via the SystemParametersInfo SPI_GETMOUSESPEED
.EXAMPLE
Gets the current mouse speed.
PS C:\> Get-MouseSpeed
.Outputs
System.int
.NOTES
See Set-MouseSpeed also.
.LINK
about_functions_advanced
.LINK
about_comment_based_help
.LINK
https://msdn.microsoft.com/en-us/library/ms724947(v=VS.85).aspx
#>
function Get-MouseSpeed() {
$MethodDefinition = @"
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref uint pvParam, uint fWinIni);
"@
$User32 = Add-Type -MemberDefinition $MethodDefinition -Name "User32Get" -Namespace Win32Functions -PassThru
[Int32]$Speed = 0
$User32::SystemParametersInfo(0x0070,0,[ref]$Speed,0) | Out-Null
return $Speed
}
<#
Set the mouse speed
Example: PS C:\> MouseSpeed.ps1 10
#>
$NewValue = $args[0]
$OldValue = Get-MouseSpeed
Set-MouseSpeed -Speed $NewValue
Write-Host "Speed changed from $($OldValue) to $(Get-MouseSpeed)"