来自混合Batch-VBScript文件中的发送密钥

问题描述 投票:0回答:2

我不知道我在做什么错。

[在以下脚本中签出,我打算通过SendKeys方法在其中切换蓝牙功能设置:

@if (@CodeSection == @Batch) @then

@echo off

set SendKeys=CScript //nologo //E:JScript "%~F0"

start "" /b explorer.exe ms-settings:bluetooth

%SendKeys% "{TAB}" & %SendKeys% " "

goto :EOF

@end

// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.AppActivate "settings":WScript.Sleep 300
WshShell.SendKeys(WScript.Arguments(0));

它不执行击键,只是打开“蓝牙设置”窗口并保持原样。

感谢您的任何帮助。

batch-file vbscript bluetooth settings sendkeys
2个回答
0
投票

因此,请尝试此代码:

<!-- : || @cls & @echo off && mode 50,03 && title <nul && title .\%~nx0 && explorer.exe ms-settings:bluetooth
%__APPDIR__%wScript.exe "%~dpnx0?.wsf" && 2>nul >nul %__APPDIR__%taskkill.exe /FI "WindowTitle eq settings*"
goto :EOF & rem :: --> <job> <script language = "vbscript">
WScript.CreateObject("WScript.Shell").AppActivate "settings"
WScript.Sleep 500: WScript.CreateObject("WScript.Shell").SendKeys "{ESCAPE}"
WScript.CreateObject("WScript.Shell").SendKeys "{TAB}"
WScript.CreateObject("WScript.Shell").SendKeys " "
WScript.Sleep 333 </script></job>


0
投票
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "ms-settings:bluetooth"
WScript.Sleep 1000
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WScript.Sleep 100
WshShell.SendKeys "%{F4}"

注意:我遵守该规则清单。我的程序很简单,而不是不必要的复杂,间接和以错误的方式进行操作。

© www.soinside.com 2019 - 2024. All rights reserved.