Reputation: 205
Is there a way in powershell to listen for message prompts produced by software that will terminate the message prompt?
For instance, if I am using an application and then it prompts a message for the user to click "OK". IS there a way I can use PowerShell to find that "window title" to kill that prompt?
Upvotes: 1
Views: 5002
Reputation: 61
You can use this two commands:
$TitleToKill = "CMD"
get-process | where-object {$_.MainWindowTitle -eq $TitleToKill} | stop-process
Upvotes: 6
Reputation: 205
I decided to go with AutoIt.
I noticed AutoIt has an AutoIt Window Info tool that you can hover you mouse over the Message Prompt. Then the Window Info will give you the Windows Title, Text and CLASS ID if it has one.
Then you can write a simple autoit script that will Wait for the message prompt and close it.
Example Script that I'm using.
WinWait("[CLASS:#32770]", "Cannot sign in to Lync because this sign-in address was not found. Please verify the sign-in address and try again. If the problem continues, please contact your support team.", 0)
WinClose( "Lync")
WinWait will wait for the prompt with that specific message and close it. Once it performs the action and closes the window. The EXE will shutdown and stop running, of course unless you program it not to close and loop.
Upvotes: 1