Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 4th, 2003, 05:22 PM
Authorized User
 
Join Date: Sep 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default automation!

Hello All, I didn't know which forum section to post this, but I thought I should start here. I have a non-microsoft written program which keeps track of some documents ( it is called Q-Pulse). at the end of every week I need to go to this program, open it up verify table indexes and compact tables. Basically, click on 3 buttons. I want to know if it is possible to automate this process. I have looked at some automation softwares such as AutoMate which is really awesome but really expensive, and I don't have that kind of money. I have tried to use a batch file and try to send keystrokes to the program. Is it possible to do such a thing!? I'm open to try any suggestions!

Thanks in advance,

Khalfieh
__________________
Sam Gharnagh
Jr. Programmer Analyst at MOH
Comp Sci at UofW
 
Old November 5th, 2003, 09:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Here is a last resort method of doing it and it may not work with all non-Microsoft programs because of communication problems. Now suppose the three buttons can be activated not only by clicking but by pressing ALT-A, ALT-B, and ALT-C, respectively. Also assume the program's Exit button can be clicked or you can press ALT-X.

Create an Access database with one form on it. Put a checkbox and make sure its default value is FALSE (or UNchecked). Set the form's Timer Interval to, say, one hour. Then on the On Timer event code that if the current time is, say, after midnight, then execute the following:
Code:
   Dim dblRetVal as Double

      If Not Me.chkDone Then
          dblRetVal = Shell("C:\Q-PULSE\Q-PULSE.EXE", 3)

          If dblRetVal = 0
             Msgbox "Q-PULSE has encountered an error.", vbExclamation, "Error!"
          Else
             SendKeys "%A", True 'First Button
             SendKeys "%B", True 'Second Button 
             SendKeys "%C", True 'Third Button
             SendKeys "%X", True 'Exit Button
          End If

          Me.chkDone = True
      End If
Open the database and form and leave it open while you're gone. After it runs, the checkbox will be true and the code will not run again.

Notes: The directory and EXE file in the SHELL function will probably be named something else. Check Q-PULSE's buttons and see if they have labels with one letter underlined. If so, it probably means that to activate that button without clicking, you can press ALT- and that letter. Use those letters instead of A, B, C, and X in my example.

If you buttons cannot be activated through the keyboard via ALT keys, you may have to use the SENDKEY function like this
Code:
   SendKeys "{TAB}{TAB}{ENTER}", True  'Tab to the correct button & press it
   SendKeys "{TAB}{ENTER}", True  'Tab to the next button & press it
You'll have to open Q-PULSE manually and count the correct number of tabs to code.


This is messy and, again, it's last resort.




Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old November 5th, 2003, 09:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

FYI. I made some changes to the code to prevent it from running more than once. You won't see it if you're getting this in e-mail. Please check the forum.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old November 5th, 2003, 11:31 AM
Authorized User
 
Join Date: Sep 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey greg,
thanks for you help! I ll definitely try it! I was thinking, I should be able to do something like that, but there is problem. When I start the program, as default it is on a different window (menu). On the side there are a few buttons (image buttons which do not have any short cuts to them. so I think you have to click on them. I tried tab, ctrl-tab, but nothing worked yet!). I need to go to a different menu by clicking one of those buttons then I can use shortcuts like alt-a....
do u know if there is a way of moving the mouse or giving the mouse coordinates to simulate a click, in VB???
or any other ideas? thanx!
If you want screenshot of the program, i can send them to you!

thanks,
Sam
 
Old November 6th, 2003, 12:47 PM
Authorized User
 
Join Date: Sep 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks alot Greg! I used sendkey for keystroke and mouse_event for mouse simulation.

Sam Gharnagh
Jr. Programmer Analyst at MOH
Comp Sci at UofW
 
Old October 26th, 2006, 12:40 PM
Registered User
 
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, everybody here seems have some experience on Shell object.
I am having a problem with code below. It runs coorectly in .NET studio (VS8). But once I loaded the file to c:\inetpub\wwwroot\.. and launch it there. The EXPLORER does not work. The return value is not 0. Can anybody tell me why? Thanks in advance!

Protected Sub lbOpenFolder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbOpenFolder.Click
        Dim dblRetVal As Double
        Dim sCmdLine As String
        Dim sPath As String
        'sPath = "\\servername\path"
        sPath = "X:\subdir"

        ' sCmdLine = "EXPLORER /E," & sPath
        sCmdLine = "C:\windows\EXPLORER.exe /E," & sPath

        dblRetVal = Shell(sCmdLine, AppWinStyle.NormalFocus)
        lblRtnVal.Text = dblRetVal 'for testing

    End Sub

 
Old October 26th, 2006, 12:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there

maybe a problem with the IIS?? you are trying to execute something that is outside the site...

HTH

Gonzalo





Similar Threads
Thread Thread Starter Forum Replies Last Post
IE automation kg8299 Excel VBA 3 June 8th, 2010 02:43 PM
IE Automation jrogers Excel VBA 1 May 3rd, 2007 06:39 AM
automation ASCIIMAN Pro VB 6 1 January 29th, 2007 02:25 PM
Excel Automation ameysun Pro VB 6 0 November 4th, 2004 02:55 AM
help with automation nicka Access VBA 1 December 12th, 2003 05:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.