Jump to content

Move (and Click) Mouse using AutoHotkey or any other Outside Technique


Recommended Posts


Short question: how can I get the position from the cursor from outside a Torque game? Sending a Windows API command like GetCursorPos does not work because the Torque engine probably has its own mouse handling.

Long question: I've never created mods or hacks for games but I always create AutoHotkey scripts to add some Hotkeys to games so I don't have to use the mouse that much (Carpal tunnel syndrome is $h!t).  A very simple script with this line allows me to press the Left Mouse Button by pressing the D key:


Another example: most games use the M key for the map but I want the Tab key so this line will do this:


So what if I have a button in the bottom right corner of the screen and I want a Hotkey to click it? Then I find the button coordinates and I write this line in my script:

F2::Click 1900 1060

Now I've come to the Torque Engine issue: my last example does not work in a Torque Engine game (Age of Decadence)! What I would like to do is move the mouse to a specific location and click the left mouse button. Who can help me to get the current mouse location from the game? And also, how can I move the mouse from the outside? Does the Torque Engine exposes information like this with an API? Something like GetCursorPos() and SetCursorPos() or maybe by using SendMessage() or PostMessage() with certain messages? Anything? If not, would it be possible to write a mod/script that would expose some info and react to the outside world? Or a mod/script that could add hotkeys that would click the mouse?

Any lead to a good line of inquiry would be appreciated!

Link to comment
Share on other sites

The engine does have functions to invoke cursor management, yeah.

Specifically, the GuiCanvas class(aka the actual window) has setCursorPos() and getCursorPos().

getCursorPos() returns a Point2I, or an x/y integer pair representing the pixel coordinate in the window.

setCursorPos() takes a Point2I as an argument to set the cursor position, again as pixel coordinates.

From there, you can do cursorClick() which has two arguments:

  1. buttonId, which I believe is a numeric offset for the buttonId being performed. Iirc with 0 it's left click, then offsetting from there does right click and so on.
  2. isDown which indicates if you're "clicking" the button down, or letting it up. In Torque keybinds can register if it's being pressed down or released differently, though most UI controls respond mostly to down events

Lastly, there's cursorNudge() which takes two arguments x and y as integers. This function will offset the cursor's current position by those pixel amounts if you know how far from current you want to push the mouse around, which may be more useful if you're talking about using the keyboard to move the mouse around the screen rather than explicitly teleporting it to a position on the screen.

Hopefully that helps. Lemme know if anything else needs further explination! 🙂

Link to comment
Share on other sites

@JeffR: Thank you for your info! I've never done anything with Torque but those functions are exactly what I'm interested in. Now I have to find out how to 'broadcast' this info to the outside. I have found some Torque scripting documentation so maybe I could write a MOD script that would react to the GuiInputCtrl event and write the cursor position to the file?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...