Jump to content
UBot Underground

How to find the coordinates (x,y in pixels) of a html object on the page?


Recommended Posts

I need to find the coordinates (position) of an object on a webpage (with one of the corners of the browser window as the point of origin) and be able to save those coordinates in two variables (x,y)... I think that there is a way using jquery and the eval function in a variable but I'm not a javascript coder and I can't get that code to work using that object id or any other tag to select it... Can anyone give me a hand with this? :D PLS!!!

Link to post
Share on other sites

 

:D TJ you are great! He did it in few minutes after I asked him to help me... he's a genius!!! :D

 

Edit: The plugin is working fine it can find the mouse coordinates but it is not useful as a solution for the topic of this thread

Link to post
Share on other sites

I installed it... well it is not working :( ... on the download page it say: "Use the mouse over function to move your mouse over an area, then use the plugin to capture the X, Y position to variables and use as needed" ... mouse over do not move the mouse so the plugin will get the cursor position (over the run button or where you last moved the mouse with your hand) ...

 

navigate("http://www.ubotstudio.com/", "Wait")
mouse over(<innertext="Verify Emails">, "No")
wait(1)
plugin command("GetMousePosition.dll", "Get Mouse X,Y", #x, #y)
ui stat monitor("x=", #x)
ui stat monitor("y=", #y)

 

... 

so in the above example if I want to get the x and y coordinates of the "verify Emails" element o the page and insert them in the Move Mouse command or in the Click Mouse command the commands will click on the run button of the bot not on the Verify Email on the page...

Link to post
Share on other sites

Well TJ's plugin tells you the X and Y positions of the "Mouse Cursor" not and object on the page.

 

However to find the position of an object on a webpage you can use some jQuery.

 

There are 2 ways to do it:

 

1. Using offset() :

 

$(function(){ var posObject = $('#container'), posX = posObject.offset().left, posY = posObject.offset().top; });

jQuery Reference & More information on using the offset function: offset().

 

 

2. Using position() :

$(function(){ var posObject = $('#container'), posX = posObject.position().left, posY = posObject.position().top; });

 

jQuery Reference & More information on using the position function: position().

 

 

Hope it helps,

 

Praney ;)

  • Like 1
Link to post
Share on other sites
Well TJ's plugin tells you the X and Y positions of the "Mouse Cursor" not and object on the page.

 

However to find the position of an object on a webpage you can use some jQuery.

 

There are 2 ways to do it:

 

1. Using offset() :

 

$(function(){ var posObject = $('#container'), posX = posObject.offset().left, posY = posObject.offset().top; });

jQuery Reference & More information on using the offset function: offset().

 

 

2. Using position() :

$(function(){ var posObject = $('#container'), posX = posObject.position().left, posY = posObject.position().top; });

 

jQuery Reference & More information on using the position function: position().

 

 

Hope it helps,

 

Praney ;)

I have found this to but I don't know how to implement them in ubot ... I have the "ID" tag of an object from the page... I replace the #container with it?

 

For example, I have a div: <div class="container_24"> and I want to find the x and y on the page. I load jquery in a run javascript command then I set up a variable like this:

set(#test, $eval("$(function()
\{ var posObject = $(\'<div class=\"container_24\">\'), posX = posObject.position().left, posY = posObject.position().top; \});
posX;
posY;"), "Global")

 

What is wrong with this code? how can I make it return the x and y ?

Link to post
Share on other sites
Did you add the jQuery reference:

<script src="http://code.jquery.com/jquery-latest.js"></script>

??

 

It won't work without it.

yes I included the entire jquery code in a "run javascript" command in ubot... it is not working... may be I did not write the "set" command ok... can you test it for me and see if you can make it work?

Link to post
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.

Guest
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.

Loading...
×
×
  • Create New...