It is currently March 28th, 2024, 8:21 pm

Changing mouse sensitivity

Post reviews, recommendations and questions about other software.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Changing mouse sensitivity

Post by SilverAzide »

jsmorley wrote:In digging a bit deeper, I'm not convinced the -NonInteractive parameter has anything to do with whether the console is displayed. It seems to have to do with whether or not an interactive "prompt" is displayed. In any case, with RunCommand I don't think you ever need it.
Right... I didn't mean to imply you needed that switch all the time, where it comes in super-handy is if you need to run a command window (cmd) ELEVATED. If you don't use this switch, you get an empty powershell window AND command window (and a UAC prompt). For example, you can call powershell, have it in turn call a DOS-type command or batch file in an elevated command shell. I use this trick to control a Windows service, so that I get no output except for a UAC prompt (and no flash of any windows). Normally, RunCommand with "Hide" is all you need.

Now...
To redirect this thread back to the original topic... The original poster's problem is that he needs to call the Win32 SystemParametersInfo API to change the mouse sensitivity immediately. Just changing the registry has no effect until logoff/logon, so you need to do both. I redirected the OP to a link where he can get a Powershell script that will create a function called Set-MouseSpeed. Using this, along with a RunCommand plugin, will allow him to run a Powershell command that will provide him the ability to pass a parameter to vary the sensitivity, which was his request.

The RunCommand command would be something like powershell -Command "#@#MouseSpeed.ps1 ; Set-MouseSpeed -Speed [&MeasureSpeed]"

...where the script is located in the @Resources folder and the [&MeasureSpeed] value is some measure that is a numeric value from 1 to 20. With this, he can easily ;) create a simple skin that allows incremental changes to the mouse sensitivity, without needing to use any third-party utilities.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing mouse sensitivity

Post by jsmorley »

Boarding party to the topsails! Arrrr!

From what I see, there is a way to distribute a skin that uses a .ps1 file to execute a PowerShell script that can be run on machines that have not changed the default execution security from "restricted". As long as the script itself does not require elevation to "administrator" to run.

Can someone who has not changed the security for PowerShell download and try this out?
PowerShellTest_1.0.rmskin
1.png
Skin:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
OnRefreshAction=[!CommandMeasure MeasureRun "Run"]

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
OutputType=ANSI
Parameter=PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '.\GetGPU.ps1'"
SubStitute="#CRLF#":""
FinishAction=[!UpdateMeter MeterGPU][!Redraw]

[MeterGPU]
Meter=String
MeasureName=MeasureRun
ClipStringW=500
ClipString=2
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=GPU Name: %1
GetGPU.ps1:

Code: Select all

$computerVideo = Get-WmiObject Win32_VideoController
write-host $computerVideo.description
If it doesn't work, I would expect you to get something like this:
2.png
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Changing mouse sensitivity

Post by SilverAzide »

Dang it... I tried your skin and got the error, then I realized your zip's .INI code does not have the -ExecutionPolicy parameters like your post does. I changed the skin to match your post and now it works... and putting it back the way it was STILL WORKS. So I can't get the error at all now. I even forced my execution policy back the the default restricted state, still works!

Totally confused...

BTW, you can use the single command:
powershell -command "Get-WmiObject Win32_VideoController | Format-Table -Property Description -AutoSize -HideTableHeaders"

...without a script if you wanted, but I assume the intent here is get a PS script to run successfully without errors or policy nags.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing mouse sensitivity

Post by jsmorley »

SilverAzide wrote:Dang it... I tried your skin and got the error, then I realized your zip's .INI code does not have the -ExecutionPolicy parameters like your post does. I changed the skin to match your post and now it works... and putting it back the way it was STILL WORKS. So I can't get the error at all now. I even forced my execution policy back the the default restricted state, still works!

Totally confused...

BTW, you can use the single command:
powershell -command "Get-WmiObject Win32_VideoController | Format-Table -Property Description -AutoSize -HideTableHeaders"

...without a script if you wanted, but I assume the intent here is get a PS script to run successfully without errors or policy nags.
Yeah, not worried about single line commands, as there is no security around that. Just interested to see if it is practical to distribute skins as .rmskins that have .ps1 scripts in them. In principle, it's not good if it doesn't work for everyone on every version of Windows in every circumstance.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Changing mouse sensitivity

Post by SilverAzide »

I still can't get your skin to fail now. It failed the first time, but now it runs fine no matter what I do. Not promising for your test for consistency across all machines/users... I'll try again tomorrow where I have access to some virtual machines that I can rewind back to the original "clean" state.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing mouse sensitivity

Post by jsmorley »

SilverAzide wrote:I still can't get your skin to fail now. It failed the first time, but now it runs fine no matter what I do. Not promising for your test for consistency across all machines/users... I'll try again tomorrow where I have access to some virtual machines that I can rewind back to the original "clean" state.
Great. I fixed that .rmskin by the way. Sorry about that.

So maybe it "remembers" that you ran a script already or something...
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Changing mouse sensitivity

Post by SilverAzide »

jsmorley wrote:So maybe it "remembers" that you ran a script already or something...
I was wondering the same thing...

So I fired up a clean Win10 machine that had its PowerShell execution policy set to "undefined" (= "Restricted"). AFAIK it has never run any PS scripts ever. I installed the test skin you posted and it ran perfectly.

Looks like you hit on the magic combination of switches to get scripts to run cleanly! ...Well, scripts that don't require some sort of permission or elevation, anyway. :thumbup:
Gadgets Wiki GitHub More Gadgets...
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Changing mouse sensitivity

Post by balala »

jsmorley wrote:Can someone who has not changed the security for PowerShell download and try this out?
Works perfectly for me.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing mouse sensitivity

Post by jsmorley »

balala wrote:Works perfectly for me.
Great, thanks!

Powershell has a lot of potential. It is quite robust and can do a lot of clever things. While it doesn't have the integration with Rainmeter that Lua has for us, it is sort like an "addon" written in AutoIt, but not requiring the creation and inclusion of a .exe executable file, which can give antivirus software fits.

I'll have to play with it, but I know it can do a lot of system level things using the WMI facilities of Windows, and can even download and parse websites and retrieve files. Be fun to explore a bit.

Ok, I'm releasing the hostage. Back to the original topic...
Unatomic
Posts: 33
Joined: October 23rd, 2012, 7:37 pm

Re: Changing mouse sensitivity

Post by Unatomic »

jsmorley wrote:Can someone who has not changed the security for PowerShell download and try this out?
Well the good thing is that PowerShellTest_1.0.rmskin runs perfectly on my machine too. (no problem with all that hijacking heheh :great: )

Now that we know we can get a return/get value from a .ps1 then I assume we can return and then set a value at the same time in a skin. Like getting the current mouse speed from the system and then sending/setting a new one +0.5 or -0.5 of the old one.

My assumption:

Code: Select all

LeftMouseUpAction=[(powershell command to get current mousespeed)][powershell -Command "#@#MouseSpeed.ps1 ; Set-MouseSpeed -Speed [&MeasureSpeed+0.5]"]
RightMouseUpAction=[(powershell command to get current mousespeed)][powershell -Command "#@#MouseSpeed.ps1 ; Set-MouseSpeed -Speed [&MeasureSpeed-0.5]"]