gemini フロントに自動入力を試みる
PowerShellでの実験
実行を簡略化する為、
■D&DのPS1ファイルを実行する.bat
@echo off
if exist %1 goto filedrop
goto exit
:filedrop
cd %~p1
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy RemoteSigned -File %~nx1
echo PowerShell終了します。
timeout /t 5
:exit
を用意する。
■list1.txt
360度パノラマ画像を作って。 Deep focus, 高精細で頼む。夕焼けの近未来都市。
も用意する。
空のCromeを立ち上げてから、
gemini--test1.ps1 を実行。 最後に立ち上げたCromeの隣に新しくGeminiが展開され、文字入力が一文字ずつ実行される。
■gemini--test1.ps1
#
add-type -AssemblyName System.Windows.Forms
$filePath = "$env:USERPROFILE\Desktop\test1\list1.txt"
#$content = Get-Content -Path $filePath -Raw
$content = Get-Content -Path $filePath -Encoding utf8
# 起動
Start-Process "chrome.exe" -ArgumentList "--start-fullscreen", "https://gemini.google.com/app?hl=ja"
# 5秒待ち
Start-Sleep -m (Get-Random -Minimum 5000 -Maximum 5100)
#TABキー送信
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
# 2秒待ち
Start-Sleep -m (Get-Random -Minimum 2000 -Maximum 2100)
#SHIFT+TABキー送信(TABと逆順) SHIFTは+CTRLは^Altは%
[System.Windows.Forms.SendKeys]::SendWait("+{TAB}")
# 2秒待ち
Start-Sleep -m (Get-Random -Minimum 2000 -Maximum 2100)
$content.ToCharArray() | ForEach-Object {
$char = $_.ToString()
# SendKeysで特殊な意味を持つ文字({ } [ ] ( ) + ^ % ~)の対策
# そのまま送るとエラーになるため {} で囲む
if ("+^%~{}[]()".Contains($char)) {
[System.Windows.Forms.SendKeys]::SendWait("{$char}")
} else {
[System.Windows.Forms.SendKeys]::SendWait($char)
}
# 5. 待ち時間(50ミリ秒 = 0.05秒)
# タイピングしているような演出&入力漏れ防止
Start-Sleep -Milliseconds (Get-Random -Minimum 80 -Maximum 380)
}
#ENTERキー送信 注文決定
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
# 30秒待ち
Start-Sleep -m (Get-Random -Minimum 30000 -Maximum 31000)
#SHIFT+TAB5回
for ($i = 0; $i -lt 5; $i++) {
[System.Windows.Forms.SendKeys]::SendWait("+{TAB}")
Start-Sleep -Milliseconds (Get-Random -Minimum 80 -Maximum 380)
}
#ENTERキー送信 ダウンロード決定
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
# 10秒待ち
Start-Sleep -m (Get-Random -Minimum 10000 -Maximum 10100)
#TAB5回
for ($i = 0; $i -lt 5; $i++) {
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
Start-Sleep -Milliseconds (Get-Random -Minimum 80 -Maximum 380)
}
# ウィンドウを閉じる
#[System.Windows.Forms.SendKeys]::SendWait("%{F4}")