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.
            Asked
            
        
        
            Active
            
        
            Viewed 6.7k times
        
    6
            
            
        - 
                    Batch is not generally an appropriate language for interacting with GUI applications. Take a look into 'SendKeys' in VBS. – unclemeat Aug 18 '14 at 22:50
- 
                    Doubt you can do this in batch: prob's use some weird program or use something else – Monacraft Aug 18 '14 at 22:51
1 Answers
9
            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}");
- 
                    1Do we need anything else in our .bat file when we want to press enter after opening an app other than WScript.CreateObject("WScript.Shell").SendKeys("{ENTER}"); – rdj7 Apr 19 '17 at 10:20
 
     
     
    