Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send Windows Key in batch script

I've recently been using the SendKeys function using Batch script.

I've understood how to input certain keys into a window, such as the tab key:

%SendKeys% "{TAB}"

Or the backspace key:

%SendKeys% "{BACKSPACE}"

But I have been trying to input the Windows key without pressing it.

Unfortunately, I do not know what the batch name for it is. I've tried:

WIN
WINDOWS
WINKEY
START
LWIN

But none have worked.

I've looked everywhere for this, and help would be greatly appreciated.

like image 895
Zinger Avatar asked Aug 16 '18 01:08

Zinger


People also ask

How do I press a key in a batch file?

The example below will open a browser window and press the Tab key to move on the input field. The code for our example will look like the below. In the above example, through the line SET SendKeys=CScript //nologo //E:JScript "%~F0" , we send keys to the keyboard buffer by using %SendKeys% .

What does %1 mean in a batch file?

When used in a command line, script, or batch file, %1 is used to represent a variable or matched string. For example, in a Microsoft batch file, %1 can print what is entered after the batch file name.

What is GOTO EOF in batch file?

In batch code in question the first goto :EOF is needed to exit batch file processing without an unwanted fall through to the subroutine code after finishing the loop. The second goto :EOF in batch code of questioner is for exiting the subroutine and continue processing in FOR loop in second line.

How do I press the key to continue in CMD?

The cmd /c pause command displays the Press any key to continue . . . and pauses the execution until a key is pressed. Output: Copy Press any key to continue . . .


1 Answers

There is currently no way to simulate the windows home logo in sendkey's, howevery this does not mean it's not possible.

If you take a look at the windows shortcut keys you will find you can simulate Open Start with the following key combinations: Ctrl + Esc.

To simulate this in batch, you can use: powershell -c "$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}') or in your case: %SendKeys% "^{ESCAPE}".

As stated in sendkeys:

  • "^" - Simulates a Ctrl key press.
  • "{ESCAPE}" - Simulates a Esc key press.
like image 55
John Kens Avatar answered Oct 27 '22 21:10

John Kens