開啟對話框的命令

開啟對話框的命令

此處運行 Windows 10 專業版。我使用一個簡單的腳本作為 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}")

首先,它打開遊戲控制器對話框。然後啟動視窗並點擊“屬性”按鈕。

相關內容