Solved

sendkeys

Posted on 2001-06-22
8
328 Views
Last Modified: 2010-08-05
What do I need to add to this --

I'm trying to run setup.exe and have(enter) pressed when the dialog pops up???




Private Sub form_load()



Shell ("command.com /c c:\windows\desktop\setup.exe"), vbHide
SendKeys (enter)
End Sub
0
Comment
Question by:patrickm3
8 Comments
 
LVL 6

Expert Comment

by:JonFish85
Comment Utility
AppActivate "Caption Of Setup.exe"
SendKeys "{ENTER}", True
0
 

Expert Comment

by:RichardVBman
Comment Utility
I agree with JonFish85; you might also need to create a time delay between the activation of the form and the sendkeys statement (you'll need to adjust the forms timer interval to suit your own needs):

AppActivate"Caption Of Setup.exe"
Call Delay(10)
SendKeys "{ENTER}",True

'Paste this Function in the declarations section

Function Delay(lngDelay as long)

dim StartTime as long

StartTime = Timer
While Timer <> StartTime + lngDelay
   Doevents
Wend

End sub
0
 
LVL 6

Expert Comment

by:JonFish85
Comment Utility
Hello RichardVBMan! I notice that you are fairly new to EE. Here at EE, experts usually choose to post always with comments, as a proposed answer locks the question and moves it to the "Answered Questions" section. Also, your "answer" is basically the same as mine, just with revisions. Please just keep in mind that it is generally better to just use comments, since the questionerre can accept a comment as an answer. Just thought I'd let you know!
0
 

Author Comment

by:patrickm3
Comment Utility
I've never used vb--could you tell me where to paste this stuff in?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:patrickm3
Comment Utility
I've never used vb--could you tell me where to paste this stuff in?
0
 
LVL 6

Accepted Solution

by:
JonFish85 earned 200 total points
Comment Utility
try something like this:

Private Sub Form_Load()
  Shell "C:\Path\To\Setup\Setup.exe", vbNormalFocus
  DoEvents
  DoEvents
  'Replace "caption" with the caption of
  'the main setup.exe
  AppActivate "Caption", True
  DoEvents
  SendKeys "{ENTER}", True
End Sub
0
 
LVL 1

Expert Comment

by:Form_Glow
Comment Utility
Why use SENDKEYS?
Just Loop until you get the handle of the "OK" button or whatever..

Do:Doevents
x = get the handle of button to click
loop until x

Call SendMessage(x, WM_LBUTTONDOWN, 0&, 0&)
Call SendMessage(x, WM_LBUTTONUP, 0&, 0&)
 
0
 
LVL 6

Expert Comment

by:JonFish85
Comment Utility
thanks for the points, but why the B grade?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

10 Experts available now in Live!

Get 1:1 Help Now