?
Solved

Controlling applications with VBScript/VB6

Posted on 2007-10-18
2
Medium Priority
?
348 Views
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.
0
Comment
Question by:tom_v_olsen
2 Comments
 
LVL 23

Assisted Solution

by:basicinstinct
basicinstinct earned 180 total points
ID: 20107805
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
http://msdn2.microsoft.com/en-us/library/sx7b3k7y.aspx
0
 
LVL 31

Accepted Solution

by:
Frosty555 earned 195 total points
ID: 20125154
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().

AllAPI.net has two very good examples of using the functions in VB6:

http://allapi.mentalis.org/apilist/keyb_event.shtml
http://allapi.mentalis.org/apilist/mouse_event.shtml

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
    DoEvents
Loop
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Suggested Courses

621 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