Results 1 to 5 of 5

Thread: [vb2008] Press the button of an external not foreground / minimized window

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2009
    Posts
    463

    [vb2008] Press the button of an external not foreground / minimized window

    known the external window size, it Hwnd and the x/y coordinates of the button to press, I am trying this code, like seen on the web:

    Code:
        <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function PostMessage(ByVal hWnd As IntPtr, _
        ByVal Msg As  UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
        End Function
    
        Const WM_LBUTTONDOWN As UInteger = &H201
    
        'button X coordinates, tried both X => respect to it window coordinates
        'and X respect to Screen coordinates (when the window is not minimized)
        Dim X as Integer = ....     
    
        'button Y coordinates, tried both Y => respect to it window coordinates 
        'and Y respect to Screen coordinates (when the window is not minimized)
        Dim Y as Integer = ....   
     
        Dim Hwnd as IntPtr = ...   ' external window handle
    
        PostMessage(Hwnd, WM_LBUTTONDOWN, IntPtr.Zero, MakeLParam(X, Y))
    
    
        Private Function MakeLParam(ByVal LoWord As Integer, ByVal HiWord As Integer) As IntPtr
    
            Return New IntPtr((HiWord << 16) Or (LoWord And &HFFFF))
    
        End Function
    but nothing happens, both if the external window is in foreground, NOT in foreground or minimized...

    what's wrong?

    ty
    Last edited by phil2000; Dec 28th, 2010 at 09:15 PM.

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