+ Reply to Thread
Results 1 to 4 of 4

How Do I Use VB Scripting Send Keystrokes?

  1. #1
    Registered User
    Join Date
    08-28-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Question How Do I Use VB Scripting Send Keystrokes?

    Hello all,

    I have a Visual Basic script in a spreadsheet that allows me to double-click a cell, and open a telnet session to a particular IP address. As seen below:

    Please Login or Register  to view this content.
    My goal is to have the script perform a series of keystrokes; so I can get past the banner, username and password prompts, and into the Command Line of a switch.

    The order of these keystrokes are as follows:
    CTRL+Y (Proceed past banner page)
    username (the username of the switch)
    Enter (to input the username and proceed to password field)
    password (the password of the switch)
    Enter (to input the password and proceed to the command line interface)


    If anyone could help me with this, it would be greatly appreciated!

    Thanks

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: How Do I Use VB Scripting Send Keystrokes?

    Hi again,

    I found some sites that walked through the process. You should be able to use code similar to the following (using your path and strings). Below the code is a link to the SendKeys function so you know how to send a CTRL or ENTER, etc. The wait time allows the window to appear, take focus and be ready for commands to be sent. Otherwise the VBA sends it too fast and you'll get some error.

    Hope this helps!
    Please Login or Register  to view this content.
    SendKeys: http://msdn.microsoft.com/en-us/libr...ffice.15).aspx
    SendKeys to other app: http://www.java2s.com/Code/VBA-Excel...pplication.htm
    AppActivate error: http://vbcity.com/forums/t/81315.aspx (first reply by Russell Judge)

  3. #3
    Registered User
    Join Date
    08-28-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: How Do I Use VB Scripting Send Keystrokes?

    Hi again Paul

    Thanks a lot for this, and your previous telnet script. I will tinker around with this and let you know how it goes.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: How Do I Use VB Scripting Send Keystrokes?

    Nice job, Paul.

    I have had success in similar situations using SendKeys on Vista machines. On Windows 7, I had to turn UAC off (which is not recommended) to get SendKeys to work.

    UAC refererences:
    http://www.howtogeek.com/howto/windo...-command-line/
    http://www.howtogeek.com/howto/4820/...-on-windows-7/

    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Prompt for KeyStrokes
    By publius190 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-20-2014, 11:54 AM
  2. Run macro with keystrokes
    By capngene in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2012, 10:47 PM
  3. send keystrokes to non excel window
    By martinez_pedro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2010, 11:59 PM
  4. Using VB script to send keystrokes to another program
    By tonymorton@googlemai in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-03-2008, 04:18 PM
  5. keystrokes from messagebox
    By scottwilsonx in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2005, 09:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1