Hi Everyone,
I'm having a problem where I can't figure out how to load the GUI first then start all the processes that the application should be doing (without a start button).
I have few things that the application does such as copies, checks registry and so forth.
If I put everything under "OnLoadFormEvent", The all processes start before the GUI even starts. If I do start-sleep, the whole process stops then without the GUI loading the processes start.
If I put the processes under a startbutton, the gui loads fine and clicking the start button starts the processes.
I also couldn't figure out how to automatically adjust the GUI on the size of the monitor. If anyone has an input on that as well, really appreciated.
Can anyone tell me how I can accomplish this?
Thanks in advance.
1. Product, version and build - PowerShell Studio 2015, 4.2.89
2. 32 or 64 bit product - 64-bit
3. Operating system, e.g.- Windows 7 64-bit
4. Attach a screenshot, if applicable - N/A
5. Attach logs, crash reports, etc., in a ZIP file - N/A
Load GUI before starting the processes
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.
- SAPIEN Support Forums
- Posts: 945
- Last visit: Thu Oct 22, 2015 1:10 pm
Load GUI before starting the processes
This is an automated post. A real person will respond soon.
Thank you for posting, gutihz.
Did you remember to include the following?
*** Make sure you do not post any licensing information ***
Thank you for posting, gutihz.
Did you remember to include the following?
- 1. Product, version and build (e.g. Product: PowerShell Studio 2014, Version & Build: 4.1.71. Version and build information can be found in the product's About box accessed by clicking the blue icon with the 'i' in the upper right hand corner of the ribbon.)
2. Specify if you are running a 32 or 64 bit version
3. Specify your operating system and if it is 32 or 64 bit.
4. Attach a screenshot if your issue can be seen on the screen
5. Attach a zip file if you have multiple files (crash reports, log entries, etc.) related to your issue.
*** Make sure you do not post any licensing information ***
Re: Load GUI before starting the processes
[MOVED TO POWERSHELL GUI FORUM BY MODERATOR]
You can look at using jobs, see:
https://www.sapien.com/blog/2012/05/16/powershell-studio-creating-responsive-forms/
Or you can use a timer control to delay load:
https://www.sapien.com/blog/2011/08/09/primalforms-2011-spotlight-on-the-timer-control/
David
You can look at using jobs, see:
https://www.sapien.com/blog/2012/05/16/powershell-studio-creating-responsive-forms/
Or you can use a timer control to delay load:
https://www.sapien.com/blog/2011/08/09/primalforms-2011-spotlight-on-the-timer-control/
David
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Load GUI before starting the processes
change the activated event of the form to the start button.
PowerShell Code
Double-click the code block to select all.$form1_Load={ #TODO: Initialize Form Controls here } $start_Click={ #TODO: Place custom script here sleep 2 $textbox1.Text = "button click" }
Re: Load GUI before starting the processes
Yes - that will work as the activated occurs after the form is displayed. The form will still remain locked until the code completes. Using a job or the time prevents the form from locking up. So...while this allows the form to be displayed it is not what the activated event was designed to be used for. Don't get me wrong. I am not saying it can't be sued. I am just noting that it does not really solve the problem. David's references are both solutions and there are a couple ore that can be implements.
Re: Load GUI before starting the processes
Thank you both for your answers...
@Dan,
Sorry I'm kind of confused by what you mean to change activated event of the form? (Kind of new to this). I tried
button1_click.performclick()
but that didn't do the job.
@jvierra,
I agree with everything you said, however, I have limited time to finish this project I am working on. Automatically clicking the button would save me a lot of time. I will definitely update the code with what you recommended when I have more time.
@Dan,
Sorry I'm kind of confused by what you mean to change activated event of the form? (Kind of new to this). I tried
button1_click.performclick()
but that didn't do the job.
@jvierra,
I agree with everything you said, however, I have limited time to finish this project I am working on. Automatically clicking the button would save me a lot of time. I will definitely update the code with what you recommended when I have more time.
Re: Load GUI before starting the processes
Fundamentally what Dan is saying is to put you code in the form activated event.
Do you know how to add an event to the form? When you see the event elect the startbutton event code for the event.
Do you know how to add an event to the form? When you see the event elect the startbutton event code for the event.