JackRap Posted April 6, 2016 Share Posted April 6, 2016 Hi, I'm very new to all this so please excuse the newbie errors I have a .bat command that opens an old DOS program in cmd. What I'd like to do is select the window and send the F3 keystroke. RunWait ( @COMSPEC & " /c \\server\Shared\share\lm.bat", "\\server\Shared\share") RunWait(WinWaitActive("C:\WINDOWS\system32\cmd.exe")) WScript.Sleep 3000 WshShell.SendKeys("{F3}") But it doesn't seem to be receiving the F3 command. Can more expert eyes see if I'm doing anything wrong? Many thanks. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 6, 2016 Developers Share Posted April 6, 2016 Welcome Jack, Not sure what you were thinking when coding the posted source. seems to be a mix of AutoIt3 and VBScript source code. Assume: Line 1 works. Line 2 is trying to shell the returncode of a winWaitActive() command LIne 3 is a VBS command and will give an error when ran with AutoIt3 Line 4 seems to be a VBS/AutoIt3 made up syntax, obviously also giving an error. The best would be to start opening the helpfile for the functions / actions you lijke to do and looking at the examples. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
JackRap Posted April 6, 2016 Author Share Posted April 6, 2016 I really don't know much about scripts so thanks for the pointers. I think I've managed to clean it up a bit but it still doesn't seem to be sending the keystroke. RunWait ( @COMSPEC & " /c \\server\Shared\share\lm.bat", "\\server\Shared\share") sleep (2000) WinWaitActive("C:\Windows\System32\cmd.exe") Send("{F3}") Link to comment Share on other sites More sharing options...
Developers Jos Posted April 6, 2016 Developers Share Posted April 6, 2016 Looks much better Maybe it would be better to explain what it is you are trying to accomplish with the Batch file in stead of doing the keystrokes to a CMD window, as that is quite error prone. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
JackRap Posted April 6, 2016 Author Share Posted April 6, 2016 The batch file just opens up a dos application in cmd commands it to navigate to a menu L: CD \LM3 lr.exe lm3ied Here the user is prompted to press F3 or Esc to run or exit. I'd hoped to use AutoIT to select the window and send an F3 keystroke command. Link to comment Share on other sites More sharing options...
alien4u Posted April 6, 2016 Share Posted April 6, 2016 Try to Change @Comspec /c (close) to /k (keep open) then you can see how the CMD windows look like and check tittle and other info. Like this: RunWait ( @COMSPEC & " /k \\server\Shared\share\lm.bat", "\\server\Shared\share") sleep (2000) WinWaitActive("C:\Windows\System32\cmd.exe") Send("{F3}") Also notice that in my system Win7 x64 the tittle of cmd windows is: "Administrator: C:\Windows\system32\cmd.exe" Check your by running cmd and double check the Window Tittle... Kind Regards Alien. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now