如何自动切换硬件图形加速?
我的笔记本电脑(可能)损坏了显卡内存,并导致一些奇怪的错误,例如屏幕上出现彩色点、光标上下跳动以及偶尔冻结。我注意到当我关闭 Windows 中的硬件加速时,问题就消失了。每当我想播放电影时,除非重新激活硬件加速,否则画面就会出现块状。
手动执行此操作很烦人,并且需要一些时间,因此我想制作一个小程序来自动执行在所有显示器上禁用或启用硬件加速的过程(相当于将滑块一直移动到留在屏幕设置中)。我以前没有 Windows 编程经验,所以如果有人至少能指出我正确的方向,我将不胜感激。
我是个小气鬼,买一台新电脑不是一个选择,因为这台电脑运行得很好,而我禁用了硬件加速。
编辑:在我的例子中,加速级别存储在注册表项
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Video{85D18855-5163-4CFC-8A71-222DCC03C001}\0000
"Acceleration.Level"=dword 中:00000005
默认情况下该键不存在,删除它并更改颜色深度开关硬件加速重新开启。
My laptop computer has (probably) corrupted graphics card memory and it causes some bizarre errors such as colorful dots appearing all over the screen, cursor jumping up and down and freezing occasionally. I noticed that the problems go away when I turn off HW acceleration in Windows. Whenever I want to play a movie, the picture is blocky unless I reactivate HW acceleration.
Doing this manually is annoying and it takes some time so I would like to make a little program to automate the process of disabling or enabling HW acceleration on all displays (equivalent to moving the slider all the way to the left in screen settings). I have no previous experience with programming for Windows so I will appreciate if someone can at least point me in the right direction.
I am a cheapskate, buying a new computer is not an option since this one works quite well while I keep HW acceleration disabled.
Edit: The acceleration level is in my case stored in the registry key
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Video{85D18855-5163-4CFC-8A71-222DCC03C001}\0000
"Acceleration.Level"=dword:00000005
The key is not there by default, deleting it and changing color depth switches HW acceleration back on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
旁注:可能会出现严重问题...
这些错误表明您的显卡出现问题,如果您不处理,您的显卡将继续下降到以下程度:你甚至不能再使用你的电脑了。
我也很不明白为什么你不能使用带有硬件加速的计算机,而你可以很好地观看视频,也许你可以考虑关闭 DWM(如果你正在使用它),因为这可能是罪魁祸首软件,不再需要您关闭硬件加速。
然而,这本质上是一个硬件问题,因此您可能计划至少升级您的显卡;或者至少留出一些预算,以防它迟早失败...
如何实现自动化...
您应该能够使用 AutoIt。
在文档中,您会找到有关基本内容的教程。前三个应该足以理解如何响应 Window 事件。
然后,只需创建一个
WHILE
循环,在该循环中等待窗口处于活动状态,然后启用硬件加速,然后等待窗口处于非活动状态,然后禁用硬件加速;之后循环重复。这样,每当您观看视频时,它都会加速,否则不会。如果您完成了安装教程,您可以轻松自动执行打开和关闭硬件加速的操作,可能需要为
SendKeys
提供 Tab 才能获得到滑块。之后,您可以发送向左或向右箭头(也许几次?)以将其滑动到正确的方向。由于我认为您指的是显卡的硬件加速功能,因此我无法为您编写此内容,因为我没有您的显卡,并且在大多数情况下甚至没有其驱动程序。
A side note: Serious problems might be developing...
These errors are a sign that there is something wrong with your graphics card and if you don't handle the chance is very high that your Graphics Card will continue to decline to the point where you can't even use your computer anymore.
I'm also pretty clueless why you aren't able to use your computer with HW acceleration while you can watch a video just fine, perhaps you could consider turning off DWM if you are using it as that could be the culprit sofware-wise and doesn't need you to turn HW acceleration off anymore.
However, this is essence a hardware problem so you might plan on upgrading at least your Graphics Card; or at least keep some budget aside for it, in case it decides to fail sooner or later...
How one automates it anyway...
You should be able to get around with AutoIt.
In the Documentation, you'll find tutorials on basic things. The first three should suffice to understand how to respond to Window events.
Then, it's just a matter of making a
WHILE
loop in which you wait for the window to be active, then enable HW acceleration, then wait for the window to be inactive, then disable HW acceleration; after which the loop repeats. That way, whenever you watch a video it's accelerated and otherwise it is not.If you did the installation tutorial, you can easily automatically perform the actions to turn the HW acceleration on and off, it might be required to provide Tab to
SendKeys
in order to get to the slider. After which you can probably send a left or right arrow (perhaps a few times?) to slide it in the right direction.As I'm thinking that you are referring to the HW acceleration feature of your graphics card, I can't write this for you as I don't have your graphics card and in the most cases don't even have its drivers.