
SendKeys cannot close DOS window.
Torgeir,
Thanks for your help. I downloaded the control and seemed to solve the
problem I was facing. However, there should be a way to accomplish the same
without having to add an additional control. Perhaps I am losing focus on
the appropriate window and that is why the keys I am sending to the DOS
window are not interpreted properly. I have looked at description of the
"AppActivate" method in MSDN and noticed it states: "You can use the task
ID returned by the Shell function in place of title to activate an
application." Do you (or anyone in the group) have an idea of how to access
the "task ID" referred to here? I am using the "Run" method to activate the
batch file running in the DOS window and it does not return the "task ID".
Any help would be greatly appreciated,
Thanks,
Jacob.
Quote:
> Using AutoItX (free), you can close a dos box (with a running bat-file
also) e.g. like this:
Quote:
> <code>
> Set WshShell = CreateObject("WScript.Shell")
> Set oAutoIt = CreateObject("AutoItX.Control")
> sComSpec = WshShell.ExpandEnvironmentStrings("%comspec%")
> WshShell.Run sComSpec
> MsgBox "Closing Command Box with Window title " & sComSpec
> oAutoIt.WinClose sComSpec,""
> </code>
> AutoIt: http://www.*-*-*.com/ , it can
automate any windows based task or even windowed DOS tasks
Quote:
> Note: It's defaults is to match the start of a window title that you
specify, use "SetTitleMatchMode 2" to specify ANY substring of the window
title you want to match. Windows titles is case *sensitive* also.
Quote:
> Regards,
> Torgeir
> <qoute>
> AutoIt is a simple tool that can simulate key presses, mouse movements and
window commands (maximize, minimize, wait for, etc.) in order to automate
any windows based task (or even windowed DOS tasks).
Quote:
> AutoItX is an ActiveX control version of AutoIt. It allows you to perform
the following types of functions:
Quote:
> Sending keystrokes and mouse clicks (all characters, keyboard layout
independent).
> Window functions (e.g. minimizing, hiding, restoring, waiting for,
activating (even under Win98/NT2000)).
Quote:
> Sleep (for those with WSH 1.0 :) )
> INI file reading and writing.
> Simple clipboard (text) commands.
> Shutdown and reboot commands (including a forced reboot that works under
both 9x and NT).
> Blocking input under Windows NT4 SP6 and 2000.
> Best of all, its small and FREE!
> </qoute>
> > 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. I am facing an issue which involves closing
the DOS window which is running a batch file. I tried sending "^C" twice,
but that does not work. The first one is caught, but then the user is
prompted for input. The only way I seem to be able to close the window using
keystrokes without user intervention is via (ALT+SPACE+C). Manually this can
be done but programmatically,
Quote:
> > 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.