Results 1 to 2 of 2

Thread: SendMessage CTRL+M

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2011
    Posts
    2

    SendMessage CTRL+M

    Yes, I searched and all threads related to this problem have not been solved properly.

    No, I don't want to use SendKeys, because It needs focus + doesn't work on Vista/7.

    How can i send a message to an application in the background/minimized to tray with the keys: CTRL + M

    This is what I've got:
    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
    
    Private Const WM_KEYDOWN = &H100
    Private Const WM_KEYUP = &H101
    Private Const VK_CONTROL = &H11
    Private Const VK_M = &H4D
    
    Private Sub Form_Load()
    Dim a As Long
    Dim b As Long
    
    a = FindWindow(vbNullString, "Untitled - Notepad") 'Example1
    b = FindWindowEx(a, 0&, "Edit", vbNullString) 'Example2
    'MsgBox a
    
    SendMessage b, WM_KEYDOWN, VK_CONTROL, vbNullString
    SendMessage b, WM_KEYDOWN, VK_M, vbNullString
    SendMessage b, WM_KEYUP, VK_M, vbNullString
    SendMessage b, WM_KEYUP, VK_CONTROL, vbNullString
    End Sub

  2. #2

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