I need to close the command prompt window using sendkeys function, but when I used the below code it did not work as running of some betch file is in progress so its not taking these below options.
require 'win32ole'
system("start cmd.exe")
sleep(5)
# Create an instance of the Wscript Shell:
wsh = WIN32OLE.new('Wscript.Shell')
# Try to activate the command window:
if wsh.AppActivate('cmd.exe')
sleep(1)
wsh.SendKeys('cd \\')
wsh.SendKeys('{ENTER}')
# change the directory path where mtn folder is residing
wsh.SendKeys('cd ')
wsh.SendKeys "C://mtn-3//mtn-2.2//"
wsh.SendKeys('{ENTER}')
wsh.SendKeys('cd bin')
wsh.SendKeys('{ENTER}')
#run the cad test node file
wsh.SendKeys('CadTestNode.bat')
wsh.SendKeys('{ENTER}')
wsh1.SendKeys('Exit')
wsh1.SendKeys('{ENTER}')
I also tried replacing last two lines with the below to terminate the process.
wsh.SendKeys "^(c)"
wsh.SendKeys('{ENTER}')
but still it's not able to terminate the process running in command prompt.
Is there any other way to terminate the batch process running in command prompt window?
Key combinations can be sent by putting the keys into an array.
puts a 'A' into the text_field. In your example,
should work.
Try this:
In the MSDN SendKeys Method specifies the following characters for this keys:
Examples: