Solved

SendKeys Skipping the first send

Posted on 1999-01-20
5
156 Views
Last Modified: 2012-05-04
This is the first part of my program.  The first TAB will not function. There are other TABs in the program that do work. I have tried putting a timer after the App is Activated.

Private Sub Command1_Click()
    AppActivate "Merchant Management", True
    SendKeys "{tab}", True
    SendKeys "E", True
0
Comment
Question by:matthewkwp
5 Comments
 
LVL 4

Accepted Solution

by:
chabaud earned 100 total points
ID: 1469673
Try this alternate code (which send Alt+E):

AppActivate "Merchant Management", True
SendKeys "%E", True
0
 
LVL 3

Expert Comment

by:sduckett
ID: 1469674
I've tested very similar code using Word instead of your app as I don't have "Merchant Management".
The code works, but it does depend on the state of the App at the time the code is run. eg. If the cursor is in a document at the time it runs a tab is placed there, if a dialog box is open, a tab is sent to that dialog box.
Can you be confident that the app is in the state you expect at all times? What actually happens if you switch to Merchant Management and press 'tab'?

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1469675
Yeah, SendKeys tends to be state dependent. You're much safer sending explicit Ctrl-this, Alt-that's than assuming that "two tabs" are going to activate some function.

M

0
 

Author Comment

by:matthewkwp
ID: 1469676
Alt/Ctrl won't work.  I also tried this in a 'Notepad' Window and had the same results.
0
 
LVL 4

Expert Comment

by:chabaud
ID: 1469677
Try insert DoEvents statement between your SendKeys.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

760 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

17 Experts available now in Live!

Get 1:1 Help Now