Solved

SendKey

Posted on 2011-03-11
8
725 Views
Last Modified: 2012-05-11
I'm needing to send key strokes to a old DOS program run under MultiView 2000 Terminal Emulator and everything is working ok until I send a SendKey {F7}.

After each SendKey i do a brief sleep.

I do not get a error it just does not do anything.  Any help would be appreciated.

Dim SecPauseTime as Integer
SecPauseTime = 15

AppActivate extAppName
Sleep iSecPauseTime * 10

SendKeys 2
Sleep iSecPauseTime

SendKeys {ENTER}
Sleep iSecPauseTime

SendKeys PIES
Sleep iSecPauseTime

SendKeys {ENTER}
Sleep iSecPauseTime

SendKeys {F7}
Sleep iSecPauseTime


0
Comment
Question by:PhilChapmanJr
  • 5
  • 2
8 Comments
 
LVL 5

Expert Comment

by:BrianVSoft
Comment Utility
I assume you see that  the "sendkeys 2" puts a "2" in a field on "extAppName"..
a. SendKeys requires that the OtherApp has focus.. Does it appear to still have focus at the F7?
b. Maybe the {Enter} takes focus away from the Text entry field on "OtherApp" - F7 might not do anything if focus is not where it should be.
b. If you manually click on the OtherApp and press F7, does that work?
0
 
LVL 2

Author Comment

by:PhilChapmanJr
Comment Utility
SendKets 2 puts a 2 in the other application
The other application still has focus
If you press F7 while in the other application it does what it suspose to do.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Try sending F7 with the keybd_event() API instead:
Const VK_F7 = &H76

Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long

...
        keybd_event VK_F7, MapVirtualKey(VK_F7, 0), 0, 0 ' key down
        keybd_event VK_F7, MapVirtualKey(VK_F7, 0), 2, 0 ' key up

Open in new window

0
 
LVL 2

Author Comment

by:PhilChapmanJr
Comment Utility
Idle Mind,
When I mix SendKeys with Keybd_event and MapVirtualKet it gets the sequence out of order
.
How would I get the values of
Example:
strTemp = "ABC123"
so I can just used the API calls?

I  tride passing the API calls the
ASC(MID(strTemp ,I,1))
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Author Comment

by:PhilChapmanJr
Comment Utility
Correction:
strTemp = "ABCabc123"
Does not work using ASC values
0
 
LVL 2

Author Comment

by:PhilChapmanJr
Comment Utility
I see what the problem is it's looking at my Caps lock
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
0
 
LVL 2

Author Closing Comment

by:PhilChapmanJr
Comment Utility
Thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

16 Experts available now in Live!

Get 1:1 Help Now