Vb.net MMORPG游戏中的自动空间机器人

Vb.net MMORPG游戏中的自动空间机器人,vb.net,bots,Vb.net,Bots,有人能帮我吗? 我使用VisualBasic2010编写了一个简单的自动按空格键程序。 它运行并工作,它通过记事本发送空间,但不幸的是,它在在线游戏中不工作(因为空格键是获取项目的控件) 我关心的是:有人能帮我让它直接在游戏中工作吗 下面是简单的代码 Public Class Form1 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Ti

有人能帮我吗? 我使用VisualBasic2010编写了一个简单的自动按空格键程序。 它运行并工作,它通过记事本发送空间,但不幸的是,它在在线游戏中不工作(因为空格键是获取项目的控件)

我关心的是:有人能帮我让它直接在游戏中工作吗

下面是简单的代码

Public Class Form1
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        SendKeys.Send(TextBox1.Text) 'Sends the message you typed in the textbox1
        SendKeys.Send(" ") 'presses the SPACE key from your keyboard
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Interval = TextBox2.Text
        Timer1.Enabled = True

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Interval = TextBox2.Text
        Timer1.Enabled = False
    End Sub

End Class

提前谢谢!:D

我认为问题在于你没有将焦点转移到游戏窗口。因此,您的程序将空格发送到您编写的vb.net程序,而不是发送到游戏

你需要做些什么来改变游戏窗口的焦点。请查看,因为它提供了有关使用Win32 API更改具有焦点的窗口的信息

编辑

根据您的请求,以下是如何将其应用到代码中。请注意,编写此代码所需的所有信息都在我提供的链接中。将来有人回答您的问题时,请阅读提供的资料来源。我留下了大量的评论来帮助你理解每一行的作用

Imports System.Runtime.InteropServices 'Needed to import the Win32 API functions

Public Class Form1
    'Make sure the programTitle const is set to the _EXACT_ title of the 
    'program you are trying to set focus to or this won't work.
    Private Const programTitle As String = "Title of program"
    Private zero As IntPtr = 0 'Required for FindWindowByCaption first parameter

    'Import the SetForegroundWindow Function
    <DllImport("user32.dll")> _
    Private Shared Function SetForegroundWindow(ByVal hWnd As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function

    'Import the FindWindowByCaption Function, called as a parameter to SetForegroundWindow
    <DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Private Shared Function FindWindowByCaption( _
      ByVal zero As IntPtr, _
      ByVal lpWindowName As String) As IntPtr
    End Function

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        'Call SetForegroundWindow whenever you want to send keys to the specified window.
        SetForegroundWindow(FindWindowByCaption(zero, programTitle))

        SendKeys.Send(TextBox1.Text) 'Sends the message you typed in the textbox1
        SendKeys.Send(" ") 'presses the SPACE key from your keyboard
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Interval = TextBox2.Text
        Timer1.Enabled = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Interval = TextBox2.Text
        Timer1.Enabled = False
    End Sub

End Class
导入Win32 API函数需要导入System.Runtime.InteropServices 公开课表格1 '确保将programTitle常量设置为 '您正在尝试设置焦点的程序,否则将无法工作。 Private Const programTitle为String=“程序标题” FindWindowByCaption第一个参数需要私有零作为IntPtr=0 '导入SetForegroundWindow函数 _ 私有共享函数SetForegroundWindow(ByVal hWnd作为IntPtr)作为布尔值 端函数 '导入FindWindowByCaption函数,该函数作为参数调用到SetForegroundWindow _ 专用共享函数FindWindowByCaption(_ ByVal zero作为IntPtr_ ByVal lpWindowName(作为字符串)作为IntPtr 端函数 私有子Timer1\u Tick(发送方作为对象,e作为事件参数)处理Timer1.Tick '无论何时要向指定窗口发送密钥,都可以调用SetForegroundWindow。 SetForegroundWindow(FindWindowByCaption(零,程序标题)) SendKeys.Send(TextBox1.Text)'发送您在TextBox1中键入的消息 SendKeys.Send(“”)按键盘上的空格键 端接头 私有子按钮1\u单击(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理按钮1。单击 Timer1.Interval=TextBox2.Text Timer1.Enabled=True 端接头 私有子按钮2\u单击(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理按钮2。单击 Timer1.Interval=TextBox2.Text Timer1.Enabled=False 端接头 末级 请注意:我测试了这段代码,验证了它可以设置窗口焦点,并发送空格键和其他任何键。如果此代码不适用于您,则说明
programTitle
常量中的名称错误。例如,如果我想设置此记事本窗口的焦点:


如果我将
programTitle
设置为
“记事本”
,试图让它将按键发送到记事本窗口,这将不起作用。那是因为“记事本”只是标题的一部分。要使其正常工作,
programTitle
应设置为
“无标题-记事本”

您是在尝试发送空格键来触发命令,还是仅尝试附加“”我只想在游戏中自动执行空格键,因为我不想手动按空格键获取/掠夺物品,而是希望程序同时执行。如果你拿到了,谢谢。嗯。。我有麻烦了。它没有起作用。我完全按照你的指示去做,那么还有别的事情要做。创建一个新项目,只添加代码来更改窗口。这就是我测试它的方式,它毫无问题地工作。唯一的例外是您需要小心使用窗口名。另外,你想用什么样的游戏来实现这一点?