Click to See Complete Forum and Search --> : SendKeys cannot close DOS window.


Jacob_Novice
October 15th, 2001, 10:15 AM
Hello all,

I am looking for a way to use SendKeys to send the close window sequence (ALT+SPACE+C) to a DOS window under WinNT. Manually this can be done but programmatically, the DOS window seems to ignore the sequence. Doing the same on a Notepad application works fine, i.e. the sequence is correct and is sent correctly. If anyone has experienced such a phenomenon and may know of a solution or work-around, I would appreciate all the help you can offer.

Thanks,

Jacob.

Cimperiali
October 16th, 2001, 05:31 AM
private Sub Command1_Click()
Dim a
a = Shell("cmd.exe", vbNormalFocus)
AppActivate a
SendKeys "Exit", true
SendKeys "{ENTER}", true
End Sub




Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

Amit Dahotre
October 16th, 2001, 09:24 AM
this is if you want to close the DOS window after it says Finished.

Right-click on the executable that runs in dos mode in windows explorer and select properties
On the program tab select "Close on exit".
Now it will never keep the window open.