Is there another way to send keystrokes to an application?
I have this Powershell script, after pressing the backtick key a console should open in the application but this doesn't happen, but pressing the keyboard the phisical way it works perfectly.
After I open the console by myself the sendkeys do work but the first sendkeys (backtick) doesn't work.
What i need is that the script opens the console by sending the backtick key.
# startpwsscrip.ps1
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}")