PDA

View Full Version : Mouse Position



Baked0420
08-16-2010, 04:00 PM
I'm on a mac and trying to make a macro. Since simba doesn't support Macs (yet?), I downloaded Eclipse and am using java to make a simple bot. I know a bit of java and how to do most the things I need for this bot. The only thing I don't know know is how to find a mouse's coordinates. I've tried google searching and I couldn't find good help. There's supposedly a Robot.getX() and Robot.getY() but when I tried using it in eclipse I got: "The method getX() is undefined for the type Robot", even though it is in the Java API (http://download.oracle.com/javase/1.5.0/docs/api/). Any help is appreciated.

EDIT: I don't see the getX() and getY() anymore, I could've swore I saw it in there before. But anyway, I used to just use guess and check, I have once in the past months ago to make a program open IE, but guess and check took way too long, I'm looking for an easier way.

EDIT2: getX and getY are in MouseEvent. Not positive yet how I'm gonna be able to use it, but I'm going to try to figure it out on my own, I'll update this post if I figure it out, until then help would still be appreciated.

Camaro'
08-16-2010, 05:07 PM
I'm on a mac and trying to make a macro. Since simba doesn't support Macs (yet?), I downloaded Eclipse and am using java to make a simple bot. I know a bit of java and how to do most the things I need for this bot. The only thing I don't know know is how to find a mouse's coordinates. I've tried google searching and I couldn't find good help. There's supposedly a Robot.getX() and Robot.getY() but when I tried using it in eclipse I got: "The method getX() is undefined for the type Robot", even though it is in the Java API (http://download.oracle.com/javase/1.5.0/docs/api/). Any help is appreciated.

EDIT: I don't see the getX() and getY() anymore, I could've swore I saw it in there before. But anyway, I used to just use guess and check, I have once in the past months ago to make a program open IE, but guess and check took way too long, I'm looking for an easier way.

EDIT2: getX and getY are in MouseEvent. Not positive yet how I'm gonna be able to use it, but I'm going to try to figure it out on my own, I'll update this post if I figure it out, until then help would still be appreciated.

I wouldn't use the Robot class if you are making a macro.

Baked0420
08-16-2010, 05:45 PM
I don't know how else to get control of a mac's mouse. I don't much about mac's at all, but I know java can be programmed on Windows and Macs, and I know java has a robot class. I don't know any other way to do it for Macs, and the robot class is similar to SRL, like it has Robot.mouseMove(x, y) and Robot.delay(int ms) and I made a randomrange method.

How do you propose I go about making a macro for a mac if you think I shouldn't use the robot class?

EDIT: By the way, I found someone who made a JFrame with a moving button, it moves to where you clicked, so I maximized the frame where the button goes, and added in a System.out.println of where the new coords are, it's better then guess and check but not perfect, since (0,0) is the top right of the frame, and (0, 0) for the mac is the top right of the screen, it's off by a few pixels. If there's a better way you know of, please tell :) or if there's an all around better way to make macro's for macs in a way similar to SIMBA and not just a mouse recorder that would be helpful also. By the way, this is not RuneScape related, so it doesn't need randomness, I just added it in cause I prefer it.

i luffs yeww
08-16-2010, 05:48 PM
You could take a look at how TRiBot works.

Tribot.org (http://www.tribot.org/).

Baked0420
08-16-2010, 06:47 PM
I followed all the mouse methods from one till the next till I got to sendMouseEvent. sendMouseEvent uses:

bot.getCanvas().processEvent(event);

found processEvent in another file, which calls:

super.processEvent(event);

so it's using processEvent from Component in the Java API. I don't know how to use that, but I assume you need to have a JPanel to use that, like how the script I found moves the button around on the panel. I don't know I could be wrong though, so correct me if I am. But I'm not using a JPanel, I'm just compiling the file and moving/clicking the mouse on the screen. Whenever I tried clicking the mouse outside the JPanel it wouldn't work, so I think to use it you need to click inside a JPanel. I have no experience in JPanel's or JFrame's by the way, so if I'm wrong, it's because I never bothered with those yet.


TriBot's looking nice, the way the folder's are all setup reminds me of when I was trying to look through RSBot to figure out reflection. Can't wait to see it and how much it grows once it's done.

i luffs yeww
08-16-2010, 07:15 PM
You can always get people to join in if you want it to (live long and) prosper.

I believe the Robot class uses the actual mouse, making it not like SMART.

Not sure if that matters, though. (Or if it's true..)

Baked0420
08-16-2010, 07:18 PM
Ya that's what I was saying. I'm not using a canvas to use a 'SMART' mouse, I'm using Safari, so I need the actual mouse. Which is why I think I need to use Robot and not the way you guys do it. Maybe one day I'll be smart enough to load browser games into my own applet, but not now :p

Tniffoc
08-16-2010, 07:22 PM
Simba works on a mac. I'm running it right now.

Get MacPorts and install WINE on like this...


sudo port install wine-devel


Then follow the normal instructions for installing simba under wine.

Simba will run in mac's X11 app.

i luffs yeww
08-16-2010, 07:23 PM
Oh well then go ahead and use the Robot class. Especially if it's only for you; do whatever you want.

Even though Simba works on Mac, you should try making something in Java. :) It's always good to learn.

Baked0420
08-16-2010, 07:25 PM
I tried installing WINE and using it like a year to two ago to get SCAR to run on the mac I'm on. I had no clue what to do, WINE made no sense to me, maybe I'll try again later, but I'm probably around 50% done with this scripts, so I'm just going to finish it in Java.


So noone can help with an easy way of getting mouse coordinate's through a mac?

EDIT: Last year of school I took AP computer science and learned java, I already know the basics of it and made a lot of java programs, I'm no advanced java programmer though. But I do know how to use it already, this isn't for learning, it's cause I'm bored lol, but I might learn a thing or two about java from it. And the script is only for me, and I thought SIMBA only works on Windows and possibly Linux also, but doesn't support Mac yet, unless you use WINE, but I'm not really trying to do all that right now.

Tniffoc
08-16-2010, 07:28 PM
Well, the best way is to use the canvas class but I once made a Java autotyper for a friend using the Robot class. If you're careful, you will not be banned.

But seriously. If you're taking this seriously at all I would just go ahead and send mouse events as SMART or RsBot does.

EDIT: This will help. http://download.oracle.com/javase/6/docs/api/java/awt/Robot.html

i luffs yeww
08-16-2010, 07:29 PM
http://www.google.com/search?q=robot+class+java
http://www.google.com/search?q=mouse+simulation+java+robot

etc. :)

Baked0420
08-16-2010, 07:30 PM
I already said this isn't for RuneScape, so I don't care bout how obvious it is, I only have some randomness in waits cause I felt like it, but there doesn't need to be any. If it was for RuneScape then I'd just use SCAR/SIMBA.

i luffs yeww
08-16-2010, 07:32 PM
Why not just use Simba again?

(Also, Simba isn't meant to be an acronym.)

Baked0420
08-16-2010, 09:02 PM
Cause I am on a mac and last time I tried getting WINE I couldn't figure out how to set it up with SCAR so I gave up, and I don't feel like taking the time trying to figure it out. And yea, I saw that thread about the acronym, I just got used to typing compiler names in caps :p

and java can easily be installed and used on a mac, so I figured I'd just use java since it'd take less time and effort to set up. But once I finish this script I'll see if I can get WINE to work so I can use SCAR and/or Simba instead.

i luffs yeww
08-16-2010, 09:23 PM
Well according to Tniffoc, it's really not that hard. :)


Simba works on a mac. I'm running it right now.

Get MacPorts and install WINE on like this...


sudo port install wine-devel


Then follow the normal instructions for installing simba under wine.

Simba will run in mac's X11 app.

Seems simple enough to me. I can try to TV you (if TV supports Mac) if you want. If you still don't wanna try this I can help you later but for nright now I have stuff to deal with.

Camaro'
08-16-2010, 09:44 PM
My fault, I thought it was for runescape, then the robot class will be fine.


Try this :)

http://www.kodejava.org/examples/296.html

Baked0420
08-17-2010, 04:50 AM
@i luffs yeww: it's fine, I don't feel like doing it right now anyway, but whenever you have time and I have the mac around I'll do it I suppose. It's my friend's computer though, I just use it when I'm over their house and sometimes I script.

It's fine Camaro', and alright, I'll take a look.

EDIT: Camaro', I already know how to do that, it's what I'm doing, but I wanna know how I can find coordinate's of where the mouse is so I know what coordinates to put in Robot.mouseMove(); without guess and checking.