如何从 PowerShell 静音/取消静音 [英] How can I mute/unmute my sound from PowerShell

查看:48
本文介绍了如何从 PowerShell 静音/取消静音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试编写一个 PowerShell cmdlet,在开始时将声音静音,除非已经静音,并在最后取消静音(仅当它开始时没有静音).找不到我可以使用的任何 PoweShell 或 WMI 对象.我正在尝试使用 Win32 函数,例如 auxGetVolumeauxSetVolume,但无法完全达到工作(如何从 IntPtr 读取值?).

Trying to write a PowerShell cmdlet that will mute the sound at start, unless already muted, and un-mute it at the end (only if it wasn't muted to begin with). Couldn't find any PoweShell or WMI object I could use. I was toying with using Win32 functions like auxGetVolume or auxSetVolume, but couldn't quite get it to work (how to read the values from an IntPtr?).

我使用的是 V2 CTP2.大家有什么想法吗?

I'm using V2 CTP2. Any ideas folks?

谢谢!

推荐答案

似乎没有一种快速简便的调节音量的方法.如果你有 C++ 经验,你可以用 这个博客帖子,其中 Larry Osterman 描述了如何从平台 api 调用 IAudioEndpointVolume 接口(对于 Vista,根据我在几次搜索中发现的内容,XP 可能更困难).

There does not seem to be a quick and easy way to adjust the volume.. If you have c++ experience, you could do something with this blog post, where Larry Osterman describes how to call the IAudioEndpointVolume interface from the platform api(for Vista, XP might be more difficult from what I've found in a few searches).

V2 确实允许您编译内联代码(通过 Add-Type),因此这可能是一个选项.

V2 does allow you to compile inline code (via Add-Type), so that might be an option.

这篇关于如何从 PowerShell 静音/取消静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆