Results 1 to 5 of 5

Thread: How to get another application's window width [Help]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Resolved How to get another application's window width [Help]

    Hello,
    I am working in a vb6 project in which i want to get the width and height of another 3rd party application. But I am not getting which API can be done it.

    Name:  Untitled.png
Views: 403
Size:  279.2 KB


    Please check the snapshot in which I want to get the width of Notepad window.

    Thanks
    Last edited by green.pitch; Nov 16th, 2013 at 12:00 AM. Reason: Solved

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: How to get another application's window width [Help]

    Code:
    Private Type RECT
        Left   As Long
        Top    As Long
        Right  As Long
        Bottom As Long
    End Type
    
    Private Declare Function FindWindowW Lib "user32.dll" (Optional ByVal lpClassName As Long, Optional ByVal lpWindowName As Long) As Long
    Private Declare Function GetWindowRect Lib "user32.dll" (ByVal hWnd As Long, ByRef lpRect As RECT) As Long
    
    Private Sub Main()
        Dim hWnd As Long, R As RECT
    
        hWnd = FindWindowW(StrPtr("Notepad"), StrPtr("Untitled - Notepad"))
        If hWnd Then
            If GetWindowRect(hWnd, R) Then
                MsgBox "&H" & Hex$(hWnd) & " = " & (R.Right - R.Left) & "x" & (R.Bottom - R.Top), vbInformation
            End If
        End If
    End Sub
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    106

    Re: How to get another application's window width [Help]

    Thanks Bonnie West. That's what I wanted...
    Yes R.Right - R.Left I can do that with that code.

    Regards,

  5. #5
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How to get another application's window width [Help]

    ....and R.Bottom - R.Top


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

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