这是我正在寻找的代码,当鼠标从列表中的一项移动到下一项时,当下拉列表处于按下状态时,我正在寻找正确的方法来捕获任何鼠标移动。
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object System.Windows.Forms.Form
$Form.StartPosition = 'CenterScreen'
$cbSearch = New-Object System.Windows.Forms.ComboBox
$cbSearch.Width = 280
$cbSearch.Items.AddRange(@('Mixed content', 'More stuff', 'ANOTHER THING CONTENT', 'Item ?', 'Mixed item'))
$Form.Controls.Add($cbSearch)
# Event handler required for when the dropdown is in it's downed state. Like
# MouseCaptureChanged only when the dropdown is down and the mouse is moved over
# each item.
$cbSearch.Add_MouseCaptureChanged({ selectChanged $this $_ })
# Event handler action for the cbSearch control.
function selectChanged ($sender, $event) {
write-host ($cbSearch.Text)
}
[void]$Form.ShowDialog()
这可能吗?我已经尝试了所有我能看到的可用鼠标事件处理程序。
$cbSearch.Add_MouseCaptureChanged({ selectChanged $this $_ })
$cbSearch.Add_MouseEnter({ selectChanged $this $_ })
$cbSearch.Add_MouseHover({ selectChanged $this $_ })
$cbSearch.Add_MouseLeave({ selectChanged $this $_ })
这是我希望在将鼠标悬停在每个项目上时发生偶数的时间。