Select item in the list box, countdown will automatically press button

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 4 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
winsoft
Posts: 24
Last visit: Sat May 29, 2021 4:59 am

Re: Select item in the list box, countdown will automatically press button

Post by winsoft »

Anyway, thank you very much for your help.
Powershell studio is a very good GUI tool
My problem above, already has a complete solution in other languages, but I am very interested, to know how to implement it in powershell studio

I will learn about powershell when there is enough time in the future.

My English is very bad, I use Google Translate, thank you
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Select item in the list box, countdown will automatically press button

Post by jvierra »

I can give you an example of how to close the form with a timer.

Try this version of your form:
Attachments
test form.psf
(59.22 KiB) Downloaded 92 times
winsoft
Posts: 24
Last visit: Sat May 29, 2021 4:59 am

Re: Select item in the list box, countdown will automatically press button

Post by winsoft »

Thank you for your help

Maybe I didn’t express it clearly,

1. When the countdown is over, perform the function of pressing the ok button, the selected items Output in the console

2. During the countdown process, if I perform other operations, such as clicking a form or selecting an item, the countdown will stop.

I think my problem, to achieve it, is very difficult
winsoft
Posts: 24
Last visit: Sat May 29, 2021 4:59 am

Re: Select item in the list box, countdown will automatically press button

Post by winsoft »

I don't understand why the following code has no output :?:

Code: Select all

$buttonOK_Click = {
	#TODO: Place custom script here
	$checkedlistbox1.CheckedItems | Write-Host
	$checkedlistbox2.CheckedItems | Write-Host
	$checkedlistbox3.CheckedItems | Write-Host
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Select item in the list box, countdown will automatically press button

Post by jvierra »

Because "CheckedItems" is not a value - it is a collection of objects that have checks.
Again. With no programming experience you will continuously make bad guesses. There is no substitute for knowing. Guessing never works in any programming language.

The link will not only teach you basic PowerShell but will also teach you the fundamentals of programming.

The form I psoted also tells you how to click the button.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Select item in the list box, countdown will automatically press button

Post by jvierra »

winsoft wrote: Sun May 19, 2019 4:29 pm Thank you for your help

Maybe I didn’t express it clearly,

1. When the countdown is over, perform the function of pressing the ok button, the selected items Output in the console

2. During the countdown process, if I perform other operations, such as clicking a form or selecting an item, the countdown will stop.

I think my problem, to achieve it, is very difficult
There are many issues with your form. The event is not connected to anything.

You need to slow down and learn how to do one thing first. When you learn how to use one control then you will have a better understanding of other controls.

The button is defined as the button that causes the form to close. The click will never be called.

The first issue you are creating for yourself is trying to design a form with absolutely no training or understanding of how forms work. Without learning what a form is and how it is intended to be used you cannot design a solution.

Always start by learning the simple things first. The videos and tutorials are there for those new to programming and forms/PowerShell. You cannot guess your way through this.
winsoft
Posts: 24
Last visit: Sat May 29, 2021 4:59 am

Re: Select item in the list box, countdown will automatically press button

Post by winsoft »

My English is not very good, I don't know how to describe the problem.
Look at the picture may be more clear

I am learning other scripting languages, but I can't communicate its code here because it's not friendly.

I just got in touch with powershell gui programming, I found a software (powershell studio) using Google search, I am trying it out and I feel it is very easy to get started.

I tried to use it to complete examples of other scripting languages. If all goes well, I have plans to use powershell scripts to help my work.

The above is my real situation, I hope to get your understanding.
Attachments
err.gif
err.gif (345.79 KiB) Viewed 1620 times
winsoft
Posts: 24
Last visit: Sat May 29, 2021 4:59 am

Re: Select item in the list box, countdown will automatically press button

Post by winsoft »

I don't understand why the same code (OK button), the result is different, maybe I am stupid, but I really checked many times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Select item in the list box, countdown will automatically press button

Post by jvierra »

GIFs do not explain your issue. The form I posted does what you ask as far as I can decode it. Without some basic knowledge of programming you will no be able to ask a clear question.

Sorry.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Select item in the list box, countdown will automatically press button

Post by jvierra »

Your form is not connected to the event. Double click on the button in the designer and it should work.
This topic is 4 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