我使用PowerShell來開發具有圖形界面一個小工具,我要瘋了這個問題...鼠標時,不要第一計時器滴答後工作
例如: 我有一個標籤在顯示ping的「實時」狀態的表單上。 與此同時,如果您單擊標籤,則會彈出一條消息。
function GoogleStatus ($Label)
{
$Google = "www.google.com"
If (Test-Connection -ComputerName $Google -Count 1 -Quiet)
{Label.Text = "Yes"}
else
{Label.Text = "No"}
}
function HelloMsg
{
[System.Windows.Forms.MessageBox]::Show("Hello","Funny Window",0,32)
}
[void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
#Forms
$Form = New-Object System.Windows.Forms.Form
$Form.Size = '150, 220'
$Label = New-Object System.Windows.Forms.Label
$Form.Controls.Add($Label)
$Label.Location = '10, 30'
$Label.Size = '75, 20'
$Label.Add_Click({HelloMsg})
#Timer Init
$Timer = New-Object 'System.Windows.Forms.Timer'
$Timer.Interval = 3000
Timer.Add_Tick({GoogleStatus $Label})
$Timer.Enabled = $True
#Show Interface
$Form.ShowDialog()
在計時器的前3個秒中,點擊標籤正確顯示彈出消息。但是,如果我等待超過3秒鐘,則點擊標籤不起作用。
幫助請:(
請幫助!:( – Nick32342