Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WScript.Shell SendKeys to close a DOS window
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00474022
Message ID:
00474213
Views:
26
>>>Can you use sendkeys to close a DOS window that was started using:
>>>
>>>oShell = CREATEOBJECT('WScript.Shell')
>>>oShell.Run('postal "customer"')
>>>
>>>The DOS window is asking for Ctrl+C to close the window. I was trying this instead of the run postal "customer" so that I can close the window programatically.
>>>
>>>Per the MSDN I tried
>>>
>>>oshell.SendKeys "^c"
>>>
>>>and
>>>
>>>oshell.SendKeys "%{F4}"
>>>
>>>I'm getting a syntax error.
>>>
>>>Regards,
>>>
>>Steve
>>
>>Is the code you're executing within Fox and as shown above? If so, you need parameters to pass the key codes.
>
>What's the syntax for that? I also tried this from the MSDN with no success:
>
>From MSDN: The parameter passed AppActivate is the caption of the recipient program's main window.
>
>oShell.AppActivate("postal") && This is the caption of the DOS window.
>I get unknown name error code.
>
>From MSDN: The SendKeys syntax is
> WshShell.SendKeys (bstrKeys As String, [pvarWait])
>
>Tried this, too.
>
>oSHell.sendkeys("^C")
>oSHell.sendkeys("^C",.f.)

I meant parenthesis, sorry. Some keycodes don't work from within Fox. In this case, you'd need to use either the SendMessage() or PostMessage() API calls to send the appropriate keycodes to the window.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform