gpt4 book ai didi

vba - 如何在 Windows 上自动切换飞行模式

转载 作者:行者123 更新时间:2023-12-02 04:30:44 25 4
gpt4 key购买 nike

在我的笔记本电脑上,我可以通过按 FN+F12 手动切换飞行模式,我想从 VB6 项目或 VBA 自动执行相同的操作。

我进行了大量搜索,只找到了有关启用/禁用无线适配器或使用 Windows 8 的 Sendkeys 的答案:

Dim WSh As Object
Set WSh = CreateObject("Wscript.Shell")
WSh.Run "C:\WINDOWS\system32\rundll32.exe %SystemRoot%\system32\van.dll,RunVAN", , True
Sleep 200
WSh.SendKeys " "
Sleep 1000
WSh.SendKeys "{ESC}"

但是这段代码并不可靠,我认为它不适用于 Windows 7 或 Windows 10。

所以我的问题是:有没有可靠的方法可以在 Windows 上自动切换飞行模式。

最佳答案

我的键盘上没有功能键,这还没有经过测试,只是一个想法 - 你为什么不尝试这样:

Sub SetMode()

CreateObject("Shell.Application").MinimizeAll
Application.SendKeys "{F12}" 'Try a way to refer the function key

End Sub

另一个可能的选项是这样的,具体取决于您的 Windows:

Option Explicit

Public Sub TestMe()

Application.SendKeys ("^{ESC}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("{s}")
SendKeys ("{e}")
SendKeys ("{t}")
SendKeys ("{t}")
SendKeys ("{i}")
SendKeys ("{n}")
SendKeys ("{g}")
SendKeys ("{s}")
SendKeys "~", False
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("{a}")
SendKeys ("{i}")
SendKeys ("{r}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys "~", False
Application.Wait Now + TimeValue("00:00:01")
SendKeys "~", False

End Sub

~ 符号用于 ENTER,ctrl+escape 模拟键盘上的 windows 键。到达所需内容后,您可以使用选项卡和箭头进行导航。

关于vba - 如何在 Windows 上自动切换飞行模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42090800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com