Question
[RESOLU]PowerShell Boutons radio
- David
- Auteur du sujet
- Hors Ligne
- Membre junior
-
Réduire
Plus d'informations
- Messages : 31
- Remerciements reçus 0
il y a 10 ans 10 mois #20365
par David
[RESOLU]PowerShell Boutons radio a été créé par David
Bonjour,
Vous pourriez me dire ou je me suis planté svp ?
Je devrais avoir une fenêtre qui s'ouvre avec 3 boutons radio et ok et annuler en bas
Mais chez moi rien ne se lance du tout :
[code:1]# Introduction to Radio buttons and Grouping #
##############################################
# A function to create the form
function Ghost32{
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Set the size of your form
$Form = New-Object System.Windows.Forms.Form
$Form.width = 500
$Form.height = 300
$Form.Text = ”Choix du ghost à descendre\"
# Set the font of the text to be used within the form
$Font = New-Object System.Drawing.Font(\"Times New Roman\",12)
$Form.Font = $Font
# Create a group that will contain your radio buttons
$MyGroupBox = New-Object System.Windows.Forms.GroupBox
$MyGroupBox.Location = \"40,30\"
$MyGroupBox.size = \"400,150\"
$MyGroupBox.text = \"Quelle image souhaitez vous descendre?\"
# Create the collection of radio buttons
$RadioButton1 = New-Object System.Windows.Forms.RadioButton
$RadioButton1.Location = '20,40'
$RadioButton1.size = \"350,20\"
$RadioButton1.Text = \"HP6005\"
$RadioButton2 = New-Object System.Windows.Forms.RadioButton
$RadioButton2.Location = \"20,70\"
$RadioButton2.size = \"350,20\"
$RadioButton2.Text = \"HP6305\"
$RadioButton3 = New-Object System.Windows.Forms.RadioButton
$RadioButton3.Location = \"20,100\"
$RadioButton3.size = \"350,20\"
$RadioButton3.Text = \"Quitter\"
# Add an OK button
$OKButton = new-object System.Windows.Forms.Button
$OKButton.Location = \"130,200\"
$OKButton.Size = \"100,40\"
$OKButton.Text = \"OK\"
$OKButton.DialogResult=[System.Windows.Forms.DialogResult]::OK
#Add a cancel button
$CancelButton = new-object System.Windows.Forms.Button
$CancelButton.Location = \"255,200\"
$CancelButton.Size = \"100,40\"
$CancelButton.Text = \"Cancel\"
$CancelButton.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
# Add all the Form controls on one line
$form.Controls.AddRange(@($MyGroupBox,$OKButton,$CancelButton))
# Add all the GroupBox controls on one line
$MyGroupBox.Controls.AddRange(@($Radiobutton1,$RadioButton2,$RadioButton3))
# Activate the form
$form.Add_Shown({$form.Activate()})
# Get the results from the button click
$dialogResult = $form.ShowDialog()
# If the OK button is selected
if ($dialogResult -eq \"OK\"«»){
# Check the current state of each radio button and respond accordingly
if ($RadioButton1){
$Script:command = \"X:\Windows\System32\Cmd.exe /c start X:\Ghost32\ghost32.exe -clone, mode=restore, src=E:\Image\HP6005.gho, dst=1 /k\"}
elseif ($RadioButton2){
$Script:command = \"X:\Windows\System32\Cmd.exe /c start X:\Ghost32\ghost32.exe -clone, mode=restore, src=E:\Image\HP6305.gho, dst=1 /k\"}
elseif ($RadioButton3){$objGhost32.Close()}
}
}[/code:1]
Merci pour votre aide precieuse !!
Message édité par: goro, à: 4/07/15 00:39
Message édité par: goro, à: 4/07/15 00:41
Message édité par: goro, à: 4/07/15 00:43<br><br>Message édité par: goro, à: 4/07/15 22:59
Vous pourriez me dire ou je me suis planté svp ?
Je devrais avoir une fenêtre qui s'ouvre avec 3 boutons radio et ok et annuler en bas
Mais chez moi rien ne se lance du tout :
[code:1]# Introduction to Radio buttons and Grouping #
##############################################
# A function to create the form
function Ghost32{
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Set the size of your form
$Form = New-Object System.Windows.Forms.Form
$Form.width = 500
$Form.height = 300
$Form.Text = ”Choix du ghost à descendre\"
# Set the font of the text to be used within the form
$Font = New-Object System.Drawing.Font(\"Times New Roman\",12)
$Form.Font = $Font
# Create a group that will contain your radio buttons
$MyGroupBox = New-Object System.Windows.Forms.GroupBox
$MyGroupBox.Location = \"40,30\"
$MyGroupBox.size = \"400,150\"
$MyGroupBox.text = \"Quelle image souhaitez vous descendre?\"
# Create the collection of radio buttons
$RadioButton1 = New-Object System.Windows.Forms.RadioButton
$RadioButton1.Location = '20,40'
$RadioButton1.size = \"350,20\"
$RadioButton1.Text = \"HP6005\"
$RadioButton2 = New-Object System.Windows.Forms.RadioButton
$RadioButton2.Location = \"20,70\"
$RadioButton2.size = \"350,20\"
$RadioButton2.Text = \"HP6305\"
$RadioButton3 = New-Object System.Windows.Forms.RadioButton
$RadioButton3.Location = \"20,100\"
$RadioButton3.size = \"350,20\"
$RadioButton3.Text = \"Quitter\"
# Add an OK button
$OKButton = new-object System.Windows.Forms.Button
$OKButton.Location = \"130,200\"
$OKButton.Size = \"100,40\"
$OKButton.Text = \"OK\"
$OKButton.DialogResult=[System.Windows.Forms.DialogResult]::OK
#Add a cancel button
$CancelButton = new-object System.Windows.Forms.Button
$CancelButton.Location = \"255,200\"
$CancelButton.Size = \"100,40\"
$CancelButton.Text = \"Cancel\"
$CancelButton.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
# Add all the Form controls on one line
$form.Controls.AddRange(@($MyGroupBox,$OKButton,$CancelButton))
# Add all the GroupBox controls on one line
$MyGroupBox.Controls.AddRange(@($Radiobutton1,$RadioButton2,$RadioButton3))
# Activate the form
$form.Add_Shown({$form.Activate()})
# Get the results from the button click
$dialogResult = $form.ShowDialog()
# If the OK button is selected
if ($dialogResult -eq \"OK\"«»){
# Check the current state of each radio button and respond accordingly
if ($RadioButton1){
$Script:command = \"X:\Windows\System32\Cmd.exe /c start X:\Ghost32\ghost32.exe -clone, mode=restore, src=E:\Image\HP6005.gho, dst=1 /k\"}
elseif ($RadioButton2){
$Script:command = \"X:\Windows\System32\Cmd.exe /c start X:\Ghost32\ghost32.exe -clone, mode=restore, src=E:\Image\HP6305.gho, dst=1 /k\"}
elseif ($RadioButton3){$objGhost32.Close()}
}
}[/code:1]
Merci pour votre aide precieuse !!
Message édité par: goro, à: 4/07/15 00:39
Message édité par: goro, à: 4/07/15 00:41
Message édité par: goro, à: 4/07/15 00:43<br><br>Message édité par: goro, à: 4/07/15 22:59
Connexion ou Créer un compte pour participer à la conversation.
- David
- Auteur du sujet
- Hors Ligne
- Membre junior
-
Réduire
Plus d'informations
- Messages : 31
- Remerciements reçus 0
il y a 10 ans 10 mois #20366
par David
Réponse de David sur le sujet Re:PowerShell Boutons radio
Alors je viens de trouver pourquoi ma form ne se lance pas :
J'ai oublie la fonction d'appel en fin de script :
[code:1]# Call the function
Ghost32[/code:1]
Ce qui nous donne après quelques modifications :
[code:1]# Introduction to Radio buttons and Grouping #
##############################################
# A function to create the form
function Ghost32{
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Set the size of your form
$Form = New-Object System.Windows.Forms.Form
$Form.width = 500
$Form.height = 300
$Form.Text = ”Choix du ghost à descendre\"
# Set the font of the text to be used within the form
$Font = New-Object System.Drawing.Font(\"Times New Roman\",12)
$Form.Font = $Font
# Create a group that will contain your radio buttons
$MyGroupBox = New-Object System.Windows.Forms.GroupBox
$MyGroupBox.Location = \"40,30\"
$MyGroupBox.size = \"400,150\"
$MyGroupBox.text = \"Quelle image souhaitez vous descendre?\"
# Create the collection of radio buttons
$RadioButton1 = New-Object System.Windows.Forms.RadioButton
$RadioButton1.Location = '20,40'
$RadioButton1.size = \"350,20\"
$radiobutton1.Checked = $true
$RadioButton1.Text = \"HP 6005\"
$RadioButton2 = New-Object System.Windows.Forms.RadioButton
$RadioButton2.Location = \"20,70\"
$RadioButton2.size = \"350,20\"
$radiobutton1.Checked = $false
$RadioButton2.Text = \"HP 6305\"
# Add an OK button
$OKButton = new-object System.Windows.Forms.Button
$OKButton.Location = \"130,200\"
$OKButton.Size = \"100,40\"
$OKButton.Text = \"OK\"
$OKButton.DialogResult=[System.Windows.Forms.DialogResult]::OK
#Add a cancel button
$CancelButton = new-object System.Windows.Forms.Button
$CancelButton.Location = \"255,200\"
$CancelButton.Size = \"100,40\"
$CancelButton.Text = \"Cancel\"
$CancelButton.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
# Add all the Form controls on one line
$form.Controls.AddRange(@($MyGroupBox,$OKButton,$CancelButton))
# Add all the GroupBox controls on one line
$MyGroupBox.Controls.AddRange(@($Radiobutton1,$RadioButton2))
# Activate the form
$form.Add_Shown({$form.Activate()})
# Get the results from the button click
$dialogResult = $form.ShowDialog()
# If the OK button is selected
if ($dialogResult -eq \"OK\"«»){
# Check the current state of each radio button and respond accordingly
if ($RadioButton1){
$Script:command = \"C:\Windows\System32\cmd.exe /C start E:\WinPE-Plugin\Apps\x86\Ghost32\ghost32.exe /clone /mode=restore /src=E:\WinPE-Plugin\Images\HP6005sevensp1.gho /dst=1\"}
elseif ($RadioButton2){
$Script:command = \"E:\WinPE-Plugin\Apps\x86\Ghost32\ghost32.exe -clone, -mode=restore, -src=E:\WinPE-Plugin\Images\HP6005seven sp1.gho, -dst=1\"}
}
}
# Call the function
Ghost32[/code:1]
Maintenant je bute sur les actions des radiobuttons, il ne lancent pas ma cmd
Vous avez une idée ? Je continue à chercher de mon côté !
Merci d'avance
J'ai oublie la fonction d'appel en fin de script :
[code:1]# Call the function
Ghost32[/code:1]
Ce qui nous donne après quelques modifications :
[code:1]# Introduction to Radio buttons and Grouping #
##############################################
# A function to create the form
function Ghost32{
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Set the size of your form
$Form = New-Object System.Windows.Forms.Form
$Form.width = 500
$Form.height = 300
$Form.Text = ”Choix du ghost à descendre\"
# Set the font of the text to be used within the form
$Font = New-Object System.Drawing.Font(\"Times New Roman\",12)
$Form.Font = $Font
# Create a group that will contain your radio buttons
$MyGroupBox = New-Object System.Windows.Forms.GroupBox
$MyGroupBox.Location = \"40,30\"
$MyGroupBox.size = \"400,150\"
$MyGroupBox.text = \"Quelle image souhaitez vous descendre?\"
# Create the collection of radio buttons
$RadioButton1 = New-Object System.Windows.Forms.RadioButton
$RadioButton1.Location = '20,40'
$RadioButton1.size = \"350,20\"
$radiobutton1.Checked = $true
$RadioButton1.Text = \"HP 6005\"
$RadioButton2 = New-Object System.Windows.Forms.RadioButton
$RadioButton2.Location = \"20,70\"
$RadioButton2.size = \"350,20\"
$radiobutton1.Checked = $false
$RadioButton2.Text = \"HP 6305\"
# Add an OK button
$OKButton = new-object System.Windows.Forms.Button
$OKButton.Location = \"130,200\"
$OKButton.Size = \"100,40\"
$OKButton.Text = \"OK\"
$OKButton.DialogResult=[System.Windows.Forms.DialogResult]::OK
#Add a cancel button
$CancelButton = new-object System.Windows.Forms.Button
$CancelButton.Location = \"255,200\"
$CancelButton.Size = \"100,40\"
$CancelButton.Text = \"Cancel\"
$CancelButton.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
# Add all the Form controls on one line
$form.Controls.AddRange(@($MyGroupBox,$OKButton,$CancelButton))
# Add all the GroupBox controls on one line
$MyGroupBox.Controls.AddRange(@($Radiobutton1,$RadioButton2))
# Activate the form
$form.Add_Shown({$form.Activate()})
# Get the results from the button click
$dialogResult = $form.ShowDialog()
# If the OK button is selected
if ($dialogResult -eq \"OK\"«»){
# Check the current state of each radio button and respond accordingly
if ($RadioButton1){
$Script:command = \"C:\Windows\System32\cmd.exe /C start E:\WinPE-Plugin\Apps\x86\Ghost32\ghost32.exe /clone /mode=restore /src=E:\WinPE-Plugin\Images\HP6005sevensp1.gho /dst=1\"}
elseif ($RadioButton2){
$Script:command = \"E:\WinPE-Plugin\Apps\x86\Ghost32\ghost32.exe -clone, -mode=restore, -src=E:\WinPE-Plugin\Images\HP6005seven sp1.gho, -dst=1\"}
}
}
# Call the function
Ghost32[/code:1]
Maintenant je bute sur les actions des radiobuttons, il ne lancent pas ma cmd
Vous avez une idée ? Je continue à chercher de mon côté !
Merci d'avance
Connexion ou Créer un compte pour participer à la conversation.
- xyz
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 69
il y a 10 ans 10 mois #20367
par xyz
Tutoriels PowerShell
Réponse de xyz sur le sujet Re:PowerShell Boutons radio
Salut,
essaie avec l'opérateur &
[code:1]&\"cmd /param...\"[/code:1]
essaie avec l'opérateur &
[code:1]&\"cmd /param...\"[/code:1]
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- David
- Auteur du sujet
- Hors Ligne
- Membre junior
-
Réduire
Plus d'informations
- Messages : 31
- Remerciements reçus 0
il y a 10 ans 10 mois #20368
par David
Réponse de David sur le sujet [RESOLU] PowerShell Boutons radio
C'est bien ce que j'ai fini par trouver après quelques heures de recherches et de tests 
Merci en tout cas
Voici le code qui fonctionne si ca peut servir :
[code:1]# La fonction pour créer la form
function Ghost32{
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Régler la taille de la form
$Form = New-Object System.Windows.Forms.Form
$Form.width = 500
$Form.height = 300
$Form.Text = ”Choix du ghost à descendre\"
# Set the font of the text to be used within the form
$Font = New-Object System.Drawing.Font(\"Times New Roman\",12)
$Form.Font = $Font
# Create a group that will contain your radio buttons
$MyGroupBox = New-Object System.Windows.Forms.GroupBox
$MyGroupBox.Location = \"40,30\"
$MyGroupBox.size = \"400,150\"
$MyGroupBox.text = \"Quelle image souhaitez vous descendre?\"
# Création de la collection de boutons radio
$RadioButton1 = New-Object System.Windows.Forms.RadioButton
$RadioButton1.Location = '20,40'
$RadioButton1.size = \"350,20\"
$radiobutton1.Checked = $true
$RadioButton1.Text = \"HP 6005\"
$RadioButton2 = New-Object System.Windows.Forms.RadioButton
$RadioButton2.Location = \"20,70\"
$RadioButton2.size = \"350,20\"
$radiobutton1.Checked = $false
$RadioButton2.Text = \"HP 6305\"
# Ajouter le bouton OK
$OKButton = new-object System.Windows.Forms.Button
$OKButton.Location = \"130,200\"
$OKButton.Size = \"100,40\"
$OKButton.Text = \"OK\"
$OKButton.DialogResult=[System.Windows.Forms.DialogResult]::OK
#Ajouter le bouton annuler
$CancelButton = new-object System.Windows.Forms.Button
$CancelButton.Location = \"255,200\"
$CancelButton.Size = \"100,40\"
$CancelButton.Text = \"Annuler\"
$CancelButton.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
# Add all the Form controls on one line
$form.Controls.AddRange(@($MyGroupBox,$OKButton,$CancelButton))
# Add all the GroupBox controls on one line
$MyGroupBox.Controls.AddRange(@($Radiobutton1,$RadioButton2))
# Activation de la form
$form.Add_Shown({$form.Activate()})
# Get the results from the bouton click
$dialogResult = $form.ShowDialog()
# Si le bouton OK est choisi
if ($dialogResult -eq \"OK\"«»){
# Verifier l'état de chaque bouton radio et agir en fonction
if ($RadioButton1){
$command = cmd.exe /C \"E:\WinPE-Plugin\Apps\x86\Ghost32\ghost32.exe /clone,src=E:\WinPE-Plugin\Images\HP6005sevensp1.gho,mode=restore,dst=1\"}
elseif ($RadioButton2){
$command = cmd.exe /C \"E:\WinPE-Plugin\Apps\x86\Ghost32\ghost32.exe /clone,src=E:\WinPE-Plugin\Images\HP6305sevensp1.gho,mode=restore,dst=1\"}
}
}
# Appel de la fonction
Ghost32[/code:1]
Merci en tout cas
Voici le code qui fonctionne si ca peut servir :
[code:1]# La fonction pour créer la form
function Ghost32{
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
# Régler la taille de la form
$Form = New-Object System.Windows.Forms.Form
$Form.width = 500
$Form.height = 300
$Form.Text = ”Choix du ghost à descendre\"
# Set the font of the text to be used within the form
$Font = New-Object System.Drawing.Font(\"Times New Roman\",12)
$Form.Font = $Font
# Create a group that will contain your radio buttons
$MyGroupBox = New-Object System.Windows.Forms.GroupBox
$MyGroupBox.Location = \"40,30\"
$MyGroupBox.size = \"400,150\"
$MyGroupBox.text = \"Quelle image souhaitez vous descendre?\"
# Création de la collection de boutons radio
$RadioButton1 = New-Object System.Windows.Forms.RadioButton
$RadioButton1.Location = '20,40'
$RadioButton1.size = \"350,20\"
$radiobutton1.Checked = $true
$RadioButton1.Text = \"HP 6005\"
$RadioButton2 = New-Object System.Windows.Forms.RadioButton
$RadioButton2.Location = \"20,70\"
$RadioButton2.size = \"350,20\"
$radiobutton1.Checked = $false
$RadioButton2.Text = \"HP 6305\"
# Ajouter le bouton OK
$OKButton = new-object System.Windows.Forms.Button
$OKButton.Location = \"130,200\"
$OKButton.Size = \"100,40\"
$OKButton.Text = \"OK\"
$OKButton.DialogResult=[System.Windows.Forms.DialogResult]::OK
#Ajouter le bouton annuler
$CancelButton = new-object System.Windows.Forms.Button
$CancelButton.Location = \"255,200\"
$CancelButton.Size = \"100,40\"
$CancelButton.Text = \"Annuler\"
$CancelButton.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
# Add all the Form controls on one line
$form.Controls.AddRange(@($MyGroupBox,$OKButton,$CancelButton))
# Add all the GroupBox controls on one line
$MyGroupBox.Controls.AddRange(@($Radiobutton1,$RadioButton2))
# Activation de la form
$form.Add_Shown({$form.Activate()})
# Get the results from the bouton click
$dialogResult = $form.ShowDialog()
# Si le bouton OK est choisi
if ($dialogResult -eq \"OK\"«»){
# Verifier l'état de chaque bouton radio et agir en fonction
if ($RadioButton1){
$command = cmd.exe /C \"E:\WinPE-Plugin\Apps\x86\Ghost32\ghost32.exe /clone,src=E:\WinPE-Plugin\Images\HP6005sevensp1.gho,mode=restore,dst=1\"}
elseif ($RadioButton2){
$command = cmd.exe /C \"E:\WinPE-Plugin\Apps\x86\Ghost32\ghost32.exe /clone,src=E:\WinPE-Plugin\Images\HP6305sevensp1.gho,mode=restore,dst=1\"}
}
}
# Appel de la fonction
Ghost32[/code:1]
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.039 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- [RESOLU]PowerShell Boutons radio