Question afficher popup et continuer script directement

Plus d'informations
il y a 13 ans 1 mois #14008 par JayG
Bonjour à tous,
Je souhaiterai afficher un message à l'écran avant de lancer mon script de sauvegarde personnel.

Le problème des popups est qu'ils attendent l'intervention utilisateur sur un bouton affiché pour continuer l'exécution du script...

Moi je veux :
Affichage d'un message style popup (quelque chose de visible si possible, sinon dans une fenetre de commande)
L'utilisateur peut alors le masquer ou non (via la croix de la fenetre)
Pendant ce temps, mon script s'exécute
à la fin du script, si le popup est toujours ouvert, le fermer automatiquement.

Quelles sont les possibilités qui s'offrent à moi ?
d'avance merci ;)

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 13 ans 1 mois #14009 par Philippe
bonjour

sans savoir comment tu ouvre ton popup....

une idee : les jobs
[code:1]# pour ouvrir ton popup
start-job -name \"popup\" -script ton_script_qui ouvre_ton_popup.ps1

# pour ferme ton popup(ouvert ou non) en fin de script
remove-job -name \"popup\"[/code:1]

mais c'est de la bidouille pour script inconue

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 13 ans 1 mois #14011 par Laurent Dardenne
Salut,
le mieux serait du code C# voir WPF .
Pour le job comme ci dessous le jeux est de fermer la fenêtre :P
Un truc :
[code:1]
#region Import the Assemblies
[reflection.assembly]::loadwithpartialname(\"System.Windows.Forms\"«») | Out-Null
[reflection.assembly]::loadwithpartialname(\"System.Drawing\"«») | Out-Null
#endregion

#region Generated Form Objects
$FrmSplashScreen = New-Object System.Windows.Forms.Form
$panel1 = New-Object System.Windows.Forms.Panel
$pictureBox1 = New-Object System.Windows.Forms.PictureBox
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

#region Generated Form Code
$FrmSplashScreen.Text = \"Please wait...\"
$FrmSplashScreen.MaximizeBox = $False
$FrmSplashScreen.Name = \"FrmSplashScreen\"

#$FrmSplashScreen.DataBindings.DefaultDataSourceUpdateMode = 0
$FrmSplashScreen.MinimizeBox = $False
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 284
$System_Drawing_Size.Height = 262
$FrmSplashScreen.ClientSize = $System_Drawing_Size
#$FrmSplashScreen.Opacity = 0.8

$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 259
$System_Drawing_Size.Height = 237
$panel1.Size = $System_Drawing_Size

$panel1.TabIndex = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 13
$panel1.Location = $System_Drawing_Point
$panel1.DataBindings.DefaultDataSourceUpdateMode = 0
$panel1.Name = \"panel1\"

$FrmSplashScreen.Controls.Add($panel1)
$pictureBox1.Dock = 5
$pictureBox1.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 259
$System_Drawing_Size.Height = 237
$pictureBox1.Size = $System_Drawing_Size

$pictureBox1.Image = [System.Drawing.Image]::FromFile('C:\Windows\Web\Wallpaper\Nature\img3.jpg')
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 0
$System_Drawing_Point.Y = 0
$pictureBox1.Location = $System_Drawing_Point


$pictureBox1.TabStop = $False
$pictureBox1.Name = \"pictureBox1\"

$panel1.Controls.Add($pictureBox1)

#endregion Generated Form Code

#Save the initial state of the form
$InitialFormWindowState = $FrmSplashScreen.WindowState
#Init the OnLoad event to correct the initial state of the form
#$FrmSplashScreen.add_Load($OnLoadForm_StateCorrection)
$FrmSplashScreen.Add_Shown({$FrmSplashScreen.Activate()})
#Show the Form
$FrmSplashScreen.Show()

1..5|
Foreach {
$FrmSplashScreen.Refresh()
Write-host \"Fait le truc 1\";Sleep -Seconds 5
}

$FrmSplashScreen.Close()
$FrmSplashScreen.Dispose()
[/code:1]

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 13 ans 1 mois #14013 par JayG
<br><br>Message édité par: JayG, à: 19/02/13 19:03

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 13 ans 1 mois #14014 par JayG
@6ratgus :
[code:1]start-job -name \&quot;popup\&quot; -script popup.ps1[/code:1]
Me renvoit une erreur :

[code:1]Start-Job : Impossible de lier le paramètre « ScriptBlock ». Impossible de convertir la valeur « popup.ps1 » du type « System.String » en type « System.Management.Automation.ScriptBlock ».[/code:1]

En changeant le paramètre -script en -FilePath ca fonctionne ;)

[code:1]start-job -name \&quot;popup\&quot; -filePath popup.ps1[/code:1]

Mais comme l'a signalé Laurent Dardenne,
Pour fermer la fenêtre ça n'a pas l'air si simple (même en utilisant un -Force)

Dommage, cette solution avait l'air plutôt simple..

@Laurent Dardenne :
Merci, je vois qu'en plus tu avais déjà posté cette solution sur le forum, \&quot;la fonction recherche, c'est pas pour les canards...\&quot;
Ca correspond plutot bien à mes attentes, même si le code est ma foi assez complexe :)<br><br>Message édité par: JayG, à: 19/02/13 19:02

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 13 ans 1 mois #14015 par Philippe
ja ma suis trompa (c'est pas la forme en ce moment)
l'option est :
-FilePath pour un fichier script
-Script (ou ScriptBlock) correcpond a une suite de command placer entre accolades ( { } )

mais la proposition de laurent est plus 'propre', si ca correspond a ton idee !B)<br><br>Message édité par: 6ratgus, à: 19/02/13 19:31

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.073 secondes
Propulsé par Kunena