1

I'm trying to simulate Win+D (show desktop) in a .vbs file, but I can't use the Windows key. I tried using Ctrl+Esc, but that doesn't work. I'm running Windows 10.

Here's my code right now:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "windows key + d ?????"
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Andrew
  • 146
  • 2
  • 11
  • Script56.chm shows no support of windows key. If you install [AutoIt](https://www.autoitscript.com/site/autoit/), then it will register a .dll named AutoItX3.dll which gives you a COM interface that you can use in VBScript. Then you can do i.e. `Set oAutoIt = WScript.CreateObject("AutoItX3.Control")`; `oAutoIt.Send "#d"`. AutoItX.chm is the installed help reference. – michael_heath Jan 14 '18 at 14:03
  • @michael_heath If I install AutoIt, will I be able to run it from a .bat file? Also, I searched for AutoIt (Win+S), and I found it inside a Python Folder "C:\Users\Andrew\Downloads\PyAutoIt-0.4\PyAutoIt-0.4\autoit\autoit.py" Is this the AutoIt your referring to, or will I have to download a different one? – Andrew Jan 14 '18 at 14:18
  • This is VBS, ok. If you mean like a hybrid script i.e. batch and vbs as I seen before, perhaps. Pure batch has no COM support so doubt it. I also do Python and have noticed it in modules others mention. I have not used in Python though probably is the one and same. If you have it in the Python module then it may already be registered. So you could try it. You may still be missing the chm file though, yet you could get the AutoIt zip no install file to get the chm. – michael_heath Jan 14 '18 at 14:31
  • Checked at [github/jacexh/pyautoit](https://github.com/jacexh/pyautoit/tree/master/autoit/lib). That is my visual id of AutoIt3.dll and the x64 version. – michael_heath Jan 14 '18 at 14:46

1 Answers1

0

ToggleDesktop Method

Raises and lowers the desktop.

object.ToggleDesktop

Parameter Description object Required. An object expression that evaluates to a Shell object.

Remarks

This method behaves like the toggle desktop icon on the quick launch bar. It hides all open windows and shows the desktop, or hides the desktop and shows all open windows. The ToggleDesktop method does not display any user interface, it just invokes the toggle action.

From https://msdn.microsoft.com/en-us/library/windows/desktop/gg537747(v=vs.85).aspx

Use this line to create the object

Set objShell = CreateObject("Shell.Application")
ACatInLove
  • 530
  • 2
  • 5