jm33-m0 / win10-mouse-natural-scroll

Enable natural scrolling feature for a USB mouse under Windows 10/11
GNU General Public License v3.0
27 stars 6 forks source link

Can't append new results into the $mouse array #1

Closed cosmoswafer closed 2 years ago

cosmoswafer commented 2 years ago

I run the mouse-natural-scroll.ps1 script on my system and it prompts the following errors:

Method invocation failed because [Microsoft.Management.Infrastructure.CimInstance] does not contain a method named 'op_Addition'.
At C:\Users\gamer\Downloads\mouse-natural-scroll.ps1:4 char:1
+ $mouses += Get-CimInstance -ClassName Win32_PointingDevice | Where-Ob ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (op_Addition:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

I believe line 3 to be:

$mouses = @(Get-CimInstance -ClassName Win32_PointingDevice | Where-Object Name -Match "USB Input Device")

Seems you should declare the $mouses as an array if it only finds one result.

jm33-m0 commented 2 years ago

https://github.com/jm33-m0/win10-mouse-natural-scroll/commit/d85cce8f6af362aa67662417c7f8a5ec0521918f

I think the "win11" script works for Windows 10 as well, consider the old script deprecated

cosmoswafer commented 2 years ago

I see. It works now. Thanks!