发送具有当前用户名的密钥

我正在尝试制作一个批处理文件,该文件将打开一个特定的站点并键入用户名。

目前我有以下代码,但问题是您必须自己输入用户名。

我想知道您是否可以使用%username%变量并将其转换为每个字母并在浏览器输入窗口中自动键入。

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


@echo off

rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
start chrome "https://servicedesk.sa.gov.ge/"
rem the script only works if the application in question is the active window. Set a timer to wait for it to load!
timeout /t 3
rem use the tab key to move the cursor to the login and password inputs. Most htmls interact nicely with the tab key being pressed to access quick links.

rem now you can have it send the actual username/password to input box
%SendKeys% "{s}"
%SendKeys% "{o}"
%SendKeys% "{m}"
%SendKeys% "{e}"
%SendKeys% "{u}"
%SendKeys% "{s}"
%SendKeys% "{e}"
%SendKeys% "{.}"
%SendKeys% "{s}"


goto :EOF


@end
// JScript section

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));

P.S。在我的情况下,用户名格式来自域,例如:“ otarashvili.e”

jjj0716 回答:发送具有当前用户名的密钥

我确实设法通过以下代码完成了该任务:

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


@echo off

rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
start chrome -new-window --incognito "https://servicedesk.sa.gov.ge/"
rem the script only works if the application in question is the active window. Set a timer to wait for it to load!
timeout /t 3
rem use the tab key to move the cursor to the login and password inputs. Most htmls interact nicely with the tab key being pressed to access quick links.

rem now you can have it send the actual username/password to input box
%SendKeys% "%USERNAME%"
%SendKeys% "{TAB}"

goto :EOF


@end
// JScript section

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
本文链接:https://www.f2er.com/2900468.html

大家都在问