Search code examples
vb.netcursorcoordinates

In visual basic, is it possible to teleport my cursor to x*y coordinates (Not x,y)


So I have this program in visual basic that requires teleporting your cursor around and clicking. Kinda like an automatic cheat for a game but not really a cheat.

Anyways I want the user to set coordinates to a point, then set those coordinates to a value, then with the push of a button teleport to those coordinates.

Alright I can make him get the coordinates. I can make the cursor teleport. I can set the coordinates he got to an integer X and an integer Y so the cursor teleports there. But I have to do all that 8 times. So I need 24 integers.

I was thinking, maybe I can skip all that if I can multiply xy so lets say he sets the coordinates to 320 (x) and 72 (y). (320,72) Alright so If I multiply xy I get the pixel number on the screen that exists in that coordinate (right?)

Alright that makes it so we only have 8 integers which is much less.

But how do I make the cursor teleport to the location "X*Y" (in the case of 320*72 it is pixel number 23040).

*TL;DR is it possible to convert this Windows.Forms.Cursor.Position = New Point(320,72) into this Windows.Forms.Cursor.Position = New Point(23040 (which is 320*72))*

Is it possible?

I can't think of a way of doing it please help me. Thanks.


Solution

  • No. (x, y) is not equivalent to (x * y).

    The reason why is obvious if you give it some thought. There are many different input values for x and y that would give the same product. For example, 6 * 1 = 6, and so does 2 * 3. Which location on the screen would 6 correspond to? The point at coordinates (6, 1), (1, 6), (2, 3), or (3, 2)?

    There might be a better way of doing this, but I find the description in your question to be very difficult to understand. If all you want to do is simulate a click event at a particular location on the screen, you do not need to explicitly move the cursor there first. I'd suggest how to do that, but it is not clear what language you're using. You've tagged the question [vbscript], but then talked about Windows Forms, which doesn't exist in VBScript. If you are using VB.NET, you will probably end up P/Invoking the SendInput function. Google for code examples.