2016-12-03 77 views
0

當我將鼠標懸停在導航欄中的圖標上時,我需要創建一條消息(如USB圖標的'Safely Remove Hardware ..')'點擊此處退出'。這是我用它來創建的圖標:Powershell WPF導航欄創建ContextMenuStrip?

. 
. 
$notifyIcon.Icon = $icon 
$notifyIcon.BalloonTipIcon = "Info" 
$notifyIcon.BalloonTipTitle = "Powershell Search" 
$notifyIcon.BalloonTipText = "Loading Search GUI. Please wait ..." 
$notifyIcon.Visible = $True 
$notifyIcon.ShowBalloonTip(50) 
#Create mouse hover box here. 
$notifyIcon.add_Click({       
    $notifyIcon.Visible = $false 
    $form.Close() 
    Stop-Process $pid 
}) 

我知道我可以使用外接的MouseEnter,但我並不想在這裏一個工具提示消息。

回答

0
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 
$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon 
$objNotifyIcon.Icon = [System.Drawing.SystemIcons]::Information 
$objNotifyIcon.BalloonTipIcon = "Info" 
$text = 'This is just a text' 
$objNotifyIcon.BalloonTipText = $text 
$objNotifyIcon.BalloonTipTitle = "Tip Title" 
$objNotifyIcon.Visible = $True 
$objNotifyIcon.ShowBalloonTip(30000) 

這樣就足夠了您的需求,我相信

+0

遺憾的是沒有。它只是給了一個永久的Tootip。我需要一些響應MouseHover的東西。 – Archdeacon

+0

OO。好的。讓我檢查一下mouseover事件..以便我們能夠觸發該事件。 –

+0

如果我右鍵單擊,我可以獲取ContextMenu項。我需要的是與MouseEnter類似的東西。 – Archdeacon

0

這應該可以幫助您:

$objNotifyIcon.Text = "when hover appear" 
+0

我現在可以自己回答這個問題了:Text屬性是需要的: '$ notifyIcon.add_MouseMove({$ notifyIcon.Text =「Click to Exit」 })' – Archdeacon