使用VB.NET强制关注桌面

时间:2011-07-06 20:29:59

标签: .net vb.net

如何在VB.NET中强制关注桌面?

1 个答案:

答案 0 :(得分:0)

我不确定你的意思。是否要从所有打开的窗口中删除焦点或最小化所有窗口(显示桌面)?

您可以使用P / Invoke显示桌面:

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_LWIN = &H5B


''' <summary>
''' Shows the desktop by minimizing all windows
''' </summary>
Public Sub ShowDesktop()
    keybd_event(VK_LWIN, 0, 0, 0)
    keybd_event(77, 0, 0, 0)
    keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
End Sub

source