VBScript SendKeys CTRL + LWIN + TAB?

I am trying to write a simple script that will send the key combination 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 "%" (the so-called ALT key) with LWIN (aka the Windows left key), it indicates a syntax error.

I tried the following but 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 this has something to do with being able to hold certain keys while other keys are pressed, but I can't figure out what is right.

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

+6
source share
5 answers

Just in case, someone will land here during these years ...
The workaround (instead of sending keystrokes) is to call directly to the application:

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

The Windows Task Switcher application opens. (Same as ⊞ windows + TAB )

+4
source

try this code:

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

I know that you are looking for VBscript, but it seems like this is unlikely (pure VBscript). Here is the post that resolved this through C #.

fooobar.com/questions/225705 / ...

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

+1
source

I think your question is an example of an XY problem, and you really want to activate Flip 3D (switch between windows). You can do this programmatically by running the rundll32 DwmApi #105 command:

 CreateObject("WScript.Shell").Run "rundll32 DwmApi #105" 
+1
source

Usa Este Codigo

'' Estas son las contantes necesarias para manejar el evento de teclado Private Const KEYEVENTF_KEYDOWN As Integer = & H0 Private Const KEYEVENTF_KEYUP As Integer = & H2

'' method for comparing a pair of key events _ Closed common routine keybd_event (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As UInteger, ByVal dwExtraInfo As UInteger)

 End Sub 

'' usalo cuando quieras este codigo simula presionar '' TAB y luego soltar el boton

keybd_event (CByte (Keys.Tab), 0, KEYEVENTF_KEYDOWN, 0) keybd_event (CByte (Keys.Tab), 0, KEYEVENTF_KEYUP, 0)

'' aqui se simula presionar la tecla de windows y TAB seguidas para despues soltarlas

keybd_event (CByte (Keys.LWin), 0, KEYEVENTF_KEYDOWN, 0) keybd_event (CByte (Keys.Lab), 0, KEYEVENTF_KEYDOWN, 0)

keybd_event (CByte (Keys.Tab), 0, KEYEVENTF_KEYUP, 0) keybd_event (CByte (Keys.LWin), 0, KEYEVENTF_KEYUP, 0)

0
source

Source: https://habr.com/ru/post/927655/


All Articles