Results 1 to 3 of 3

Thread: Sending Buttonclick to another program

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170
    Thanks for reading this!

    I'm looking for a good way to fire a "faked" buttonclick to another windows program written in C. Being that a buttonclick is nothing more than a "windows message", I would think that would easily be possible.

    Second issue:

    Would it be possible to click a toolbar button in another program with code?

    Thanks for any info!
    Phil

  2. #2
    Guest
    Code:
    Public 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
    Declare Function findwindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Declare Function SendMessageByNum& Lib "User32" Alias "SendMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
    
    Public Const WM_LBUTTONDOWN = &H201
    Public Const WM_LBUTTONUP = &H202
    
    
    Sub Click(Wh)
    DoEvents
    X = sendmessagebynum(Wh, WM_LBUTTONDOWN, 0, 0&)
    X = sendmessagebynum(Wh, WM_LBUTTONUP, 0, 0&)
    End Sub
    
    
    Use:
    
    'x = Findwindow(hwnd, vbnullstring)
    'button = FindWindowEx(hwnd, 0&, "button", vbNullString)
    'Click button
    Something like that.


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170

    Excellent, but....

    Looks pretty good Matt, but have you had any experience with "clicking" another programs toolbar buttons? How could this be accomplished?


    The application I have to develop must be able to do one simple thing:

    Click the "Save" button on the other program. The other program is pretty old (writen in Win31 days I believe). Unfortunatly there are no hotkeys to "send" so only a "click" will work.


    I owe someone a big ol beer if they figure this one out before I do!!

    Philip

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