Sign in to follow this  
Followers 0
igotandrew

Help Needed w/ Basic Macro Script

28 posts in this topic

#1 ·  Posted (edited)

Hello, I'm trying to create a little script that renews my ip address, because I am behind a router.

Call("rInternet")

Func rInternet()
    if WinExists("Mozilla Firefox") or WinExists(" - Mozilla Firefox") Then
        WinActivate("Mozilla Firefox")
        Sleep(1500)
    Else
        Run("C:\Program Files\Mozilla Firefox\firefox.exe", "", @SW_MAXIMIZE)
        Sleep(4000)
    EndIf
    If WinActive("Mozilla Firefox") Then
      ;Do Something
    Else
        WinActivate("Mozilla Firefox")
    EndIf

    MouseClick("left", 378, 66)
    Sleep(1000)
    Send("{DELETE}")
    Sleep(250)
    Send("192.168.1.1{ENTER}")
    Sleep(1000)
    Send("admin{tab}admin{ENTER}")  ;Authentication Required
    Sleep(7000)
    MouseMove(256, 629, 100)
    Sleep(100)
    MouseDown("left")
    sleep(250)
    MouseUp("left")
;MouseClick("left", 256, 629, 2)
;   $pix1 = PixelGetColor(137, 450)
;   $pix2 = PixelGetColor(263, 460)
;  $pix3 = PixelGetColor(131, 567)
 ; $pix4 = PixelGetColor(268, 568)

  ;if $pix1 = "0x6666CC" Then
;   MouseClick("left", 256, 629, 2)
;MsgBox(0, "", "Found Pixel 1")
  ;ElseIf $pix2 = "0x6666CC" Then
 ;   MouseClick("left", 256, 629, 2)
;   MsgBox(0, "", "Found Pixel 2")
  ;ElseIf $pix3 = "0x6666CC" Then
;   MouseClick("left", 256, 629, 2)
;    MsgBox(0, "", "Found Pixel 3")
  ;ElseIf $pix4 = "0x6666CC" Then
  ; MouseClick("left", 256, 629, 2)
;    MsgBox(0, "", "Found Pixel 4")
;  EndIf


    Sleep(18000)
EndFunc

I'm trying to get it to click the renew ip button, but thats not happening.

Everything else works.

Any ideas? I've tried 2 different methods.

--- Couple of things I forgot to add

0x6666CC << Is a safe pixel (it only shows on the webpage after it's loaded)

256, 629 << Coords of the Renew Ip button

Edited by Depression

Share this post


Link to post
Share on other sites



So no one knows the answer?

Share this post


Link to post
Share on other sites

If you want to do this in AutoIt, then you should be using IE and the IE.au3 UDF. I personally never use IE except where I have to, but if you want to script it from AutoIt, this is one of the "have to's".

:D


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

I don't know how to load ie w/ it.

Share this post


Link to post
Share on other sites

I don't know how to load ie w/ it.

The way to find out is to learn. Read the help file for the _IE* functions. Try a few of the example scripts. Yours would start like this:

#include <IE.au3>

$oIE = _IECreate("http://192.168.1.1")

; ...

:D


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

is IE.au3 already included in the installation?

I can't seem to find it on the forums.

Share this post


Link to post
Share on other sites

it is...type:

#Include <IE.au3>

:D

cheers :P

Share this post


Link to post
Share on other sites

So I've been toying with IE and for some reason I can't get the window to work...

I try stuff like WinExist(" - Microsoft Internet") and it doesn't return 1.

Share this post


Link to post
Share on other sites

Posted Image

This is the status of my router page.

Is there a way to read the status, to see if its "Disconnect", "Connecting", or "Connected"?

This doesn't seem to show up on visible text with the au3 window info app.

Share this post


Link to post
Share on other sites

Posted Image

This is the status of my router page.

Is there a way to read the status, to see if its "Disconnect", "Connecting", or "Connected"?

This doesn't seem to show up on visible text with the au3 window info app.

Share this post


Link to post
Share on other sites

Yes, you can get into the HTML web page document from the router in IE using the _IE* functions, and find out what text comes after "Status:". View the source on the page and find out what kind of Form/Frame/Tag/etc. that text is in. Then you go get it with the _IE* functions.

:D


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

Like which function?

I know how to isolate it, but how do I get the source?

Share this post


Link to post
Share on other sites

Like which function?

I know how to isolate it, but how do I get the source?

On the IE toolbar: View | Source

You are looking for Form tags then probably the input tags for the input boxes and buttons you want to work with.

:D


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

_IEBodyReadHTML() ?


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

_IEBodyReadHTML() ?

Thanks, thats what I was looking for.

Share this post


Link to post
Share on other sites

What do I do with that? I can't even get the source w/o obj var or something..

Share this post


Link to post
Share on other sites

What do I do with that? I can't even get the source w/o obj var or something..

You should really temporarily stop work on this project and work your way through the examples in the help file for the _IE* functions. Once you understand that, it will be much easier to help you.

What you are looking to pick up on is how the Document Object Model (DOM) works in a web browser (IE in this case). How to find objects in a Form, how to find input tags and identify the ones the ones you want, etc.

:D


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 should really temporarily stop work on this project and work your way through the examples in the help file for the _IE* functions. Once you understand that, it will be much easier to help you.

What you are looking to pick up on is how the Document Object Model (DOM) works in a web browser (IE in this case). How to find objects in a Form, how to find input tags and identify the ones the ones you want, etc.

:D

What do you mean?

Share this post


Link to post
Share on other sites

I read the function info..

Share this post


Link to post
Share on other sites

I read the function info..

That's a start. Did you run any of the examples in the help file for the various _IE* functions? Have you successfully gotten it show you the HTML for the page?

:D


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