简体   繁体   English

使用 VB.NET 将焦点强制到桌面

[英]Forcing focus to the desktop using VB.NET

How can I, in VB.NET, force the focus to the desktop?在 VB.NET 中,如何将焦点强制到桌面?

I'm not sure what you mean.我不确定你是什么意思。 Do you want to remove focus from all open windows or minimize all windows (Show desktop)?您想从所有打开的 windows 中移除焦点还是最小化所有 windows(显示桌面)?

You can show desktop using P/Invoke:您可以使用 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资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM