Hi guys
I want to show the dekstop by clicking a button.
So everything is minimized
Shell ("C:\blah\Show Desktop.scf") didn't work
Thanx
Printable View
Hi guys
I want to show the dekstop by clicking a button.
So everything is minimized
Shell ("C:\blah\Show Desktop.scf") didn't work
Thanx
no idea, but just give try to send keys of start menu key + d, this will show the desktop.
Good idea!
I'll post my result
How can I send the start menu/windows key?? :ehh: :eek: :rolleyes:
Try this
VB Code:
Option Explicit 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 VK_CONTROL = &H11 Private Const VK_ESCAPE = &H1B Private Const KEYEVENTF_KEYUP = &H2 Private Sub Command1_Click() keybd_event VK_CONTROL, 0, 0, 0 ' Press Control Key keybd_event VK_ESCAPE, 0, 0, 0 ' Press Escape Key keybd_event VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0 ' Release Escape Key keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 ' Release Control Key End Sub
Hmm..
That's Control and Escape.
Do you also know something for the Windows key?
Thanx
you could enumerate all visible windows and minimize them with API
Enumerate: EnumWindows
Check if visible: IsWindowVisible
And then minimze: ShowWindow
Thnx people!
Actually, it seems it's easier.
Check out this code by Robdog888
http://www.vbforums.com/showthread.php?t=360571
That rocks!
Much easier! Thank you jcis (and Robdog)
When you click the "Show Desktop" button, explorer actually runs the Shell32.IShellDispatch4.ToggleDesktop() method.
See the proper way to Programmatically Showing the Desktop (ToggleDesktop) and the VB.NET way.
But it is not working in VB6.
Add a reference to Microsoft Shell Control & Automation and in object browser it will showup. (check 'show hidden members'). But I'm unable to create an instance of IShellDispatch4 interface in VB6. :(
Apart from the keybd_event method, you can try these,
Idea 1 - Non-API
VB Code:
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
or better,
Create a new .scf file (or use the default one) and use shell execute to call it.
Idea 2 - ShellExecute API (better)
VB Code:
Option Explicit 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 Private Sub Command1_Click() ShellExecute Me.hwnd, vbNullString, _ App.Path & "\aaa.scf", _ vbNullString, "C:\", SW_SHOWNORMAL End Sub
That's even better :p
Maybe you can add it to the Codebank?
Just an update.
This works in VB6/VBScript:
http://msdn2.microsoft.com/en-us/library/ms630442.aspxvb Code:
Private Sub Command1_Click() Dim objShell Set objShell = CreateObject("Shell.Application") objShell.ToggleDesktop Set objShell = Nothing End Sub