Solved

creating "winbatch" type batches

Posted on 2001-09-10
6
295 Views
Last Modified: 2008-03-06
is it possible to create batch programs, similar to what winbatch can do, in VB6?

for example launch an application from the shell and operate it from VB6; move the mouse, choose menu items,...,do user type of actions.

a simple example would be: from VB6 open internet explorer browser, call hotmail.com, send a message, close IE. Winbatch does that but I was wondering if I could do it from VB6 instead? thank you
0
Comment
Question by:lorynthia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6472485
This could be done using microsoft html object library.
I did a little app to put password/user in hotmail and go directly to inbox folder:

VERSION 5.00
Begin VB.Form frmHotmail
   Appearance      =   0  'Flat
   BackColor       =   &H80000004&
   Caption         =   "Hotmail login"
   ClientHeight    =   1290
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3660
   Icon            =   "frmHotmail.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   1290
   ScaleWidth      =   3660
   StartUpPosition =   2  'CenterScreen
   Begin VB.PictureBox Picture1
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   525
      Left            =   2100
      Picture         =   "frmHotmail.frx":08CA
      ScaleHeight     =   495
      ScaleWidth      =   1350
      TabIndex        =   5
      Top             =   1680
      Width           =   1380
   End
   Begin VB.CommandButton Command1
      Caption         =   "&Logon"
      Enabled         =   0   'False
      Height          =   375
      Left            =   2340
      TabIndex        =   4
      Top             =   840
      Width           =   1215
   End
   Begin VB.TextBox Text1
      Height          =   315
      IMEMode         =   3  'DISABLE
      Index           =   1
      Left            =   900
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   420
      Width           =   2715
   End
   Begin VB.TextBox Text1
      Height          =   315
      Index           =   0
      Left            =   900
      TabIndex        =   1
      Top             =   60
      Width           =   2715
   End
   Begin VB.Label Label1
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Password:"
      Height          =   195
      Index           =   1
      Left            =   60
      TabIndex        =   2
      Top             =   420
      Width           =   735
   End
   Begin VB.Label Label1
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Username:"
      Height          =   195
      Index           =   0
      Left            =   60
      TabIndex        =   0
      Top             =   60
      Width           =   765
   End
End
Attribute VB_Name = "frmHotmail"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim WithEvents IE As InternetExplorer
Attribute IE.VB_VarHelpID = -1
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_MAXIMIZE = 3

Private Sub Command1_Click()
IE.navigate "www.hotmail.com"
End Sub

Private Sub Form_Load()

Set IE = New InternetExplorer
With IE
    .Visible = True
    .navigate "about:blank"
    ShowWindow .hwnd, SW_MAXIMIZE
    Do While .Busy <> False
        DoEvents
    Loop
    Command1.Enabled = True
End With
End Sub



Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is IE) Then
    On Error Resume Next
    Dim HDoc As HTMLDocument
    Dim txt As HTMLInputElement
    Set HDoc = IE.document
    If InStr(1, URL, "passport.com/cgi-bin/login", vbTextCompare) Then
        For Each txt In HDoc.body.All
            Select Case UCase$(txt.Name)
            Case "LOGIN"
                If Text1(0).Text = "" Then
                    txt.Value = "anonymous"
                Else
                    txt.Value = Text1(0).Text
                End If
            Case "PASSWD"
                If Text1(1).Text = "" Then
                    txt.Value = "pwd"
                Else
                    txt.Value = Text1(1).Text
                End If
            Case "ENTER"
                txt.Click
                Exit For
            End Select
        Next
    Else
        Dim HAnchor As HTMLAnchorElement
        For Each HAnchor In HDoc.body.All
            If UCase$(HAnchor.innerText) = UCase$("inbox") Then
                HAnchor.Click
                Unload Me
            End If
        Next
    End If
   
End If
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6472493
By the way, i don't know what is "winbatch"...sorry.
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 50 total points
ID: 6472498
You can do these things, but VB is more geared to creating components and standalone applications than to manipulating other applications, so it isn't always easy.  It generally requires a fair amount of knowledge of Windows API programming to be able to manipulate other programs successfully.

The other main difference between a programming language like VB and a scripting language like Winbatch is that a VB program must be compiled to an executable format to run.  Winbatch scripts are just text files that are interpreted by the winbatch executable which does all the heavy lifting.  

Windows has it's own scripting language, VBScript.  It is fairly limited in what you can do with it in terms of manipulating other programs, but you can extend it with components you create in VB.  Not necessarily easy to do, but possible.

Ultimately, you could even write your own version of Winbatch using VB, but this is a major undertaking.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6473079
"...It is fairly limited in what you can do with it
in terms of manipulating other programs..."
Paul, vbscript is a powerfull scripting language, you could manipulate COM-aware apps just LIKE (note like in uppercase) VB.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6473158
>you could manipulate COM-aware apps just LIKE (note
like in uppercase) VB.<


Yes, but that requires them to be COM aware.  There are so many programs that aren't.  The main problem in VBScript is no access to the API.  Sending messages to windows using the API, manipulating a windows position, simulating key strokes and menu clicks, this can be done in VB, but not in VBScript.  If you've ever used Winbatch, then you know it allows this kind of macro-like action, but not in VBScript.  

You are right that you have a fair amount of control over the main Microsoft products and a few others that have adopted exposing an object hierarchy through COM.
0
 

Author Comment

by:lorynthia
ID: 6506704
thank you very much.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

696 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