
This script is suitable for desktop application as the SendKeys method interacts with the desktop and sends the Key commands.

#region: Variables $date = Get-Date -Format d $time = Get-Date -Format t $logPath = 'C:\temp' $logFile = $logPath + '\popup_cleaner' + $date + '.log' $popupName = '' #endregion #region: Clean up old log files #Clean up log files older than 30 days $days = "-30" $currentDate = Get-Date $deleteTillDate = $currentDate.AddDays($days) Get-ChildItem $logPath | Where-Object #endregion You can also send any key stroke or a combination of Key strokes as per your requirement by following the SendKeys code. You have to notice the title of the popup window as you have to use that in the script. So, here is a model script that can be used to automatically clear those pop-up windows. Sounds old technique? But I think it still has several use cases. The macro throws some pop-ups and won’t proceed unless you clear them. Let’s assume MS Excel as the application here and you are running a macro. I created a simple PowerShell script and ran this in a regular interval to handle those pop-ups. I could not find any PowerShell cmdlet for this situation but I found the old Application.SendKeys VBA method still useful.
#Visual basic popup window windows#
I had to find some Windows native solution to tackle this situation. It is highly inconvenient for anyone to clear those pop-ups manually. This was impacting some automated functions of the application as the process was getting stopped with the pop-up.

I came across a situation where one of my applications was throwing a pop-up and expect someone to click ‘OK’ or ‘Cancel’ to proceed.
