In my script when I have a messagebox open, the messagebox always opens in the background, behind all other applications and windows running. I am trying to do two things (I apologize if they should be two questions, but I think are closely related) 1. I want the message box to be show in the front of all applications when it needs presents, and 2. I want to change the focus to the 'okay' button on the messagebox.
First I load the messagebox $hide = [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
Then it opens when needed.
do
{
$attempt = LogIn #recieves true (see line 233 comments)
$bad++ #attempt = true
if ($bad -lt $allock -and $attempt -eq $false)
{
Messagebox -Message "Wrong Password" -BoxTitle "Error"
}
if ($bad -eq $allock -and $attempt -eq $false) #false, skip
{
Messagebox -Message "Five Tries, You are almost Locked out, Try again" -BoxTitle "Error"
}
if ($bad -eq $lockout-and $attempt -eq $false) #false, skip
{
Messagebox -Message "Six tries, you are probably locked out. Good Luck." -BoxTitle "Lockout?"
break
}
#attempt = true
} while ($attempt -ne $true) #true, exit
While there is a plethora of information on how to use messageboxes in powershell, I was unable to find any information on bringing the box to the front, and changing the focus to the enter button on the box. I would appreciate any guidance or pointers to information. Thank you.