Solved

sendkeys

Posted on 2001-06-22
8
331 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
ID: 6220522
AppActivate "Caption Of Setup.exe"
SendKeys "{ENTER}", True
0
 

Expert Comment

by:RichardVBman
ID: 6220540
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
ID: 6220577
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:patrickm3
ID: 6223168
I've never used vb--could you tell me where to paste this stuff in?
0
 

Author Comment

by:patrickm3
ID: 6223189
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
ID: 6223514
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
ID: 6224809
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
ID: 6494593
thanks for the points, but why the B grade?
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

786 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