1.

Solve : Easy Q - Batch file press's enter??

Answer»

I am writing a batch file to open MSAccess, then open a specific DB. When this DB is opened a window pops up and I need to 'press enter', the BUTTON to be clicked is already highlighted when the window appears so after a pause or two what command is 'enter' or 'click'.

THANKS
I'm not aware you can do this in DOS batch. You could try this little snippet of VBScript:

Code: [Select] Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "drive:\path\MSACCESS.EXE drive:\path\dbname.mdb"
WshShell.SendKeys "~" 'this is enter key
WScript.Sleep 2000
WshShell.SendKeys "~" 'this is enter key

Be sure to change drive, path, and dbname to something meaningful. Save the script with a vbs extension and run as wscript scriptname.vbs

GOOD luck. 8-)Right idea but it won't work. Thanks thoughSorry the little snippet won't work on your machine. I'm guessing that you have a DOS machine. VBScript RUNS on every version of Windows starting with Win 95C.

You might try QBasic or try Googling for an out of date DOS version of AutoIt (if they even made one). Other than that I can't recall a DOS scripting program that would work on your machine (I must be having a senior moment).

Good luck. 8-)OK, I got it working but I need the 'tab' key to be clicked first before the 'enter' key. How do I do that? I guess I just need the symbol for tab.The tab key is character 9 in the ascii table. It has no graphical representation, but depending on the application, may affect the visual display of text.

Without telling us which application you used, it's darn near impossible to determine how to get a tab key inserted.

Need more info. 8-)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 ("~").


Well I'm sufficiently confused. In VBS the tab key would be WshShell.SendKeys {tab}

The comments in your code appear to be JScript. I have little experience with JS but you might try
WshShell.SendKeys ("{TAB}")

Good luck. 8-)
OMG that works, thank you so much. Now I get to work on the import part. Any suggestions???This link may give you some ideas: VBS Import

"OMG that works" doesn't really say much. I still don't really know if you using JS or VBS but in either case the general method is the same, the implementation may be different.

Happy Computing. 8-)



Discussion

No Comment Found