creating "winbatch" type batches

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
lorynthiaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
PaulHewsConnect With a Mentor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
Richie_SimonettiIT OperationsCommented:
By the way, i don't know what is "winbatch"...sorry.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Richie_SimonettiIT OperationsCommented:
"...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
 
PaulHewsCommented:
>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
 
lorynthiaAuthor Commented:
thank you very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.