Sign in to follow this  
Followers 0
rrenis

Can anyone help me tidy this up please?

8 posts in this topic

Hi,

This is my first attempt with AutoIt so I know it's very basic and I'm probably going about things the wrong way! :D

All I want to do is to log on to a web site automatically. Unfortunately I can't simply record the mouse functions because I want to be able to give it to my fellow workmates who have different screen resolutions and versions of Windows (I assume the mouse movement recordings are machine specific?).

Here's what I have so far but I'm using the sleep command to allow for the windows starting up, but depending on what I have running sometimes the sleep delay is not enough. I know I could increase the sleep time but then I may as well just log in normally :)

Code:

Run("C:\Program Files\Internet Explorer\iexplore.exe")

Sleep(2000)

Send("{CTRLDOWN}o{CTRLUP}")

Send("http{SHIFTDOWN};{SHIFTUP}//nameofwebsite.com{ENTER}")

Sleep(2000)

Send("username{TAB}password{ENTER}")

The second sleep command is there because the website we log onto automatically throws up a popup for the login.

When I tried recording the code I got a WinWait command but everyone has different home pages so again that doesn't work - hence the Run command.

I hope I've made sense with all this. If anyone can offer some suggestions I'd be very grateful!! :D

Cheers,

rrenis

Share this post


Link to post
Share on other sites



If you tell me the website, I can help you more ...


----[ SandyD ]---

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If you tell me the website, I can help you more ...

<{POST_SNAPBACK}>

:EDITED:

Thanks mate - the website is h++p://service.xxxx.co.uk - sorry can't give out the user and pass :)

I guess I could use the WinWait command but I'd given up on this because I don't know a way of adding a "wildcard", i.e. when I used the recorder I got the code below but some of the PC's at work don't have the "provided by..." suffix - not sure why the IT guys haven't standardised it. Is it possible to shorten the WinWait so that after h++p://service.xxxx.co.uk there is a "wildcard" added to the code for those users that don't have the "provided by..." suffix?

Code:

WinWait("h++p://service.xxxx.co.uk - xxxx Online - Microsoft Internet Explorer provided by #name of company#","")

If Not WinActive("h++p://service.xxxx.co.uk - xxxx Online - Microsoft Internet Explorer provided by #name of company#","") Then WinActivate("h++p://service.xxxx.co.uk - xxxx Online - Microsoft Internet Explorer provided by #name of company#","")

WinWaitActive("h++p://service.xxxx.co.uk - xxxx Online - Microsoft Internet Explorer provided by #name of company#","")

Thanks for getting back to me so quick!! :D

Cheers,

rrenis

Edited by rrenis

Share this post


Link to post
Share on other sites

Hi,

This is my first attempt with AutoIt so I know it's very basic and I'm probably going about things the wrong way!  :D

All I want to do is to log on to a web site automatically. Unfortunately I can't simply record the mouse functions because I want to be able to give it to my fellow workmates who have different screen resolutions and versions of Windows (I assume the mouse movement recordings are machine specific?).

Here's what I have so far but I'm using the sleep command to allow for the windows starting up, but depending on what I have running sometimes the sleep delay is not enough. I know I could increase the sleep time but then I may as well just log in normally  :)

Code:

Run("C:\Program Files\Internet Explorer\iexplore.exe")

Sleep(2000)

Send("{CTRLDOWN}o{CTRLUP}")

Send("http{SHIFTDOWN};{SHIFTUP}//nameofwebsite.com{ENTER}")

Sleep(2000)

Send("username{TAB}password{ENTER}")

The second sleep command is there because the website we log onto automatically throws up a popup for the login.

When I tried recording the code I got a WinWait command but everyone has different home pages so again that doesn't work - hence the Run command.

I hope I've made sense with all this. If anyone can offer some suggestions I'd be very grateful!!  :D

Cheers,

rrenis

<{POST_SNAPBACK}>

Try this:

$nameofwebsite = "http://www.autoitscript.com"

$popuptitle = "Logon" ;just an example (change this to a part of text that is always in the title)

Opt("WinTitleMatchMode", 2);Match any substring in the title

;launches the page direct minimized and minimize the window, no ctrl o

Run("C:\Program Files\Internet Explorer\iexplore.exe " & $nameofwebsite,"",@SW_MINIMIZE )

WinWait("- Microsoft Internet Explorer", $nameofwebsite,10);wait until main IE window exists

;the ting is it waits for the popup because the mainwindow is minimized

WinWaitActive($popuptitle,"",10);this part of the title that shows up in the popup

sleep(500);&llow the window to build up correct so the default control can get the focus

Send("username{TAB}password{ENTER}")

WinSetState ( "- Microsoft Internet Explorer", $nameofwebsite, @SW_RESTORE );restore the main IE window

;the possebility is there that the url ($nameofwebsite) changed during the url, change to

;WinSetState ( "- Microsoft Internet Explorer", "", @SW_RESTORE )

That dous the job i think, let me know if it's not

Share this post


Link to post
Share on other sites

Try this:

$nameofwebsite = "http://www.autoitscript.com"

$popuptitle = "Logon" ;just an example (change this to a part of text that is always in the title)

Opt("WinTitleMatchMode", 2);Match any substring in the title

;launches the page direct minimized and minimize the window, no ctrl o

Run("C:\Program Files\Internet Explorer\iexplore.exe " & $nameofwebsite,"",@SW_MINIMIZE )

WinWait("- Microsoft Internet Explorer", $nameofwebsite,10);wait until main IE window exists

;the ting is it waits for the popup because the mainwindow is minimized

WinWaitActive($popuptitle,"",10);this part of the title that shows up in the popup

sleep(500);&llow the window to build up correct so the default control can get the focus

Send("username{TAB}password{ENTER}")

WinSetState ( "- Microsoft Internet Explorer", $nameofwebsite, @SW_RESTORE  );restore the main IE window

;the possebility is there that the url ($nameofwebsite) changed during the url, change to

;WinSetState ( "- Microsoft Internet Explorer", "", @SW_RESTORE  )

That dous the job i think, let me know if it's not

<{POST_SNAPBACK}>

Hi TuMbLeWeEd - thanks that worked great, can't imagine I would have got there myself but thanks to your pointers next to each peice of code I can understand what's doing what. Thanks!! :D

Just one small niggle - the initial screen pop's up over the login screen once the script ends, and so needs to be closed (or minimised). It's no big problem though - I'll have a go at trying to resolve it - but if anything springs to mind why this could be happening you'll save me hours of head scratching!! :)

Thanks,

rrenis

Share this post


Link to post
Share on other sites

Sussed it - just deleted the WinSetState command. :">

Many Many Thanks!!!!!!!!!!! :):D:D

Cheers,

rrenis

Share this post


Link to post
Share on other sites

Sussed it - just deleted the WinSetState command.  :">

Many Many Thanks!!!!!!!!!!!  :)  :D  :D

Cheers,

rrenis

<{POST_SNAPBACK}>

Didn't know the logon popup did not close on it's own.

My geus was you needed th main window.

No prob for the comments in it, it's no use for you to learn if you dont know wat is dous

(and for myself also, have a terrible memmory)

Try to do commenting always!!!

(wrote a script of a +-1500 lines a few monts ago with no comment at all, so im going crazy now to figure it out wat was the intension for some code pieces)

Share this post


Link to post
Share on other sites

Didn't know the logon popup did not close on it's own.

My geus was you needed th main window.

No prob for the comments in it, it's no use for you to learn if you dont know wat is dous

(and for myself also, have a terrible memmory)

Try to do commenting always!!!

(wrote a script of a +-1500 lines a few monts ago with no comment at all, so im going crazy now to figure it out wat was the intension for some code pieces)

<{POST_SNAPBACK}>

Thanks for the advice - for a noob like me it's much apreciated :huh:

Good luck with the 1500+ lines of code :D and with that in mind, thanks again for taking the time to help me out!!! :)

Cheers,

rrenis :D

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