Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对于文本文件中的每个单词,为每个单词vb.net添加一个计时器_Vb.net - Fatal编程技术网

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

对于文本文件中的每个单词,为每个单词vb.net添加一个计时器,vb.net,Vb.net,我正在写一个程序来跟踪游戏中的计时器。游戏有聊天功能,你可以说“/注意,等等”。这会将“blah t”保存到gamefolder中的文本文件中。我需要能够看到用户添加到文件中的内容,我正在考虑执行text.contains,但我需要恢复.contains的整行内容。当我收到这一行时,我需要阅读这一行,并制作一个新的计时器(时间由输入的“t”决定),它在表单上添加一个标签,标签上的时间加上输入的“blah”,这是我目前为止的代码 请注意,我主要关心的是Timer1代码,所有其他代码只是为了防止用户

我正在写一个程序来跟踪游戏中的计时器。游戏有聊天功能,你可以说“/注意,等等”。这会将“blah t”保存到gamefolder中的文本文件中。我需要能够看到用户添加到文件中的内容,我正在考虑执行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
Imports System.IO
导入System.Runtime.InteropServices
公开课表格1
将私有函数getForeGroundIndow Lib“user32”别名“getForeGroundIndow”()声明为IntPtr
私有将自动函数GetWindowText-Lib“user32”(ByVal hWnd作为System.IntPtr,ByVal lpString作为System.Text.StringBuilder,ByVal cch作为Integer)声明为整数
私有makel作为字符串
作为整数的私有InitialStyle
显示为十进制的百分比
暗Lea
私有子表单_Load(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理MyBase.Load
Me.Location=新点(0,0)
InitialStyle=GetWindowLong(Me.Handle,-20)
可见百分比=0.1
SetWindowLong(Me.Handle,-20,初始样式或&H80000或&H20)
'SetLayeredWindowAttributes(Me.Handle、0、255*PercentVisible和H2)
'Me.BackColor=Color.Red
Me.TopMost=正确
端接头
私有函数GetCaption()作为字符串
Dim标题作为新System.Text.StringBuilder(256)
Dim hWnd As IntPtr=GetForeGroundIndow()
GetWindowText(hWnd、标题、标题容量)
Return Caption.ToString()
端函数
公共共享函数GetWindowLong(ByVal hWnd作为IntPtr,ByVal nIndex作为Integer)作为Integer
端函数
公共共享函数SetWindowLong(ByVal hWnd作为IntPtr,ByVal nIndex作为Integer,ByVal dwNewLong作为Integer)作为Integer
端函数
公共共享函数将LayeredWindowAttributes(ByVal hWnd作为IntPtr,ByVal crKey作为整数,ByVal alpha作为字节,ByVal dwFlags作为整数)设置为布尔值
端函数
私有子Timer1\u Tick(发送方作为对象,e作为事件参数)处理Timer1.Tick
Dim CapTxt作为字符串=GetCaption()
暗淡路径为String=“C:\Riot Games\League Of Legends\RADS\solutions\lol\u game\u client\u sln\releases\0.0.1.123\MyNotes.txt”
如果CapTxt=“传奇联盟(TM)客户端”,则
Me.TopMost=正确
尝试
Test.Text=File.ReadAllLines(Path).FirstOrDefault(函数(x)x.Contains(“Ezreal”))
''System.IO.File.WriteAllText(路径,'')
特例
结束尝试
其他的
Me.top=False
Me.SendToBack()
如果结束
端接头
末级

除了您的解释很难理解之外,我认为用户不希望有键盘记录器之类的东西来监视他们键入的内容。你到底想达到什么目的?请解释您试图解决的问题,而不是您认为应该如何解决。@LucMorin在玩游戏时,用户可以键入“/note”,这将在notes文本文件中添加注释。文本文件目录永远不会更改。我希望能够为每个人在文本文件中添加新行时创建一个计时器。Ok。我懂了。因此,您需要监视对该文件的更改,然后解析它以找到特定文本并启动相应的计时器。您只提到显示这些计时器的剩余时间,但您是否还需要计时器“触发”某些内容?您提到了一个
文本框
,但由于计时器可以动态添加/删除,因此您需要一个GUI来对添加/删除计时器做出反应。请编辑您的问题并提供尽可能多的信息,但也请分享您已有的任何代码。@LucMorin kk我将尝试重新解释,并包括我的代码。对不起,我真的不善于解释:(好吧,请你设身处地,如果你不能很好地解释这个问题,我们将很难提供帮助;-)