Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vb Menu activation (no SendKeys)

Status
Not open for further replies.

CP60

Programmer
Oct 16, 2008
145
DE
How would I get a the MDI child menu, which is the parent of yet another child element, to show it self (with out causing the click event to fire) without using SnedKeys?

-Level 1
- Sub 1
- Sub 2

This should show:

-Level 1
- Sub 1

The only way I know of is by using SendKeys:
Call SendKeys("%{L}{1}", True)
 
Rhis is what I have:
Code:
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal code As Long, ByVal maptype As Long) As Long
Private Declare Sub keybd_event Lib "user32" (ByVal vk As Byte, ByVal scan As Byte, ByVal Flags As Long, ByVal extra As Long)
Private Declare Function VkKeyScan Lib "user32" Alias "VkKeyScanA" (ByVal c As Byte) As Integer

Public Sub OpenMenuItem(aryKeys() As String)
    Const KEYTAB = &H12
    Dim vKey As Variant
    
    Dim ksKey As Integer
    Dim vkKey As Integer
    Dim vkAlt As Integer
    
    vkAlt = MapVirtualKey(KEYTAB, 0)
    
    Call keybd_event(KEYTAB, vkAlt, 0, 0)
    Call keybd_event(KEYTAB, vkAlt, &H2, 0)
    
    For Each vKey In aryKeys
        ksKey = VkKeyScan(Asc(vKey)) And &HFF
        vkKey = MapVirtualKey(ksKey, 0)
    
        Call keybd_event(ksKey, vkKey, 0, 0)
        'Call keybd_event(ksKey, vkKey, &H2, 0)
    Next vKey

End Sub

and calling like this:

Dim aryKeys(2) As String
aryKeys(0) = "S"
aryKeys(1) = "R"
aryKeys(2) = "P"
Call OpenMenuItem(aryKeys)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top