Solved

SendKey

Posted on 2011-03-11
8
726 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

895 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