对于textfile中的每个单词,为每个单词vb.net添加一个计时器

时间:2016-03-20 02:13:06

标签: vb.net

我正在编写一个程序来跟踪游戏中的计时器。游戏有聊天,你可以说" / note blah t"。这将节省" blah t"到游戏文件夹中的文本文件。我需要能够看到用户添加到文件中的内容,我正在考虑做text.contains,但我需要恢复整个.contains行。当我收到该行时,我需要阅读该行,然后创建一个新的计时器(时间由输入的内容决定" t")为表单添加标签,其中包含时间加上输入的内容" blah",到目前为止这是我的代码。

注意我主要关注Timer1代码,所有其他代码只是为了防止用户在游戏中点击我的表单。

Imports System.IO
Imports System.Runtime.InteropServices

Public Class Form1

    Private Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As IntPtr
    Private Declare Auto Function GetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpString As System.Text.StringBuilder, ByVal cch As Integer) As Integer
    Private makel As String
    Private InitialStyle As Integer
    Dim PercentVisible As Decimal
    Dim Lea

    Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.Location = New Point(0, 0)
        InitialStyle = GetWindowLong(Me.Handle, -20)
        PercentVisible = 0.1

        SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000 Or &H20)

        'SetLayeredWindowAttributes(Me.Handle, 0, 255 * PercentVisible, &H2)

        'Me.BackColor = Color.Red
        Me.TopMost = True
    End Sub

    Private Function GetCaption() As String
        Dim Caption As New System.Text.StringBuilder(256)
        Dim hWnd As IntPtr = GetForegroundWindow()
        GetWindowText(hWnd, Caption, Caption.Capacity)
        Return Caption.ToString()
    End Function

    <DllImport("user32.dll", EntryPoint:="GetWindowLong")> Public Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
    End Function

    <DllImport("user32.dll", EntryPoint:="SetWindowLong")> Public Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
    End Function

    <DllImport("user32.dll", EntryPoint:="SetLayeredWindowAttributes")> Public Shared Function SetLayeredWindowAttributes(ByVal hWnd As IntPtr, ByVal crKey As Integer, ByVal alpha As Byte, ByVal dwFlags As Integer) As Boolean
    End Function

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim CapTxt As String = GetCaption()
        Dim Path As String = "C:\Riot Games\League Of Legends\RADS\solutions\lol_game_client_sln\releases\0.0.1.123\MyNotes.txt"
        If CapTxt = "League of Legends (TM) Client" Then
            Me.TopMost = True
            Try
                Test.Text = File.ReadAllLines(Path).FirstOrDefault(Function(x) x.Contains("Ezreal"))

                ''System.IO.File.WriteAllText(Path, "")
            Catch ex As Exception

            End Try
        Else
                Me.TopMost = False
            Me.SendToBack()
        End If


    End Sub
End Class

0 个答案:

没有答案
相关问题