Jump to content

Window Finder


FSRxc
 Share

Recommended Posts

Hi,

I'm very new to AutoIT, yesterday infact and I am creating a script which will automatilly load IE, enter a web address and then the credentials for a given website.

However, I would like to use the AutoIT Window Finder to ensure the URL is entered into the toolbar in IE. How does the Window finder work exactly? and what information would I need to enter syntax wise within the script so it works?

I had also thought about simply telling AutoIT to execute the 'Run' command and then enter the URL into the 'RUN' box inorder to bypass loading IE and then entering the URL. However, I have so far been unable to find the shell execute command for 'RUN' to make it work within AutoIT.

Any ideas?

Cheers.

Link to comment
Share on other sites

There are many ways to do this, and one of the simplest is:

$sURL = "http://www.autoitscript.com"
ShellExecute($sURL)
But that might open in a different browser if IE is not your default.

A more reliable method would be:

#include <IE.au3>

$sURL = "http://www.autoitscript.com"
$oIE = _IECreate($sURL)
That will get you IE every time.

Both ShellExecute() and _IECreate() are in the help file.

;)

Edited by PsaltyDS
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
Link to comment
Share on other sites

There are many ways to do this, and one of the simplest is:

$sURL = "http://www.autoitscript.com"
ShellExecute($sURL)
But that might open in a different browser if IE is not your default.

A more reliable method would be:

#include <IE.au3>

$sURL = "http://www.autoitscript.com"
$oIE = _IECreate($sURL)
That will get you IE every time.

Both ShellExecute() and _IECreate() are in the help file.

;)

That's great, thanks!

Out of interest, how does the 'Window Info Finder' work and how can I use that in relation syntax as appose to tabbing all of time, for example, when I want it to select a username and password field etc?

Link to comment
Share on other sites

First, you don't have to do it that way. Look at the example scripts in the help file under _IEFormElementSetValue(). Those functions get object references directly to the elements on the web page and work with them. So "tabbing around" is not required.

You could do it that way if you must, and ControlSend() would probably be the most reliable method. But you're jumping into a more advanced topic because a web page displayed in a browser is not the same thing at all as a button or edit control in a GUI.

;)

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
Link to comment
Share on other sites

First, you don't have to do it that way. Look at the example scripts in the help file under _IEFormElementSetValue(). Those functions get object references directly to the elements on the web page and work with them. So "tabbing around" is not required.

You could do it that way if you must, and ControlSend() would probably be the most reliable method. But you're jumping into a more advanced topic because a web page displayed in a browser is not the same thing at all as a button or edit control in a GUI.

;)

Interesting. Thanks again.

The example code for logging into Hotmail looks perfect for what I'm after actually, it just doen't try to enter a username and password when you run the example.

Basiclly, what I need to do is create an AutoIT that goes to a webmail page, enters credentials, composes a new email, enters the receiver details, subject and message body and then sends it. For the record, this is not to send SPAM/marketing or bulk emails etc.

; *******************************************************

; Example 3 - Login to Hotmail

; *******************************************************

;

#include <IE.au3>

; Create a browser window and navigate to hotmail

$oIE = _IECreate ("http://www.hotmail.com")

; get pointers to the login form and username, password and signin fields

$o_form = _IEFormGetObjByName ($oIE, "f1")

$o_login = _IEFormElementGetObjByName ($o_form, "login")

$o_password = _IEFormElementGetObjByName ($o_form, "passwd")

$o_signin = _IEFormElementGetObjByName ($o_form, "SI")

$username = "your username here"

$password = "your password here"

; Set field values and submit the form

_IEFormElementSetValue ($o_login, $username)

_IEFormElementSetValue ($o_password, $password)

_IEAction ($o_signin, "click")

Link to comment
Share on other sites

It's just an example, and the names of those elements may have changed since it was written. For example, the name of the Form may not be "f1" anymore.

Just like learning to use the AutoIt Window Info Tool to get information about a GUI control, you would need to learn how to use a DOM Inspector (like DebugBar) to get information about web page elements and see if any of that changed.

;)

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