CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2014
    Posts
    1

    VBScript(SendKeys)

    I am trying to create a VBS to send keystrokes to an application and basically autofill a registration form so i dont have to do it literally, about 500 times.... once per computer. This is the scripts I have completed so far...

    It brings the proper window to the front, and then does nothing. If I were to press any key on the keyboard, it begins typing in the selected field. If i reference it to bring up an open notepad, it type accordingly there. I am not the greatest at VBscript and mostly just pull things from various sources and try to make them work together.

    Code:
    Set WshShell = WScript.CreateObject("WScript.Shell")
    
    'WshShell.Run "VSPACE"
    WshShell.AppActivate "License Wizard"
    WScript.Sleep 500
    
    
    ' name
    WshShell.Sendkeys "RPS"
    WshShell.Sendkeys "{TAB}"
    'Company
    WshShell.Sendkeys "ROCKLAND PUBLIC SCHOOLS"
    WshShell.Sendkeys "{TAB}"
    'Country
    WshShell.Sendkeys "{TAB}"
    'Address
    WshShell.Sendkeys "52 MACKINLAY WAY"
    WshShell.Sendkeys "{TAB}"
    'City
    WshShell.Sendkeys "ROCKLAND"
    WshShell.Sendkeys "{TAB}"
    'State
    WshShell.Sendkeys "MA"
    WshShell.Sendkeys "{TAB}"
    'zip
    WshShell.Sendkeys "02370"
    WshShell.Sendkeys "{TAB}"
    'email
    WshShell.Sendkeys "TECHNOLOGY@ROCKLANDSCHOOLS.ORG"
    WshShell.Sendkeys "{TAB}"
    'phone
    WshShell.Sendkeys "7818718415"
    WshShell.Sendkeys "{TAB}"
    'reseller
    WshShell.Sendkeys "OCKERS"
    WshShell.Sendkeys "{TAB}"
    'type
    WshShell.Sendkeys "{TAB}"
    'next
    WshShell.Sendkeys "{TAB}"
    WshShell.Sendkeys "{TAB}"
    WshShell.Sendkeys "{ENTER}"
    WshShell.Sendkeys "{TAB}"
    WshShell.Sendkeys "{TAB}"
    WshShell.Sendkeys "{ENTER}"
    WshShell.Sendkeys "{ENTER}"
    WshShell.Sendkeys "{ENTER}"
    WshShell.Sendkeys "{ENTER}"

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VBScript(SendKeys)

    You didn't say what KIND of form, and who calls it up and how?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured