Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to press a key with batch file

Tags:

batch-file

Hi I am new with batch file, I want to know how to auto press a key from batch file. I want to make a program that open a browser and press the tab key automatically.

like image 224
Yagel Avatar asked Aug 18 '14 20:08

Yagel


People also ask

How do I press a button in a batch file?

Usually either tabs and/or arrow-keys will suffice. Sometimes you may need to use the ALT key to move into the menus. Also, you might actually be able to use a series of keyboard commands like ALT + F S ENTER , or even a keyboard shortcut like CTRL + S .

What is %% A in batch?

Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.

What is %% g'in batch file?

%%parameter : A replaceable parameter: in a batch file use %%G (on the command line %G) FOR /F processing of a command consists of reading the output from the command one line at a time and then breaking the line up into individual items of data or 'tokens'.


1 Answers

A search for "batch file sendkeys" and further revision returned this list of answers for similar questions:

  • How to make a batch file to run a hotkey
  • Batch file that changes URL in open browser
  • Press Keyboard keys using a batch file
  • Automatically respond to runas from batch file

The Batch file below do what you want:

@if (@CodeSection == @Batch) @then
@echo off
CScript //nologo //E:JScript "%~F0"
rem Open the browser here
goto :EOF
@end
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}");
like image 117
Aacini Avatar answered Oct 18 '22 22:10

Aacini