Code to Show the Desktop - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This is a tutorial on how to minimize all active applications and show the desktop in Visual Basic .NET

Add the following declarations below you Public Class Form1:

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

Then add the following Sub

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

Then call ShowButton from a button click event:

ShowDesktop


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.