Is there any other way to send keystrokes in an application?
I have a Powershell script, after pressing the backtick key, the console should open in the application, but this does not happen, but pressing the keyboard physically, how it works fine.
After I open the console myself, sendkeys work, but the first sendkeys (backtick) do not work.
I need the script to open the console by sending the return line key.
function wait {
param([int]$stop = 8)
Start-Sleep -seconds $stop
}
[void] [System.Reflection.Assembly]::LoadWithPartialName("'Microsoft.VisualBasic")
& "$env:C:\Program Files (x86)\Steam\SteamApps\common\Half-Life\cstrike.exe"
$a = Get-Process | Where-Object {$_.Name -eq "Counter-strike"}
wait3
$Cursor = [system.windows.forms.cursor]::Clip
[System.Windows.Forms.Cursor]::Position = New-Object system.drawing.point(509,763)
wait
[System.Windows.Forms.SendKeys]::SendWait({"ENTER"})
wait
[System.Windows.Forms.SendKeys]::SendWait({"`"})
wait
[System.Windows.Forms.SendKeys]::SendWait("connect ")
wait
[System.Windows.Forms.SendKeys]::SendWait("192.168.1.1")
wait
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
source
share