Get-WindowTitle and Send-Keys

I have a service pack install for CADWorx2016 that I need to install. There is no silent install for it. I was hoping to use Get-WindowTitle and Send-Keys to work to in order to click next and ok after the install. I cannot find any similar scripts to see how it is used. I used to use a feature similar in Autoit called winwaitactive. Any help would be appreciative.

Hello,

im using similar way with IE Reset, where i didnt figure out how to check Delete Personal data,
so i’m calling reset function, and then send 3 keys to the window , it will tick what i want and click ok for reset, hope it helps.

Keys combination are here :
https://msdn.microsoft.com/en-us/library/aa266279(v=vs.60).aspx

Scipt part looks like this :

#call IE reset
Execute-Process -Path “C:\Windows\System32\RunDll32.exe” -Parameters “InetCpl.cpl,ResetIEtoDefaults” -NoWait
Start-Sleep -s 5
Send-Keys -WindowTitle ‘Reset Internet Explorer Settings’ -Key “%P”
Send-Keys -WindowTitle ‘Reset Internet Explorer Settings’ -Key “%r” -WaitSeconds 5
Send-Keys -WindowTitle ‘Reset Internet Explorer Settings’ -Key “%c”

What powershell code can be used to rename any window during and installation ?

  • i have an installer that uses the same window name for each of the 3 prompts that i am sending keys to.

  • Currently i am using the following to sendkeys to the windows that setup.exe prompts me with:

<code>[System.Reflection.Assembly]::LoadWithPartialName(&amp;quot;&#039;Microsoft.VisualBasic&amp;quot;)
$p=get-process | where {$_.name -eq &amp;quot;setup&amp;quot;}
[Microsoft.VisualBasic.Interaction]::AppActivate($p.ID)
[System.Windows.Forms.SendKeys]::SendWait(&amp;quot;{ENTER}&amp;quot;)</code>

What about something like this?

$p = (get-process -Name notepad).Id
$WTitle = (Get-WindowTitle -GetAllWindowTitles | Where-Object {$_.ParentProcessId -eq $p}).WindowTitle
Send-Keys -WindowTitle $WTitle -Keys ‘{ENTER}’

it didnt work at : $WTitle = (Get-WindowTitle -GetAllWindowTitles | Where-Object {$_.ParentProcessId -eq $p}).WindowTitle

keep getting boolean errors

Write-Log : Cannot process argument transformation on parameter ‘WriteHost’. Cannot convert value “” to type “System.Boolean”. Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 0.

  •     Write-Log -Message 'Function Start' -Source ${CmdletName} -DebugMessage
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:slight_smile: [Write-Log], ParameterBindingArgumentTransformationException
    • FullyQualifiedErrorId : ParameterArgumentTransformationError,Write-Log

Did you change the name of the process to setup or whatever window you are sending keys to?

yes … i used the following code:

<code>cls
$p = (get-process -Name setup).Id
$WTitle = (Get-WindowTitle -GetAllWindowTitles | Where-Object {$_.mainwindowtitle -eq $p}).WindowTitle #.ParentProcessId -eq $p}).WindowTitle  # -GetAllWindowTitles | Where-Object {$_.ParentProcessId -eq $p}).WindowTitle
$WTitle
Send-Keys -WindowTitle $WTitle -Keys &#039;%n&#039;</code>

Ineed to change the name of the window so i can wait for the new instance of the next window to occur (all windows seem to use the same parent window and i need to send keys once it is done installing and then prompts for more input. it uses the same original window name for all child windows which is why i need to change the name and wait for the new window to appear

Im currently using the following code to get the window name and id but not sure how to change the name of the window from here

<code># Get an Applications Process ID - the Application and its Processes can be found via the task manager
    $AppProcID = (Get-Process &#039;setup&#039;).id

# Get an Applications Window Process ID - the Application and its Processes can be found via the task manager
    $Window = (get-process | where {$_.mainwindowtitle -match $WindowNames[2]}).id # | format-table id, name, mainwindowtitle -autosize</code>

RECAP : i am trying to create a powershell script that will sendkeys to uninstall HaverAnalytics_DLX_4.x. The challenge and objective is to get the script to identify each child window of the uninstall, but the challenge is that they are all using the same Window name. To workaround this, i have decided to rename the windows as they appear so i can apply logic to the code to know which window\instance of the procedure requires specific sendkeys during the unisntall.