Results 1 to 3 of 3

Thread: PostMessage Key Constants

  1. #1
    zchoyt
    Guest

    PostMessage Key Constants

    I am sending messages to other windows using the PostMessage API. For example, I open calc and send it the Ctrl+V message (which is the hotkey for paste). That works OK. The problem comes when I want to send and Alt+something command. I don't know the constants for alt, and they are not in the KeyCodeConstants enum. Please help.

    Here is what I have now:
    VB Code:
    1. Private Sub Command2_Click()
    2.     Dim winhwnd As Long
    3.     winhwnd = FindWindow(vbNullString, "calculator")
    4.  
    5.     PostMessage winhwnd, WM_KEYDOWN, vbKeyControl, 0
    6.    
    7.     PostMessage winhwnd, WM_KEYDOWN, vbKeyV, 0
    8.     PostMessage winhwnd, WM_KEYUP, vbKeyV, 0
    9.    
    10.     PostMessage winhwnd, WM_KEYUP, vbKeyControl, 0
    11.  
    12. End Sub

  2. #2
    New Member
    Join Date
    Jul 2002
    Location
    Fort Worth, TX
    Posts
    3
    Const VK_MENU = &H12 'ALT Button
    Const VK_LMENU = &HA4 'Specifically Left Alt button

    Hope this helps
    "If at first you dont succeed, call if version 1.0"

    Nickolas

  3. #3
    zchoyt
    Guest
    I can't get it to work. I am trying to send menu commands to the calc. It just presses the "E" button on the calculator (in

    VB Code:
    1. Private Sub Command2_Click()
    2.     Dim winhwnd As Long
    3.     winhwnd = FindWindow(vbNullString, "calculator")
    4.  
    5.     PostMessage winhwnd, WM_KEYDOWN, vbKeyMenu, 0
    6.    
    7.     PostMessage winhwnd, WM_KEYDOWN, vbKeyE, 0
    8.     PostMessage winhwnd, WM_KEYUP, vbKeyE, 0
    9.    
    10.     PostMessage winhwnd, WM_KEYUP, vbKeyMenu, 0
    11.  
    12. End Sub


    The control button works (like in the first post)

    Help Help Help!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width