none
Get External ErrorProvider tooltip message RRS feed

  • Question

  • Hi everyone,

    i'm trying to get the information from an external form, specifically a ErrorProvider.

    I have this:

    

     so i want to get in another application the message that it's inside this application. i'm trying to get it with UIAutomation, but not successful, any idea please?


    Yordy Corrales

    Wednesday, March 6, 2019 2:25 AM

All replies

  • Hi,

    read another program control conten,

    Imports System.Runtime.InteropServices
    Imports System.Text
    
    Public Class Form1
        <DllImport("User32.dll", EntryPoint:="FindWindow")>
        Public Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
        End Function
        <DllImport("User32.dll", EntryPoint:="FindWindowEx")>
        Public Shared Function FindWindowEx(ByVal hwndParent As IntPtr, ByVal hwndChildAfter As IntPtr, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
        End Function
        <DllImport("User32.dll", EntryPoint:="FindEx")>
        Public Shared Function FindEx(ByVal hwnd As IntPtr, ByVal hwndChild As IntPtr, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
        End Function
        <DllImport("user32.dll", EntryPoint:="SendMessageA")>
        Private Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer
        End Function
        Public Shared WM_GETTEXT As Integer = &HD
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            'Const BM_CLICK As Integer = &HF5
            Dim maindHwnd As IntPtr = FindWindow(Nothing, "Test2Form")
    
            If maindHwnd <> IntPtr.Zero Then
                MsgBox("Find Main Window")
                Dim maindHwndp As IntPtr = FindWindowEx(maindHwnd, 0, "WindowsForms10.EDIT.app.0.141b42a_r9_ad1", vbNullString)
    
                If maindHwndp <> IntPtr.Zero Then
                    MsgBox("Find Child Window!")
                    Const buffer_size As Integer = 1024
                    Dim buffer As StringBuilder = New StringBuilder(buffer_size)
                    SendMessage(maindHwndp, WM_GETTEXT, buffer_size, buffer)
                    MsgBox(buffer.ToString())
                    'SendMessage(maindHwndp, BM_CLICK, 0, Nothing)
                End If
            Else
                MsgBox("No Find Main Window")
            End If
        End Sub
    
    End Class
    

    "WindowsForms10.EDIT.app.0.141b42a_r9_ad1"?

    spy++

    but it  can't read the errorprovider value.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 6, 2019 7:10 AM
  • Tooltip message is set dynamically...
    Wednesday, March 6, 2019 8:18 AM
  • Hello,

    If you don't mind me asking, what is the reason for obtaining the tooltip text? If this is for some sort of UI test this would fall into visual (inspection with your eyes) confirmation rather than via using code to valid text is according to specifications.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, March 6, 2019 10:27 AM
    Moderator
  • Hi,

    read another program control conten,

    Imports System.Runtime.InteropServices
    Imports System.Text
    
    Public Class Form1
        <DllImport("User32.dll", EntryPoint:="FindWindow")>
        Public Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
        End Function
        <DllImport("User32.dll", EntryPoint:="FindWindowEx")>
        Public Shared Function FindWindowEx(ByVal hwndParent As IntPtr, ByVal hwndChildAfter As IntPtr, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
        End Function
        <DllImport("User32.dll", EntryPoint:="FindEx")>
        Public Shared Function FindEx(ByVal hwnd As IntPtr, ByVal hwndChild As IntPtr, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
        End Function
        <DllImport("user32.dll", EntryPoint:="SendMessageA")>
        Private Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer
        End Function
        Public Shared WM_GETTEXT As Integer = &HD
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            'Const BM_CLICK As Integer = &HF5
            Dim maindHwnd As IntPtr = FindWindow(Nothing, "Test2Form")
    
            If maindHwnd <> IntPtr.Zero Then
                MsgBox("Find Main Window")
                Dim maindHwndp As IntPtr = FindWindowEx(maindHwnd, 0, "WindowsForms10.EDIT.app.0.141b42a_r9_ad1", vbNullString)
    
                If maindHwndp <> IntPtr.Zero Then
                    MsgBox("Find Child Window!")
                    Const buffer_size As Integer = 1024
                    Dim buffer As StringBuilder = New StringBuilder(buffer_size)
                    SendMessage(maindHwndp, WM_GETTEXT, buffer_size, buffer)
                    MsgBox(buffer.ToString())
                    'SendMessage(maindHwndp, BM_CLICK, 0, Nothing)
                End If
            Else
                MsgBox("No Find Main Window")
            End If
        End Sub
    
    End Class

    "WindowsForms10.EDIT.app.0.141b42a_r9_ad1"?

    spy++

    but it  can't read the errorprovider value.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Hi, thanks for answer. If you say that i can't read the error provider.... How can testcomplete software do it?? I have the licensed software at my job, and I test this article: https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/net-errorprovider.html and it works... So I think it must be posible to get it, because if they can, I can... But I don't know how to do it. It must exist a way to get the message from tooltip, not necessarily with uiauromation, maybe another library or windows API. Maybe getting .net properties from a form or something like that. I just need to know the right path to archive the goal. Do you know how to get .net properties from an external control?

    Yordy Corrales

    Friday, March 8, 2019 5:38 AM
  • Hello,

    If you don't mind me asking, what is the reason for obtaining the tooltip text? If this is for some sort of UI test this would fall into visual (inspection with your eyes) confirmation rather than via using code to valid text is according to specifications.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    It's to register all the errors that happen inside an application. I'm making an automation app. So if the data put it inside fails, the automation must stops. And register what the error is. Do you know how to get it? Maybe reading .net properties from external controls. But I don't know how to retrieve that info.. not necessarily with uiautomation, but maybe exists some library 

    Yordy Corrales

    Friday, March 8, 2019 5:38 AM
  • You can get the current message with ReadProcessMemory and TTM_GETTEXT

    (on my VS version (2015), the Tooltip class name is "WindowsForms10.tooltips_class32.app.0.141b42a_r9_ad1", but it could be different for other versions...)

    Friday, March 8, 2019 11:26 AM