Home > How-To Library > System & API

How to Minimize all windows (in four ways)

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _ ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Sub Main() Call keybd_event(&H5B, 0, 0, 0) Call keybd_event(&H4D, 0, 0, 0) Call keybd_event(&H5B, 0, &H2, 0) End Sub 'Another way: Option Explicit Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, _ ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Const VK_STARTKEY = &H5B Const VK_M = 77 Const KEYEVENTF_KEYUP = &H2 Public Sub Main() 'WinKey down keybd_event VK_STARTKEY, 0, 0, 0 'M key down keybd_event VK_M, 0, 0, 0 'M key up keybd_event VK_M, 0, KEYEVENTF_KEYUP, 0 'WinKey up keybd_event VK_STARTKEY, 0, KEYEVENTF_KEYUP, 0 End Sub 'Another way: Option Explicit ' Add a reference to Microsoft Shell Control & Automation Dim MyShell As New Shell32.Shell Private Sub Command1_Click() MyShell.MinimizeAll End Sub Private Sub Command2_Click() MyShell.UndoMinimizeALL End Sub 'Another way: Option Explicit 'Create a new .scf file (or use the default one) and use shell execute to call it. 'To create a .scf file: 'In Notepad, type the following text on individual lines: '[Shell] 'Command = 2 'IconFile=explorer.exe,3 '[Taskbar] 'Command = ToggleDesktop 'Click File, click Save As, and then save the file to your desktop as Show Desktop.scf. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _ ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Const SW_SHOWNORMAL = 1 Public Sub Main() ShellExecute Me.hwnd, vbNullString, App.Path & "\aaa.scf", vbNullString, "C:\", SW_SHOWNORMAL End Sub

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.