«

华为电脑管家提示已连接多台显示设备

学长 发布于 阅读:3127 matepad pro


三种方法:

方法一:可以先把设备移除(其他显示器拔下来)

方法二:多显卡的可以禁用外接显示器设备的显卡

方法三:先win+i的设置中点击显示>高级显示 选择从桌面删除 开

然后再在设备管理器中禁用对应的即插即用显示器

(貌似微软整了两套设备管理器的方案。。。必须两边同时禁止华为电脑管家才会认为没接入显示器)

在华为设备连接成功后可连接其他显示器

非华为电脑也可以安装最新的华为电脑管家

然后就可以把华为平板作为电脑的第二(三)块屏幕啦


powershell

获取显示器列表

Get-PnpDevice -class Monitor

最关键的InstanceId不全。。。所以还得加个管道符专门拿这个属性

Get-PnpDevice -class Monitor |Select-Object -Property InstanceId

一般是第一个出来的ID

禁止掉

Disable-PnpDevice  -InstanceId "这个ID"

Disable-PnpDevice -InstanceId @((Get-PnpDevice -class Monitor).InstanceId[0])

加引号因为这个ID带&这样的特殊字符

开启

Enable-PnpDevice  -InstanceId "这个ID"

Enable-PnpDevice -InstanceId @((Get-PnpDevice -class Monitor).InstanceId[0])


总结写成bat。。。另外bat创建个快捷方式然后右击属性加个管理员权限




@echo off
CHCP 936>nul
set /p a=1.关闭 2.开启
if %a%==2 goto on
powershell -c Disable-PnpDevice -InstanceId @((Get-PnpDevice -class Monitor).InstanceId[0])
:on

powershell -c Enable-PnpDevice -InstanceId @((Get-PnpDevice -class Monitor).InstanceId[0])




目前看来不需要在重启显示器。。。不知道这是不是windows 11的bug

更多的显示器的情况下估计内屏永远是第一个显示器那么用select-object 去除最后一个的功能来实现


@echo off
CHCP 936>nul
set /p a=1.关闭 2.开启
if %a%==2 goto on
powershell -c Disable-PnpDevice -InstanceId @((Get-PnpDevice -class Monitor).InstanceId ^| Select-Object -SkipLast 1)
:on
powershell -c Enable-PnpDevice -InstanceId @((Get-PnpDevice -class Monitor).InstanceId ^| Select-Object -SkipLast 1)



复制到电脑不碍事的地方保存为“真·多屏协同.bat”编码最好使用ANSI因为有中文

然后把保存的文件复制快捷方式到桌面,然后设置快捷方式的图标还有高级选择管理员运行


ref: https://stackoverflow.com/questions/60021489/how-to-use-get-pnpdevice-to-get-instanceid-of-a-device

https://stackoverflow.com/questions/36428949/whats-the-equivalent-of-xargs-in-powershell

=================================================================

插着显示器重启后。。。主显示器又变成外屏了。。。

https://devblogs.microsoft.com/scripting/use-powershell-to-discover-multi-monitor-information/

https://community.spiceworks.com/topic/658220-get-monitor-manufacturer-model-and-serial-number

提到使用Get-WmiObject WmiMonitorID -Namespace root\wmi

来进行显示器的获取。。。

但是具体怎么set wmi或者通过wmi获得谁是主显示器还不得而知

使用上述的bat最起码可以禁止到最后一个显示器。。。当然可以调skip。。。

最简单就是使用上述代码先禁止然后再开起。。。

=================================================================

现在知道华为要限制第二个屏幕接入因为需要对应触屏输入。。。

因为是移动设备,华为平板作为显示器基本上是最后一个添加到电脑上作为显示器

但是触屏和笔默认考虑对应的是第二个显示器。。。

通过对Get-PnpDevice -class Monitor >输出的前后两个文件做对比。。。

找不到对应的触摸板输入硬件。。。

所以问题就变成了怎么强制让最后一个接入的显示器变成第二个显示器的问题了。。。

Get-WmiObject Win32_DesktopMonitor | Select *

呃。。。看来只能手动禁止对应的显卡造成显示器断开连接完华为扩展屏幕才可以了


@echo off
CHCP 936>nul
set /p a=1.关闭 2.开启
if %a%==2 goto on
powershell -c Disable-PnpDevice -InstanceId ((Get-WmiObject Win32_DesktopMonitor).PNPDeviceID ^| Select-Object -Skip 1)
:on
powershell -c Enable-PnpDevice -InstanceId ((Get-WmiObject Win32_DesktopMonitor).PNPDeviceID ^| Select-Object -Skip 1)


因为不是只是禁用显示器,只有镜像是成功对应触屏的,扩展还是默认会把触屏对应到第二块屏幕上。。。

在桌面右击--显示设置---选中除第一个显示器还有华为平板对应的显示器断开然后重新扩展,就可以把触屏映射回到华为平板对应的显示器上了


还有个问题就是显示器亮度在添加删除显示器的时候会变得最亮。。。

https://docs.microsoft.com/en-us/windows/win32/wmicoreprov/wmimonitorbrightness

调高再调低就恢复了

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-wmiobject?view=powershell-5.1

https://devblogs.microsoft.com/scripting/use-powershell-to-report-and-set-monitor-brightness/

https://docs.microsoft.com/en-us/windows/win32/wmicoreprov/wmisetbrightness-method-in-class-wmimonitorbrightnessmethods

范例:

$brightness = 50
$delay = 5
$myMonitor = Get-WmiObject -Namespace root\wmi -Class WmiMonitorBrightnessMethods
$myMonitor.wmisetbrightness($delay, $brightness)
缩写下

(Get-WmiObject -ns root/wmi -class wmiMonitorBrightNessMethods).WmiSetBrightness(5,50)

最终设置回原来的亮度

(Get-WmiObject -ns root/wmi -class wmiMonitorBrightNessMethods).WmiSetBrightness(5,((Get-WmiObject -Namespace root/WMI -ClassName WmiMonitorBrightness).CurrentBrightness+1))

(Get-WmiObject -ns root/wmi -class wmiMonitorBrightNessMethods).WmiSetBrightness(5,((Get-WmiObject -Namespace root/WMI -ClassName WmiMonitorBrightness).CurrentBrightness-1))



@echo off
CHCP 936>nul
powershell -c Get-WmiObject Win32_DesktopMonitor ^| select DeviceID,Status,PNPDeviceID
powershell -c Disable-PnpDevice -InstanceId ((Get-WmiObject Win32_DesktopMonitor).PNPDeviceID ^| Select-Object -Skip 1)
echo.
echo 可以连接多屏协同了
echo 扩展模式还得去高级显示设置打开从桌面删除再关闭
start ms-settings:display
::还得加个“阻止windows使用此显示器”功能,目前没找到
set a=n
set /p a=是否恢复?y/n:
if %a%==n goto END
powershell -c Enable-PnpDevice -InstanceId ((Get-WmiObject Win32_DesktopMonitor).PNPDeviceID ^| Select-Object -Skip 1)
:END
powershell -c (Get-WmiObject -ns root/wmi -class wmiMonitorBrightNessMethods).WmiSetBrightness(5,((Get-WmiObject -Namespace root/WMI -ClassName WmiMonitorBrightness).CurrentBrightness+1))
echo 亮度恢复中
powershell -c (Get-WmiObject -ns root/wmi -class wmiMonitorBrightNessMethods).WmiSetBrightness(5,((Get-WmiObject -Namespace root/WMI -ClassName WmiMonitorBrightness).CurrentBrightness-1))
pause



推荐阅读:


扫描二维码,在手机上阅读