Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBScript SendKeys CTRL+LWIN+TAB?

I am trying to write a simple script that will send the key combo of CTRL+WINDOWS KEY+TAB. The code below sends the keys CTRL+ALT+TAB

Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.SendKeys "^%{TAB}"

However when I try to replace "%" (aka the ALT key) with LWIN (aka the Left Windows Key) it says Syntax Error.

I tried the following, but had no luck:

Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.SendKeys "^{LWIN}{TAB}"

 

Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.SendKeys "^{LWIN}+{TAB}"

 

Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.SendKeys ^{LWIN}+{TAB}

I know it has something to do with being able to Hold certain keys while other keys are pressed but I can't seem to get it right.

The windows key can be pressed programmatically using CTRL+ESC. Is there a way to set this combination as a variable called LWIN and then use one of the above Scripts?

like image 888
daniel11 Avatar asked Oct 13 '12 22:10

daniel11


3 Answers

Just in case someone land here on these years...
A workaround (instead of sending keystrokes) is to call directly to the application:

Set objShell = CreateObject("Shell.Application")
objShell.WindowSwitcher

This will open Task Switcher Windows App. (Same as ⊞ windows+TAB)

like image 167
gmo Avatar answered Oct 23 '22 22:10

gmo


try this code:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "+(^{LWIN}{TAB})"
like image 5
Robin Avatar answered Oct 23 '22 23:10

Robin


I know you are looking for VBscript but it looks like that is unlikely (pure VBscript). Here is a post that did solve this via C#.

https://stackoverflow.com/a/10367832/1742115

This page tells how to call the C# DLL from your VBscript if you want to keep some of this in vbs.

like image 1
RLH Avatar answered Oct 23 '22 23:10

RLH