开发者

How to check if a button is clicked?

开发者 https://www.devze.com 2023-01-10 22:23 出处:网络
I have a following LOC in my ps1 script which displays a message with an OK button. [Windows.Forms开发者_开发知识库.MessageBox]::Show($Message, $Title, [Windows.Forms.MessageBoxButtons]::OK, [System.

I have a following LOC in my ps1 script which displays a message with an OK button.

[Windows.Forms开发者_开发知识库.MessageBox]::Show($Message, $Title, [Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information, [System.Windows.Forms.MessageBoxDefaultButton]::Button1, [System.Windows.Forms.MessageBoxOptions]::DefaultDesktopOnly) | Out-Null   

I want to perform some operation only if the user clicks the OK button something like:

if (Button1.pressed())
{
   #perform some operations
}

How do I check if the button is clicked?

Thanks


I found a simple explanation here.

Basically, you compare the Show function's return value with [Windows.Forms.DialogResult]::OK

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号