?
Solved

SendKey

Posted on 2011-03-11
8
Medium Priority
?
736 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 86

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 35118378
0
 
LVL 2

Author Closing Comment

by:PhilChapmanJr
ID: 35118873
Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 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…
Suggested Courses
Course of the Month9 days, 10 hours left to enroll

762 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