Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SendKeys Skipping the first send

Posted on 1999-01-20
5
162 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 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…

829 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