GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 6 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by jvierra »

What does you jobscript look like? Did you try mu test?

$jobscript = { Get-ChildItem$env:ProgramFiles -recurse }

In the completed script just do this.
  1. $Competed = {
  2.     Param($job)
  3.    $res =  $job | Receive-Job
  4.    [System.Windows.Forms.MessageBox]::Show( $res.Count)
  5. }
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

The message box doesn't come up with [System.Windows.Forms.MessageBox]::Show( $res.Count) or updating a form property (textbox) within the CompletedScript. It does work outside of the Completed script. I created a separate button with the following code, keeping it simple and the value of $res.Count is 0.

$button1_Click={
#TODO: Place custom script here
$this.Enabled = $false
Add-JobTracker -Name "Test" `
-JobScript {
Get-ChildItem $env:ProgramFiles -recurse
} `
-CompletedScript {
PARAM ($job)
$res = $job | Receive-Job
}
$this.Enabled = $true
[System.Windows.Forms.MessageBox]::Show($res.Count)
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by jvierra »

I looked at your code and it is horribly broken in many, many places. I did not fix it but used your form to show how the JobTracker works.
Run the form attached to see how it works. Throw out your code and rethink what you are trying to do.

As I posted earlier, you need to go back and carefully read the blog post until you fully understand how this needs to work.

It takes about one step to create a tracker and a few edits to update the code. Stop trying to be so fancy before you even have a working tracker. Your fancy things are breaking the tracker and the form.
Attachments
ProcessLoop v1.0.psf
(51.87 KiB) Downloaded 129 times
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

I got rid of my "horribly" written code/wsf file and created one from scratch to reference what you had change/coded for the routine. Does the file/code you provided work, yes. Taking the pieces of what you added and putting them on my newly created wsf file it doesn't seem to update (got rid of my code so I could try and understand/debug through it). The progressbar or the datagrid don't update at all. Sorry I am just getting really frustrated with this as I expected either copying and pasting the code from the example/article or the code you provided would work and then I would go through the motion of testing/debugging like you want me too. I am not trying to give you a hard time at all and appreciate the help you have provided so far. What you coded up doesn't exactly do what I need it to do, as i want the progressbar to be the number of files or in my example that i had, the number of computer objects. The code you provided and the example in the article is giving the progressbar a random number to increase and set max.

I have attached the new form/wsf file with the example code you just provided back, can you tell me why please what I am missing?

Again, I do appreciate your help.
Attachments
Test-Tracker.psf
(30.93 KiB) Downloaded 137 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by jvierra »

Well you need to spend the time to learn how to create a form with PSS. YOu are just copying code around with no concept of how to build a form.

Go back to the article and read it carefully. Try all of the examples until you understand what they are trying to show you. You cannot learn forms in 10 minutes. Even experienced programmers take days to finally understand how Windows works. It cannot be guessed at if you are not already an experienced programmer. The articles in the info center will help you to understand controls and how forms are managed through events.

Start by creating a new form and adding the JobTracker control set and then run the form. That takes about 2 minutes and is a good place to start.

1. Create new dialog form.
2. Drop "Button - Start Job" on form.
3. Click "Run"
4. Click "Start" button.

Job runs and animates button.
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

I know how to create a form in PSS, as how did i magically create the form/example when i started this thread which everything was working fine. Just want to have a responsive form when Get-AdComputer was called/used. Anyways...

Is there anyway to know in PSS if a set value for a control is set/changed from default in the properties vs hard coding it (which you would know right away)?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by jvierra »

Did you try my recipe for creating a job form?

To understand how the controls properties work I recommend reading the documentation for PSS. It is available on the help menu as "Product Manual". This will give you a structured overview of how to use PSS.

Unfortunately we cannot teach you how to use PSS or how to design and code forms. There are books available on how t design and code forms however they are all in C# and VB.Net but the lessons are mostly transferrable.
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

How does this simple question, which is a yes or no response get a reply of this? Copying and pasting from a script?

The question:
Is there anyway to know in PSS if a set value for a control is set/changed from default in the properties vs hard coding it (which you would know right away)?

jvierra: I am good from here, i see i am not getting anywhere/help with the questions i am asking. Will try to figure it out on my own. Thanks,
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by jvierra »

Look at the properties pane. What happens when you change a property?
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

Look at the properties pane. What happens when you change a property?
-- My point is if you manually change a property on a control is it stored somewhere to reference. Vs if you hard coded it in your code on a control you would know as the code is listed in the control.

Control Sets...
Based on your wording you are stating that there are built in control sets to add to the form on a control once created. When I right click on a control, example button i don't see add control set, just create control set.
I am running PSS on Windows 10, installed version 5.4.136.

Start by creating a new form and adding the JobTracker control set and then run the form. That takes about 2 minutes and is a good place to start.

1. Create new dialog form.
2. Drop "Button - Start Job" on form.
3. Click "Run"
4. Click "Start" button.

Job runs and animates button.
This topic is 6 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked