Sign in to follow this  
Followers 0
Mesca

How Can I Make My Script Work On Other PC's?

13 posts in this topic

I have made a really small script the utilizes mouse clicks from x,y co-ordinates.

If I wanted to share this script, how can make it work on other PC's, since there are variables like different screen resolutions, etc.?

Share this post


Link to post
Share on other sites



You can get desktop size from the macros (@DesktopHeight, @DesktopWidth).

If the coordinates are relative to a window, then you probably don't need to worry about it. Just set Opt("MouseCoordMode", 0) (or mode = 2).

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Give this a try...

; Settings for the mouse

; This is for the 1440 x 900 screen - change as needed
Global $Width = 1440
Global $Height = 900

MyMouseMove(100, 200)

Func MyMouseMove($x, $y)
    MouseMove(@DesktopWidth * $x / $Width, @DesktopHeight * $y / $Height)
EndFunc   ;==>MyMouseMove

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

You can get desktop size from the macros (@DesktopHeight, @DesktopWidth).

If the coordinates are relative to a window, then you probably don't need to worry about it. Just set Opt("MouseCoordMode", 0) (or mode = 2).

:)

I understand what you mean, but the script I made if a website. So just say the other user has different settings in Internet Explorer like no status bar or buttons at the top, the co-ordinated would change

Share this post


Link to post
Share on other sites

I understand what you mean, but the script I made if a website. So just say the other user has different settings in Internet Explorer like no status bar or buttons at the top, the co-ordinated would change

If you're trying to simulate input to a webpage, you could try using 'IE Management' UDF for more reliable functions then clicking screen locations.

Share this post


Link to post
Share on other sites

I understand what you mean, but the script I made if a website. So just say the other user has different settings in Internet Explorer like no status bar or buttons at the top, the co-ordinated would change

Use the IE.au3 UDF. Get an object reference to the element (i.e. $oElement) you are interested in and get the position with _IEPropertyGet($oElement, "browserX") with browserX\browserY, or screenX\screenY.

Of course, if all you want to do is click that element, you can just do _IEAction($oElement, "click") without looking for coordinates at all.

Spend some time with the example scripts in the help file for the _IE* functions.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Use the IE.au3 UDF. Get an object reference to the element (i.e. $oElement) you are interested in and get the position with _IEPropertyGet($oElement, "browserX") with browserX\browserY, or screenX\screenY.

Of course, if all you want to do is click that element, you can just do _IEAction($oElement, "click") without looking for coordinates at all.

Spend some time with the example scripts in the help file for the _IE* functions.

:)

I used a javescript to find the x,y position of the element I am trying to click. How do I phrase my _IEAction line so it will click it?

Thank you for your help and patience.

Share this post


Link to post
Share on other sites

I used a javescript to find the x,y position of the element I am trying to click. How do I phrase my _IEAction line so it will click it?

Thank you for your help and patience.

You don't with the coordinates. _IEAction() requires an object reference to the DOM element you want to act on.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You don't with the coordinates. _IEAction() requires an object reference to the DOM element you want to act on.

:)

Sorry for being a complete noob, but do you find the name of the object reference?

Share this post


Link to post
Share on other sites

Sorry for being a complete noob, but do you find the name of the object reference?

Let's back up to some basics that were passed over earlier:

1. Is this a point on a web page you want to click on?

2. If so, what kind of web page is it, and what is the nature of the element you want to click on (i.e. submit button, link, etc.)?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Let's back up to some basics that were passed over earlier:

1. Is this a point on a web page you want to click on?

2. If so, what kind of web page is it, and what is the nature of the element you want to click on (i.e. submit button, link, etc.)?

:)

Yes, I want to click a certain point on the page. It is a forum, and I want to to select the first topic within the forum.

So the first topic can always change and is not a set button.

I made the bot already using MouseClick and it works fine for me, but I was wondering about sharing it.

Share this post


Link to post
Share on other sites

Yes, I want to click a certain point on the page. It is a forum, and I want to to select the first topic within the forum.

So the first topic can always change and is not a set button.

I made the bot already using MouseClick and it works fine for me, but I was wondering about sharing it.

If it works, go with it.

If you want something more reliable, you could look at the page with a DOM inspector like DebugBar. You'll probably find the links to the topics within a FORM element, and for example, you could just click on the first link element in that form. This all depends on learning something about HTML and the DOM as used by the IE.au3 UDF in AutoIt. Maybe it's not worth the effort right now if you've got an easy work-around. But if you keep writing scripts towards web pages, you will eventually want to learn it.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  
Followers 0