#How to click without moving mouse

46 messages · Page 1 of 1 (latest)

short forum
#

Is it possible to do something like robot.mousePressAt(x, y, InputEvent.BUTTON1_DOWN_MASK) instead of

robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
tough sapphireBOT
#

This post has been reserved for your question.

Hey @short forum! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

visual stump
#

Doesn't look like it. But sounds like a good place to just create a pressAt function and use that instead. You already have the code written for it to work.

short forum
#

Ye, but I don't want to move the mouse which is the issue

visual stump
#

If I may ask, why can't you move the mouse?

short forum
#

I am trying to create my own macro app, and this part is for an autoclicker. Because its a autoclicker then my keyboard focus goes off the app so I can't use keybinds to disable it, which only leaves using the mouse with a button, but because I want this to have a lot more features that won't always work if I want to move the mouse. Either I need to figure out how to have keyboard focus on multiple windows/apps, force it onto mine (I don't think this would be a good way to go around it), or make it so I press in a position on screen without actually moving my mouse to that position so I can freely move the mouse to the button on the JFrame where I stop the autoclicker

#

so anyway is my best bet just doing something like

int prevX = (int) MouseInfo.getPointerInfo().getLocation().getX();
int prevY = (int) MouseInfo.getPointerInfo().getLocation().getY();
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseMove(prevX, prevY)

even though that would be pretty scuffed? Atleast I would imagine it would be

visual stump
#

So what will this auto clicker be doing?

Will it be just speed clicking, stopping afk timers, navigating through menus?

#

Because everything I have read so far has said to close a JFrame you need focus, and that you cannot click a certain set of coords without first moving your mouse to the location.

So understanding exactly what is wished to be done may help find a suitable solution

short forum
#

Well the final goal is to have click in different positions on the screen (done, but has issue said above), requirements for clicking such as color (done), time reqs, amount of times a certain thing would happen, etc, scrolling, and so on. Since it would be set up by the user inside the app, it's overall purpose for the final goal is just to automate anything that happens with the mouse and possibly keyboard presses as well if I decide to add it. I have an idea on how to program all of that, but im having issues on how to run it without potentially preventing the user from stopping the autoclicker because it takes keyboard focus off of the app and moves mouse, so if you don't have touch screen you can't really stop the auto-clicker. However it's done, The most basic form my issue I can think of is that I just need a way to stop the autoclicker without mouse or keyboard focus, or I figure out a way to grant the user that stuff while continuing to keep the autoclicker running

thorn fern
#

Just a reminder that any discussion of botting software is against Discord's ToS. However, to answer your question. If it's a Java application, you can use reflection to hook in to the swing or JavaFX callbacks.

#

If it's not a Java application, you'll have to use JNI to hook in to the applications mouse hooks and interact with it using C.

#

Either those mentioned above, or you'll just have to live with the fact that it'll move your mouse.

short forum
thorn fern
#

Any botting software in general

short forum
#

anyway ill look into those things, thank you

tough sapphireBOT
thorn fern
#

I'm assuming this is for a video game

short forum
#

Not entirely sure, the plan is kinda just to allow me to automate certain tasks that always stay the same but take time to do manually. It's also being used as experience for programming, as mostly ive just made stuff in Unity and I want to learn more langauges.

thorn fern
#

This could be an X/Y problem. What are you trying to automate? Perhaps you don't need to move the mouse at all.

short forum
# thorn fern This could be an X/Y problem. What are you trying to automate? Perhaps you don't...

As I said im not entirely sure. Might be games (although I would check whether or not that game allows macros first), might be traveling through certain menus on my computer, might use it for a game I make myself eventually, or I might end up not finding a use for it and just never opening it up. The only thing I know for a fact im using it for is to learn more about java, as i have never dealt with JFrames and such before

visual stump
#

So just a general purpose macro program. Makes sense

short forum
#

yep

thorn fern
#

That's very broad, you can't have one application do everything on anything.

#

Software is tailored for a specific purpose, so if you want to automate an excel sheet, it'd be different than some other generic task.

#

Unless that's what you wanted, you want it to be able to do anything and everything.

#

In that case, you'd have to use the users mouse and keyboard.

short forum
#

No it's not supposed to do everything, just a general macro program for the mouse

#

In the scenario of something like excel or google sheets, pretty sure they have their own way of making programs so I would just use that

thorn fern
#

Okay well then you have 4 options for mouse inputs.

#

Use robot

#

Use native hooks

#

Hook in to it with reflection if it's a Java application

#

Or use something like

#

Which is just an abstraction of the native hooks

#

Nevermind that last option, it's only used for detecting native mouse events.

visual stump
#

That repo has a keyboard listener thou? or does it say somewhere it doesn't work?

short forum
#

ok, I will look into all of that, thank you. Should I close this post now?

tough sapphireBOT
tough sapphireBOT
thorn fern
#

It's used for detecting mouse and keyboard events

#

Not for interacting with the mouse and or keyboard

visual stump
#

Ah. I was thinking having this run to listen for a close program key to avoid the lockup and focus problems OP was having
but still have java robot handle all the automation

short forum
#

Thanks everyone who helped