Jump to content

Cursor position


Recommended Posts

Hi, (sorry for my bad english, just in case)

i dont know whats the problem when i open my desired windows to get the X,Y poisition for macroing, i move my cursor on the desired position, then write the X,Y coord, when i move my mouse and put the cursor on the same place again i have a big difference of 100*pixel .. (using AutoIt Window Spy) never the same result i tried to start each time from coord 0, 0 then move back to the desired position .. always the same problem and btw i dont have any cursor acceleration

anyone know?

Link to comment
Share on other sites

probably has to do with your using either the coords relative to the window versus relative to the desktop size, something like that... rtfm, look at the autoit options, you can set it to use one or the other.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

There are a couple things to be careful of when using pixel coordinates. Mainly, you should pay attention to what MouseCoordMode you are in. You can either use absolute screen coordinates (the default) or coordinates relative to the active window. Each one is more appropriate in various curcumstantes. For example, if you are using absolute coordinates and get your mouse position through the Spy window, unless the window is in the exact same position next time it is opened, it will be in a different location. This will cause your previously working script to break.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

no, because my window cursor and desktop cursor are the same... i can start from 0,0 then going to my hotspot and just for fun going back to 0,0 (normally top-left corner) i can get coord 0,0 in center of my window ?!?! how im suppose now to make a working macro with mouseclick.

Link to comment
Share on other sites

im currently using .. example: "MouseClick ("Left", 466, 42, 2)"

but is not the problem the problem is how to get an "absolute window coordinate"

can you explain more what you are talking about Pekster?

Link to comment
Share on other sites

Absolute coordinates are full screen coordinates whereas window relative coordinates are specific to the active window. In the included image below, the corner where the red arrow points is the absolute coordinates 0, 0 and the yellow arrow points to the corner of the window that is also coordinates 0, 0. The differance is that one is using the absolute coordinate option, and the other is set to relative. Please see the function Opt() in the manual for information on this. Also, a larger sample of the image is avaiable here. (Sorry, the larger picture file was killing my UT2K4 game. You'll just have to live with the smaller one :D )

Edited to correct a small typo, and again to remove larger picture

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

ok thanks for the info but the main problem still unresolved... how do i get THE coordinate of my hotspot.

EDIT: its impossible for me to get the right coord cause when i move my mouse around and trying to get the coord again it always change sometime i can have 330,30 .. or 576,60 etc.. etc..

Edited by Zykl02
Link to comment
Share on other sites

ok thanks for the info but the main problem still unresolved... how do i get THE coordinate of my hotspot.

well, what's your hotspot? I button on a dialog, a picture on a webpage? there's numerous ways to get a location and then have a mouse click on it...

here's a little snipet that looks for a specific color then moves the mouse to that coord. I wrote it in a do loop to play curveball.swf automatically (it sucks, but it does move the mouse to that color)

$moveto = PixelSearch(113, 145, 689, 540, 0xA0FFB2 , 10 , 2)
   If Not @error Then
   MouseMove( $moveto[0], $moveto[1] ,0 )
   EndIf

in this case I just went with absolute coords and avoided the issue of windows size and location by resizing the IE window to 800x600 at the start of the script.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

ok thanks i will try to make my macro using pixel color its a little more tricky but it should work too

well, really, what're you trying to click? there's probably a better and less iffy way than pixel searching... can you do whatever you're trying to do by just using the keyboard? that's the best way to get autoit to work right everytime... well, second best, the best is really to us controls...

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

what is it you're trying to click?

Please elaborate to help us help you...

Some helpful information:

  • Your Operating System (or Systems if this is a cross platform issue)
  • Script snipit of the script that's not working (try to isolate just the part that's not working)
  • what you've already tried to make it work (snipits of that code doesn't hurt if you have it)
  • what version of autoit you're running
  • what you're trying to make the script do (someone may have already
  • figured it out, or it might be in the FAQ)
  • what you've already read in the FAQ or Help File that didn't work
  • And whatever else you think might be helpful in helping us help you...

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

I have yet to see the Window Spy produce the behavior you are describing. Are you absolutely positive you are reading it correctly? Can you give any more information other than "It don't work" to us, such as what window are you trying to view? The more you tell us, the more likely you are to get the problem solved.

Link to comment
Share on other sites

Are you sure you are reading the right values? I have used the SpyWindow since version 2 of AutoIt, and I have never seen it report invalid pixel coordinates on any OS from 98 to XP Pro. There is a sample of what you want to look for in a linked picture. As you can see, when I mouse over the "File" menu (let's say I wanted to click on it) the highlighted rectangle in red shows the absolute ("On Desktop") coordinates, and the relative ("In Window") coordinates. The absolute coordinates will never change for the same mouse position on the screen (unless you change resoutions.) Also, as long as the window stays the same size, the relative coordinates should always point to the "File" menu of this window provided it is the active window when using relative coordinates.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...