write a batch script to press "tab" and "Enter" key
22,125
Try this;
@if (@CodeSection == @Batch) @then
@echo off
CScript //nologo //E:JScript "%~F0"
goto :EOF
@end
WScript.Sleep (1000)
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}");
WScript.Sleep (1000)
WScript.CreateObject("WScript.Shell").SendKeys("~");
Author by
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
I need to press "TAB" and "Enter" key using either a batch script or VB script.
OK, I'm writing the vb file in notepad. I run it by double clicking icon testVB.vbs in C:. This is what I have: testVB.vbs
Set WshShell = CreateObject("WScript.Shell") WshShell.Run "test.bat" WScript.Sleep 1000 WshShell.SendKeys (TAB) //to tab from the cancel button to open button WScript.Sleep 1000 WshShell.SendKeys "~" //clicks open button
test.bat
@ECHO OFF START MSAccess "C:\path\file.mdb"
I want to open Access and the DB, but a pop up window appears which is what I'm trying to get around. After I figure that out I will need to figure out how to write code to import a .txt file to the DB.
The TAB is what is not working, I have tried {TAB}, "TAB", (TAB), and different combos. I get an error with the first one and the others have no action. The enter works though ("~").
-
Aacini over 9 yearsYou forgot to mention the source of this answer...