打开对话框的命令

打开对话框的命令

这里运行的是 Windows 10 Pro。我使用一个简单的脚本作为我的 Windows 游戏控制器配置的快捷方式,但我总是必须手动导航到对话框中的“属性”按钮才能到达我真正想要到达的地方。第一张图片是快捷方式带我去的地方:

在此处输入图片描述

现在我想要去的地方是可以通过按“属性”按钮到达的下一个页面:

在此处输入图片描述

我想修改脚本,使其自动转到游戏控制器配置对话框的第二页。有没有办法修改脚本,甚至编写一个可以实现此目的的新脚本?这是 .vbs 脚本(由名为 Tileconfiy 的程序生成,允许将快捷方式固定到开始菜单):

Dim targetPath, targetArguments

targetPath = """C:\Windows\explorer.exe"""
targetArguments = "C:\Windows\System32\joy.cpl"

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.CurrentDirectory = "C:\Windows\System32\"
WshShell.Run targetPath & " " & targetArguments, 1
WshShell.AppActivate("joy.cpl")
WshShell.SendKeys("{TAB}")
WshShell.SendKeys("{ENTER}")

游戏配置打开正常,但 TAB 和 ENTER 部分未执行。我尝试了代码最后一部分的几种变体,包括以下内容:

WshShell.SendKeys("{TAB}")
WshShell.SendKeys("{ENTER}")

WshShell.SendKeys("{TAB}")
WshShell.SendKeys("{~}")

WScript.CreateObject("WScript.Shell").SendKeys("{TAB})";
WScript.CreateObject("WScript.Shell").SendKeys("~");

WScript.CreateObject("WScript.Shell").SendKeys("{TAB}";
WScript.CreateObject("WScript.Shell").SendKeys("ENTER");

但这些似乎都无法让它发挥作用。

答案1

' -------------------------------------------------------------------------------
'--- AUTOGENERATED BY TILEICONIFIER - DO NOT MANUALLY EDIT ---
'--------------------------------------------------------------------------------

'Custom Shortcut Type = "Explorer"
'Shortcut Name = "JOYSTICK WIn10"
'Shortcut Path = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\TileIconify\Custom Shortcuts\JOYSTICK WIn10_1\JOYSTICK WIn10.lnk"

Dim targetPath, targetArguments

targetPath = """C:\Windows\explorer.exe"""
targetArguments = "C:\Windows\System32\joy.cpl"

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.CurrentDirectory = "C:\Windows\"
WshShell.Run targetPath & " " & targetArguments, 1
WshShell.AppActivate("Game controllers")
Wscript.Sleep 2000
WshShell.SendKeys("{TAB}{TAB}{TAB}")
WshShell.SendKeys("{ENTER}")

首先打开游戏控制器对话框。然后激活窗口并单击属性按钮。

相关内容