Re: WScript & Sendkeys

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



hi ken,

I'm confused.  Did you mean vbSCRIPT or vb -- as in VISUAL BASIC.

If you meant visual basic, then you don't need the scripting versions
of appactivate and sendkeys.  VB has its own appactivate and sendkeys,
(as well as a sleep api as mentioned above).

However, that being said, I suggest that there is a more effective
way to go about "filling in a form".  I suggest instantiating internet
explorer, navigating to the html page with the form, hooking into the
page's "document object model", and filling in the form by setting
appropriate values into the input tag elements on the form.

You can find plenty of examples of this approach on the scripting ng's.
Search the group archives for "InternetExplorer.Application".

cheers, jw

Ken Nelson wrote:
I need to write a program in VB that automatically goes out to a website and uses the SendKeys function to fill it in for me.

I have been researching WScript Shell & SendKeys and was given the following code snippit:

Private Sub Command1_Click()
Set wshshell = CreateObject("Wscript.Shell")
wshshell.Run "Notepad"
wshshell.AppActivate ("notepad")
wscript.sleep 500
wshshell.SendKeys "Hello, World!"
End Sub

When I run it, I get "Object Required" on the "wscript.sleep 500" line. That is one problem, the second is I want to open up a web page in IE, not notepad, so wanted to change it to look something like:

Private Sub Command1_Click()
strURL = "http://www.google.com";
Set wshshell = CreateObject("Wscript.Shell")
wshshell.Run (strURL)
x=wshshell.AppActivate (strURL)
wscript.sleep 500
wshshell.SendKeys "Hello, World!"
End Sub

The .AppActivate is not working (x turns out to be false)...so what do I need in teh AppActivate instead of strURL?

I appreciate any help

Ken Nelson
.



Relevant Pages

  • Re: Runas
    ... > running runas process than using appactivate and sendkeys? ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.scripting.vbscript)
  • Re: Runas
    ... > running runas process than using appactivate and sendkeys? ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windowsxp.wmi)
  • Re: Runas
    ... > running runas process than using appactivate and sendkeys? ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.inetsdk.programming.scripting.vbscript)
  • Re: simple timer required
    ... WaitFor ... SendKeys strDocument ... I just tried AppActivate and SendKeys but could not get the examples to ... lngReturn = ShellExecute(_ ...
    (microsoft.public.vb.general.discussion)
  • Re: [HELP] closing a program with VBA code
    ... > AppActivate "IML Device 1", ... > SendKeys "%", False ... > DoEvents ...
    (microsoft.public.excel.programming)