Jump to content
Sign in to follow this  

Triangulation of coordinates on screen

Recommended Posts


OK, it seems I've really got some rookie knowledge limitations preventing me from getting an effective script working. Here is my challenge:

I'm working on a script that automates a user-defined list of actions to be performed on a web app. I've failed miserably at getting _FF to work, but I'm not sure it would help anyway.

These actions involve clicking on controls in the app, and I've automated it by giving each action coordinates for each piece. "Click at [x,y], then click at [x1,y1] etc. All the coordinates are in relation to the app's window.

Since there is a possibility of different users' browsers rendering slightly differently -- and more likely, that the browser chrome on user A is of a different size than the browser chrome on user B -- I've got a triangulation procedure. The script guides the user to move his mouse to a particular point on the screen, and then all subsequent coordinates are given in relation to that point.

Here is the code for this procedure:

Func _Triangulate()
    Local $xtest, $ytest, $coords[2]

    Local $continue=7

    ;move the mouse to the starting point

        ;until the Y coordinate is set or the user cancels, loop
    While (Not $coords[1]) and ($continue=7)
        $continue = MsgBox(259,"Triangulation","Judge whether the cursor is, vertically, pointing to the bottommost edge of the [landmark]. Click 'Yes' if it is, press 'Return' if it isn't. Cancel to exit the script.")
        If $continue = 6 Then
                        ;if user says cursor is in the right Y position,
                        ;record that position
            $coords[1] = $ytest
            ;otherwise, move the cursor up 3
                        $ytest-=3 ;

    ;If the user cancelled, end the script
        If $continue=2 Then

    ;put the mouse back to the current position

    ;repeat the loop, this time using the X coordinate
        While (Not $coords[0]) and ($continue=7)
        $continue = MsgBox(259,"Triangulation","Y coordinate locked. Judge whether the cursor is, horizontally, pointing to the [landmark]. Click 'Yes' if it is, press 'Return' if it isn't. Cancel to exit the script.")
        If $continue = 6 Then
            $coords[0] = $xtest

    If $continue=2 Then
    Return $coords

It feels so kludgy to me, and I'm open to more elegant solutions to this whole problem (even if it means using something other than x/y coordinates to accomplish the task.

But here's the real problem: I'm using Win 7, it works fine. When I compile the script as 32-bit and send it over to someone using XP, this validation doesn't work. On my screen, I can see the mouse move fine, it remains an arrow and as long as I use the Enter key instead of clicking "No" while it loops, I can easily see the cursor move steadily into position.

On my coworker's machine, however (XP running on a VM on a Linux box), this all doesn't work: the cursor remains an i-bar for one, it doesn't reliably move into position. It's as if MOST of the time (but not ALL of the time) whenever this MsgBox is rendered, it takes the cursor with it.

What is a noob to do?

Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.