VB.net findwindow / findwindowex

Hi everyone, I'm trying to figure out how to find this window label when the name of the control matches all the other labels in the program.

WindowsForms10.STATIC.app.0.378734a
WindowsForms10.STATIC.app.0.378734a
WindowsForms10.STATIC.app.0.378734a

All 3 tags are called the same. The most interesting for me is the% progress counter (1%, 2%, 3%, etc.)

How can I get a value (using a timer, of course) from this shortcut without knowing its title at any given time?

Any help would be wonderful !: O)

David

+3
source share
2 answers

The obvious answer would be to get the text from all three labels and check which one looks like "1%", "55%", etc.

If strText Like "#%" Or strText Like "##%" Or strText = "100%" Then
' ...

( Windows API ) API Microsoft UI.

0

, , .

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    'This block of code creates a list of all the labels on my form.
    'Replace this with code to get a list of labels on the form you are scraping
    Dim LblList As New List(Of Label)

    For Each ctrl As Control In Me.Controls
        If TypeOf ctrl Is Label Then
            LblList.Add(CType(ctrl, Label))
        End If
    Next
    'End

    Dim ProgressLblTxt As String = String.Empty
    For Each lbl As Label In LblList
        If lbl.Text.Contains("%") Then 'You could use several different criteria here as mentioned in the previous answer
            ProgressLblTxt = lbl.Text
        End If

        If ProgressLblTxt <> String.Empty Then Exit For
    Next

    'Do something with ProgressLblTxt
    MsgBox(ProgressLblTxt)
End Sub
0

Source: https://habr.com/ru/post/1768925/


All Articles