Results 1 to 1 of 1

Thread: Get window text

  1. #1
    intelcorei9
    intelcorei9 is offline
    Guest
    Join Date
    2014 Apr
    Posts
    1
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    Get window text

    Use : 1 Label, 2 Textbox, 1 Timer

    Code:
    Public Class Main
        Private Declare Function GetWindowTextLengthA Lib "user32" ( _
        ByVal hwnd As IntPtr) As Integer
    
        Private Declare Function GetWindowTextA Lib "user32" ( _
        ByVal hwnd As IntPtr, _
        ByVal lpString As System.Text.StringBuilder, _
        ByVal nMaxCount As Integer) As Integer
    
        Private Function GetText()
            Dim processName As Process() = Process.GetProcessesByName(txtProcess.Text)
            Dim length As Integer = GetWindowTextLengthA(processName(0).MainWindowHandle)
            Dim sb As New System.Text.StringBuilder("", length)
            GetWindowTextA(processName(0).MainWindowHandle, sb, sb.Capacity + 1)
            Return sb.ToString()
        End Function
    
        Private Sub tmrChk_Tick(sender As Object, e As EventArgs) Handles tmrChk.Tick
            Dim processName As Process() = Process.GetProcessesByName(txtProcess.Text)
            If Not processName.Length = 0 Then
                Label1.Text = "Detected: " + txtProcess.Text
                Label1.ForeColor = Color.Green
                txtGet.Text = GetText()
            Else
                Label1.Text = "Can not find: " + txtProcess.Text
                Label1.ForeColor = Color.Red
                txtGet.Text = String.Empty
            End If
        End Sub
    End Class

Similar Threads

  1. [Tool] RH Bin to Text Converter
    By premank1 in forum Game Files
    Replies: 0
    Last Post: 2016-12-12, 07:26 AM
  2. [Help] reading text value with readprocessmemory
    By elshabory in forum Delphi
    Replies: 5
    Last Post: 2013-01-07, 04:34 PM
  3. Photoshop Tutorial: Text on Fire
    By DaimonHellstrom in forum Graphics Tutorials
    Replies: 0
    Last Post: 2012-03-13, 12:29 PM
  4. [Source] Scrolling text
    By Dwar in forum D3D Programming
    Replies: 0
    Last Post: 2010-12-15, 01:26 PM
  5. [C++] Drawing Rects/Lines/Text
    By Dwar in forum D3D Programming
    Replies: 0
    Last Post: 2010-12-15, 01:23 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
  •