开发者

Forcing focus to the desktop using VB.NET

开发者 https://www.devze.com 2023-03-18 22:27 出处:网络
开发者_运维技巧How can I, in VB.NET, force the focus to the desktop?I\'m not sure what you mean.Do you want to remove focus from all open windows or minimize all windows (Show desktop)?

开发者_运维技巧How can I, in VB.NET, force the focus to the desktop?


I'm not sure what you mean. Do you want to remove focus from all open windows or minimize all windows (Show desktop)?

You can show desktop using 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

0

精彩评论

暂无评论...
验证码 换一张
取 消