Solved

SendKey

Posted on 2011-03-11
8
728 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
[X]
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
  • 5
  • 2
8 Comments
 
LVL 5

Expert Comment

by:BrianVSoft
ID: 35115043
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
ID: 35116158
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
ID: 35116414
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:PhilChapmanJr
ID: 35117909
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
 
LVL 2

Author Comment

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

Author Comment

by:PhilChapmanJr
ID: 35118072
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
ID: 35118378
0
 
LVL 2

Author Closing Comment

by:PhilChapmanJr
ID: 35118873
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro: print each sheet to pdf using ExportAsFixedFormat 11 63
Advice in Xamarin 21 109
Problem to line 23 74
Set WorkSheet  not Working 9 51
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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

749 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