Controlling applications with VBScript/VB6

Posted on 2007-10-18
Last Modified: 2010-04-24
I have become pretty good at writing VB code within the Excel environment.  I would like to expand and attempt to create keystokes (like a macro) in other applications (non-microsoft but most likely VB based).  What is the best direction for me to go?  I have the VB6 programming environment installed.  Also, are we talking about the same thing when we say VBScript and simply programming with VB code?  Thank you.
Question by:tom_v_olsen
    LVL 23

    Assisted Solution

    1. sending keystrokes to other apps from vb/vba/vbs - use sendkeys (and appactivate)
    2. vbscript is different to vb, the syntax is a little different, but not hard to learn if you know vb/vba
    LVL 31

    Accepted Solution

    There is a more low-level windows api method of emulating keystrokes and mouse movements.

    Use the two api functions keybd_event() and mouse_event(). has two very good examples of using the functions in VB6:

    Remember it will be the active window that receives the keystroke/mouseclick. Exactly as though you were to click the mouse or hit a keyboard button on your keyboard. So you need to make sure the app has the focus when the vb code executes.

    It'd probably do you good to learn how to make little sleeping loops in your vb app... you will need to wait for a few milliseconds before performing the next action.... give the application a chance to work!

    something like:

    nStart = Timer
    Do Until Timer - nStart > 0.5       '  half a second

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (…
    When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now