使用当前用户名发送密钥

Send keys with current username

我正在尝试创建一个批处理文件,用于打开特定站点并输入用户名。

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

我想知道您是否可以使用 %USERNAME% 变量并转换它的每个字母并在浏览器输入中自动输入 window。

@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"

我确实设法通过以下代码完成了它:

@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));