1

特定のサイトを開いてユーザー名を入力するバッチ ファイルを作成しようとしています。

現時点では次のコードがありますが、問題はユーザー名を自分で入力する必要があることです。

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

私の場合のPSユーザー名の形式は、ドメインから取得されます。たとえば、「otarashvili.e」です。

4

1 に答える 1