次の perl スクリプトを実行しようとしたところ、ユーザー セッションがロックされました...
$n=15;
while($n>0)
{
print "$n,";
$n--;
sleep(1);
}
追加のコードなしで通常どおり機能しました...、次の秒の前にセッションをロックしたため、セッションをロックしたときに出力がありませんでした。セッションのロックを解除したときに表示される出力:
C:\Pradeep>perl test.pl
15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,
C:\Pradeep>
SetForegroundWindow($_); のような Win32::GuiTest 関数を使用してサーバーに接続するために使用する以下のスクリプトを実行すると、SendKeys("Password01"); など...問題なく接続され、サーバーへのログインに成功しました。しかし、実行中にセッションをロックし、セッションのロックを解除すると、スクリプトの実行は完了しましたが、サーバーへのログインは行われませんでした。
use Win32::GuiTest qw(FindWindowLike GetWindowText SetForegroundWindow SendKeys);
system('"start %windir%\system32\mstsc.exe"');
$Win32::GuiTest::debug = 0;
$max_Sleep_time=3;
$Cur_Sleep_time=0;
do
{
sleep(1);
@windows = FindWindowLike(0, "Remote Desktop Connection");
$number_of_windows_opend = scalar(@windows);
$Cur_Sleep_time++;
}while ($number_of_windows_opend==0&&$Cur_Sleep_time!=$max_Sleep_time);
for (@windows) {
SetForegroundWindow($_);
SendKeys("server_name");
SendKeys("{ENTER}");
sleep(10);
@windows_seq = FindWindowLike(0, "Windows Security");
for (@windows_seq) {
SetForegroundWindow($_);
SendKeys("Password01");
SendKeys("{ENTER}");
}
@windows={};
exit;
}
私によると、私は自分の機能を実行するためにアクティブなウィンドウを使用しました。したがって、機能していません。ユーザーセッションが実行プロセスの途中でロックされている場合、上記の機能を正常に実行できる他の方法はありますか? または、コードを変更する必要がありますか?