我正在尝试使《反恐精英:全球攻势》(cs:go)中的玩家自动移动,以尝试制作一个简单的脚本。
脚本本身是无关紧要的,因为我只需要一种向程序输入键(例如空格键或W A S D)的方法。之前,我已经使用Hooks或发送密钥来处理此问题。但是,cs:go似乎没有将这些键注册为移动键。
奇怪的是,当我打开聊天时它确实起作用。它会接收按键输入,但不会将其注册为实际的按键来移动播放器。
有人可以帮我解决这个问题吗?
以防万一,下面是代码:
class Program
{
enum CSGO
{
Health = 0x0,
X = 0xA0,
Y = 0xA4,
Z = 0xA8,
Jumping = 0x07E8,
Velocity = 0x0BDC,
forceJump = 0x4F1D988,
forceJumpTwo = 0x04AC6978,
forceJumpThree = 0x04F5794C,
Name = 0x0EC9
}
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
[DllImport("user32.dll")]
static extern ushort GetAsyncKeyState(int vKey);
public static bool IsKeyPushedDown(Keys vKey)
{
return 0 != (GetAsyncKeyState((int)vKey) & 0x8000);
}
static void Main(string[] args)
{
CounterStrike();
}
static void CounterStrike()
{
VAMemory vam = new VAMemory("csgo");
Console.CursorVisible = false;
IntPtr aClient = MemoryReader.GetModuleAddy("csgo", "server.dll");
if (aClient != (IntPtr)null)
{
//IntPtr aAdress = (IntPtr)aClient + pRef1;
//IntPtr adress = (IntPtr)vam.ReadInt32(aAdress) + pRef2;
IntPtr adress = MemoryReader.GetPointer("csgo", aClient, new int[] { 0x00A43754, 0x230 });
//IntPtr adress2 = MemoryReader.GetPointer(process, aClient, new int[] { 0x013759CC, 0x13C, 0x1B4, 0x2C0, 0x0, 0x6A8 });
while (true)
{
while (!IsKeyPushedDown(Keys.Space))
{
Console.SetCursorPosition(0, 0);
int jumping = vam.ReadInt32((IntPtr)adress + (int)CSGO.Jumping);
if (jumping != 0)
{
Console.WriteLine("Jumping ", Console.ForegroundColor = ConsoleColor.Green);
}
else
{
Console.WriteLine("Standing", Console.ForegroundColor = ConsoleColor.Yellow);
//this is where the spacebar input is supposed to go. memory writing, sendkeys and a hook such as either PostMessage or keybd_event did not seem to work
vam.WriteInt32((IntPtr)aClient + (int)CSGO.forceJump, 5);
Thread.Sleep(10);
vam.WriteInt32((IntPtr)aClient + (int)CSGO.forceJump, 4);
Thread.Sleep(10);
vam.WriteInt32((IntPtr)aClient + (int)CSGO.forceJumpTwo, 5);
Thread.Sleep(10);
vam.WriteInt32((IntPtr)aClient + (int)CSGO.forceJumpTwo, 4);
Thread.Sleep(10);
vam.WriteInt32((IntPtr)aClient + (int)CSGO.forceJumpThree, 5);
Thread.Sleep(10);
vam.WriteInt32((IntPtr)aClient + (int)CSGO.forceJumpThree, 4);
Thread.Sleep(10);
}
//vam.WriteInt32((IntPtr)adress, 100000);
Thread.Sleep(1000);
}
Thread.Sleep(100);
}
}
}
}