[System.Windows.Forms.MessageBox]::Show('Review Outstanding Timesheet', 'Urgent', 'Yesno')
Not to sure this is strictly a PS question, the above is working fine but i would like to customise the buttons to read
not sure if there is a simple option or even a hard one as never really messed with windowsforms
Nope. You’d have to build a new form completely from scratch.
Thanks Don, managed to get this from a MS demo and customise
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'Timesheet reminder'
$form.Size = New-Object System.Drawing.Size(300,200)
$form.StartPosition = 'CenterScreen'
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Point(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = 'Review'
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $OKButton
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Point(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = 'Ignore'
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CancelButton
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,50)
$label.Text = "'Please would you complete your timesheet(s) to enable the timely recognition of costs on our projects and the billing of these to clients, if applicable.
$form.Topmost = $true
$result = $form.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
Write-Host = "review"
Write-Host = "Ignore"
awaiting telling off for WH command :), just for demo purpose so its ok
A different thought using ComObject.
$r = New-Object -ComObject wscript.shell
# 5 --> is the timeout for showing the popup
# 6 --> CancelContinueTryAgain , Cancel and Continue can be used here.
^ nice, how would i customise the text in the buttons however ?
I would echo Don’s reply.
FYI, if you start messing with PS with GUI. You don’t have to do this from scratch.
Use these resources:
Visual Studio Community Edition
The above are freely available, or you can get this, but it’s not free:
Thanks all, ive created quite a few apps with Sapien, its a great tool and take sthe hard work of creating the forms out of the equation, great for speed but bad for learning
this needed to be ran as a scheduled task and pop the box up on screen.