Hi
I want to create a responsive form so the gui doesnt freeze when used as sample i want to create a gui
where you type in a device/hostname. And then you can ping and tracert without locking the gui at the same time
is this possible at all before i continue this?
So live updating the result in the richtext box doing both at the same time?
https://www.sapien.com/blog/2012/05/16/ ... ive-forms/
Ping/Tracert Gui - responsive forms
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Ping/Tracert Gui - responsive forms
Just follow the instructions in the article on the link you just posted. Read the article carefully and try al of the example code until you understand the point of the article. Use the custom control sets to implement the code in the article.
Re: Ping/Tracert Gui - responsive forms
I have tried the sample code from the blog and it works but my brain can gasp it.
So i created a simple form and added the custom control "Button - Start Job"
but get this error?
So i created a simple form and added the custom control "Button - Start Job"
Code: Select all
$buttonStartJob_Click={
$buttonStartJob.Enabled = $false
#Create a New Job using the Job Tracker
Add-JobTracker -Name 'JobName' `
-JobScript {
#--------------------------------------------------
#TODO: Set a script block
#Important: Do not access form controls from this script block.
Param($Argument1)#Pass any arguments using the ArgumentList parameter
Test-Connection -ComputerName "$($textbox1.Text)" -Count 10
#--------------------------------------------------
}`
-CompletedScript {
Param($Job)
$results = Receive-Job -Job $Job
$richtextbox1.Text = $results
#Enable the Button
$buttonStartJob.ImageIndex = -1
$buttonStartJob.Enabled = $true
}`
-UpdateScript {
Param($Job)
$results = Receive-Job -Job $Job -Keep
$richtextbox1.Text = $results
#Animate the Button
if($null -ne $buttonStartJob.ImageList)
{
if($buttonStartJob.ImageIndex -lt $buttonStartJob.ImageList.Images.Count - 1)
{
$buttonStartJob.ImageIndex += 1
}
else
{
$buttonStartJob.ImageIndex = 0
}
}
}`
-ArgumentList $null
}
Code: Select all
ERROR: Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command
ERROR: again.
ERROR: + CategoryInfo : InvalidData: (:) [Test-Connection], ParameterBindingValidationException
ERROR: + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.TestConnectionCommand
ERROR: + PSComputerName : localhost
ERROR:
- Attachments
-
- Test-Connection_Gui.psf
- (20.8 KiB) Downloaded 146 times
Re: Ping/Tracert Gui - responsive forms
Think i understand it a little but seem to work
Code: Select all
$buttonStartJob_Click = {
$Count = '5'
$Device = $($textbox1.Text)
$buttonStartJob.Enabled = $false
Write-Host "$Device $Count"
#Create a New Job using the Job Tracker
Add-JobTracker -Name 'JobName' `
-JobScript {
#--------------------------------------------------
#TODO: Set a script block
#Important: Do not access form controls from this script block.
Param($Device,$Count)#Pass any arguments using the ArgumentList parameter
Test-Connection -ComputerName $Device -Count $Count
#--------------------------------------------------
}`
-CompletedScript {
Param($Job)
$results = Receive-Job -Job $Job
$richtextbox1.Text = $results
#Enable the Button
$buttonStartJob.ImageIndex = -1
$buttonStartJob.Enabled = $true
}`
-UpdateScript {
Param($Job)
$results = Receive-Job -Job $Job -Keep
$richtextbox1.Text = $results
#Animate the Button
if($null -ne $buttonStartJob.ImageList)
{
if($buttonStartJob.ImageIndex -lt $buttonStartJob.ImageList.Images.Count - 1)
{
$buttonStartJob.ImageIndex += 1
}
else
{
$buttonStartJob.ImageIndex = 0
}
}
}`
-ArgumentList $Device,$Count
}