Need to brainstorm. I have a form that I publish for end users to a terminal server..when I need to update it I have to go find who's left it open and close it via task manager.
I'm looking for ideas to track and possibly reset a timer based on any control interaction on the form.
Form close due to inactivity?
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: Form close due to inactivity?
In Windows we would hook the messageloop. PowerShell uses dialogs which do not own a message loop. There might be a generic process hook you could install like a keep-alive.
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Form close due to inactivity?
This is what I came up with after a redbull. It works but I'm not sure if adding the mousehover event is proper, my idea was that I don't want the mousehover running all the time. Should I remove it after the timer is reset?
- $formmousehover = {
- $formO365UserProvision.Text = ''
- $script:StartTime = (Get-Date).AddMinutes(1)
- [TimeSpan]$span = $script:StartTime - (Get-Date)
- $statusbar1.Text = "Form timeout: " + "{0:N0}" -f $span.TotalMinutes + " Minute(s)"
- }
- $timer1_Tick = {
- [TimeSpan]$span = $script:StartTime - (Get-Date)
- if ($span.TotalSeconds -gt 30) { $statusbar1.Text = "Form timeout: " + "{0:mm}:{0:ss}" -f $span } else {
- $statusbar1.Text = "hover mouse over form to add time"
- $formO365UserProvision.Text = "Are you still using this form? " + "{0:N0}" -f $span.TotalSeconds + " Seconds"
- $formO365UserProvision.add_MouseHover($formmousehover)
- if ($span.TotalSeconds -le 0) {
- $formO365UserProvision.Close()
- }
- }
- }
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Form close due to inactivity?
I wired up their chairs to give them 120v when they leave their rdp sessions disconnected
This one is just for adding/updating rows in a small sql db so the operations take seconds. I gave it a 10 minute timeout.
This one is just for adding/updating rows in a small sql db so the operations take seconds. I gave it a 10 minute timeout.