Results 1 to 4 of 4

Thread: how to get the value of a text box???

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    antartica
    Posts
    4

    Question

    im wondering how to get the value of a text box of another program????

  2. #2
    Junior Member
    Join Date
    Sep 1999
    Location
    mousafah,abu-dhabi,UAE
    Posts
    29
    hi

    download this source code

    http://www.geocities.com/HUS_ME

    bYe

    Ahmed Walid

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    This should get the text of the calculators result window:
    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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    
    Private Sub Form_Load()
        Dim hcalcwnd As Long, hResultwnd As Long
        hcalcwnd = FindWindow("SciCalc", vbNullString)
        hResultwnd = FindWindowEx(hcalcwnd, 0&, "Static", vbNullString)
        Debug.Print GetWndText(hResultwnd)
    End Sub
    
    Private Function GetWndText(hwnd As Long)
        Dim l As Long, temp As String
        l = GetWindowTextLength(hwnd)
        temp = Space(l)
        GetWindowText hwnd, temp, l
        l = InStr(temp, vbNullChar) - 1
        If l Then
            GetWndText = Left(temp, l)
        Else
            GetWndText = temp
        End If
    End Function
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Guest
    There are some declarations and code that you can erase to make it shorter.
    Code:
    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 GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    
    Private Sub Form_Load()
        Dim hResult
        hResult = FindWindowEx(FindWindowEx(0, 0, "SciCalc", vbNullString), 0&, "Static", vbNullString)
        Debug.Print GetWndText(hResult)
    End Sub
    
    Private Function GetWndText(ByVal hwnd As Long)
        Dim temp As String * 255
        GetWindowText hwnd, temp, 255
        GetWndText = Left(temp, Len(temp) - InStr(1, temp, vbNullChar))
    End Function

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