locked
Show pop-up in first plane RRS feed

  • Question

  • Hi.

    I'm not a developer but I'm try write script on powershell.

    I inserted a popup code into my script and would like to force the pop-up window to the foreground in front of any window that is open to the user.
    Searching I found that there is a window control, but I could not implement it.

    How should I do?

    ### Option 1
    $MSG = "Option 1"
    $TITULO = "Title 1"
    $BOTOES = "OkCancel"
    $ICONE = "Warning"
    
    $Result_1 = [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms");[Windows.Forms.MessageBox]::show("$MSG", "$TITULO","$BOTOES","$ICONE","Button2")
    
    
    
    ### Option 2
    Add-Type -AssemblyName PresentationCore,PresentationFramework
    $MSG_2 = "Option 2"
    $TITULO_2 = "Title 2"
    $BOTOES_2 = [System.Windows.MessageBoxButton]::"OkCancel"
    $ICONE_2 = [System.Windows.MessageBoxImage]::"Information"
    
    $Result_2 = [System.Windows.MessageBox]::Show($MSG_2,$TITULO_2,$BOTOES_2,$ICONE_2)
    

    Thank you!


    Wednesday, August 30, 2017 9:12 PM

All replies

  • Only two lines can be used here:

    Add-Type -AssemblyName System.Windows.Forms
    [System.Windows.Forms.MessageBox]::Show('message','title','OkCancel','Information')

    You cannot make a message box topmost when run from a console application.  You will have to create a custom form that  can do that.


    \_(ツ)_/

    Wednesday, August 30, 2017 9:42 PM