Question is off-topic or not relevant
Can I make my cursor move using Unity in Source games?
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.
Has anyone found anything about this? I would really like to know.
This question has nothing to do with Unity. You're using a windows API function which has no relation to game development with Unity. It also seems you try to manipulate other game applications in order to automate something or to cheat in that game. If that's the intention you're completely wrong here.
Closed.
Follow this Question
Related Questions
About generated dlls and Unity 1 Answer
Adding Packages from Nuget - Some get removed while others don't? 0 Answers
System.Threading.Tasks.Extensions.dll is not allowed to be included or could not be found 1 Answer
Unity mobile game build working from personal license but giving compile error with pro license 0 Answers