I play a game called CS:GO and I was wondering if it was possible to move my cursor within the game. CS:GO is made by valve and runs on the Source engine. At the minute, I am able to move my cursor through code while window focus is on Unity or Google Chrome. I do have "Run In Background" checked.
Here is my current code:
using UnityEngine;
using System.Collections;
using System.Drawing;
using System.Runtime.InteropServices;
public class MouseControl : MonoBehaviour {
[DllImport("user32.dll")]
public static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")]
public static extern bool GetCursorPos(out Point pos);
Point cursorPos;
// Use this for initialization
void Start () {
cursorPos = new Point();
GetCursorPos(out cursorPos);
Invoke("moveMouse", 3);
}
void moveMouse() {
SetCursorPos(cursorPos.X, cursorPos.Y + 150);
}
}
I have not yet compiled this, but I don't think that is the problem.
Thanks in advance, and I am really sorry if this is just a noob question.
↧