Sign in to follow this  
Followers 0
bundyxc

Automating Web Tasks

7 posts in this topic

#1 ·  Posted (edited)

This is just a quick script I made for a friend (no, there's no personal data here).

$i = 1
While $i = 1
Run("C:\Program Files\Mozilla Firefox\firefox.exe")


WinWaitActive("Mozilla Firefox Start Page - Mozilla Firefox")

;Connect to InfiniteAdds
Send("{CTRLDOWN}l{CTRLUP}")
Send("http://infiniteadds.org/")
Send("{ENTER}")
WinWaitActive("InfiniteAdds.com - Mozilla Firefox")
Sleep(1500)

;Log in as Bramshakalaka
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}")
Send("442410747")
Send("{ENTER}")
Sleep(10000)

;Connect to MaxAdds
Send("{CTRLDOWN}l{CTRLUP}")
Sleep(1000)
Send("http://maxadds.com/")
Send("{ENTER}")
WinWaitActive("MaxAdds.com - Mozilla Firefox")
Sleep(5000)

;Log in to MaxAdds as Bramshakalaka
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}")
Send("442410747")
Send("{ENTER}")
Sleep(15000)


;Close
WinClose("MaxAdds.com - Mozilla Firefox")
Sleep(1800000)
WEnd

First off, I couldn't get the script to run indefinitely, so I just had to use a loop to make it repeat this every 30 minutes. Maybe there's an easier way to do this.

Here's the idea of the "program": Open Firefox, go to a site.. log in. Go to another site.. log in. Now, the only problems I'm having is that with the way I have it set up, I have to rely on "Sleep" to wait for pages to load. Is there any other way to do this? I also kind of wanted a messageBox to pop up before the program starts.. but I also run this when my computer is idle, so I'd like it to close the message box if I don't respond. Is this possible? I'm also wondering if there's any other way to get the program to find forms in the site.. as opposed to having to hit TAB a bunch of times. Thank you for all of your help.

Edited by bundyxc

Global $arr[2]

$arr[0]="hip"
$arr[1]="hip"
;^^ hip hip array. ^^

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

search help file dude hire are some examples to get you started.you get form info from web page source, CTRL+u in firefox.:

there are also following functions:

_IENavigate

_IELoadWait

MsgBox(4096, "Test", "This box will time out in 10 seconds", 10)


;Sample 1
;~ ===============
#include <IE.au3>
$oIE =_IECreate("http://us.mg3.mail.yahoo.com/dc/launch?action=folderview&YY=1693872259&.rand=871828897",0,1,1);opens the webpage,0, 1=visible, 1=_ieloadwait
; get pointers to the login form and username, password and signin fields
$o_login = _IEGetObjByName($oIE,"login")
_IEFormElementSetValue ($o_login, "tony")
$o_password = _IEGetObjByName($oIE,"passwd")
_IEFormElementSetValue ($o_password, "tony123_pass")
$o_signin=_IEGetObjByName($oIE,".save")

Sleep(2000) 
_IEAction($o_signin,"click")
Sleep(2000) 
_IEQuit($oIE)

Sleep(1000)


;Sample 2
;~ ===============
Opt("WinTitleMatchMode", 2)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
$oIE =_IECreate("http://us.mg3.mail.yahoo.com/dc/launch?action=folderview&YY=1693872259&.rand=871828897",0,0,1);opens the webpage,0, 0=hidden, 1=_ieloadwait

$win = '- Microsoft Internet Explorer'

WinSetState($win, "", @SW_SHOW)
Sleep(2000)
WinSetState($win, "", @SW_HIDE)
Sleep(2000)
WinSetState($win, "", @SW_SHOW)
Sleep(2000)

$o_login = _IEGetObjByName($oIE,"login")
_IEFormElementSetValue ($o_login, "username")
$o_password = _IEGetObjByName($oIE,"passwd")
_IEFormElementSetValue ($o_password, "pass")
$o_signin=_IEGetObjByName($oIE,".save")

Sleep(2000) 

_IEAction($o_signin,"click")

Sleep(2000) 

_IENavigate ($oIE, "http://www.google.com")
_IELoadWait ($oIE)
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

Thanks for that. I totally redid my code. I know this code is still noobish, but it's working 100 times better. Any suggestions?

#include <IE.au3>
$aIE =_IECreate("http://infiniteadds.org",0,0,1)
$a_login = _IEGetObjByName($aIE,"friendid")
_IEFormElementSetValue ($a_login, "21802680")
$a_signin=_IEGetObjByName($aIE,"action")
Sleep(500)
_IEAction($a_signin,"click")
_IELoadWait ($aIE)
Sleep(500)
_IEQuit($aIE)

$bIE =_IECreate("http://infiniteadds.org",0,0,1)
$b_login = _IEGetObjByName($bIE,"friendid")
_IEFormElementSetValue ($b_login, "442500255")
$b_signin=_IEGetObjByName($bIE,"action")
Sleep(500)
_IEAction($b_signin,"click")
_IELoadWait ($bIE)
Sleep(500)
_IEQuit($bIE)

$cIE =_IECreate("http://maxadds.com",0,0,1)
$c_login = _IEGetObjByName($cIE,"friendid")
_IEFormElementSetValue ($c_login, "21802680")
$c_signin=_IEGetObjByName($cIE,"action")
Sleep(500)
_IEAction($c_signin,"click")
_IELoadWait ($cIE)
Sleep(500)
_IEQuit($cIE)

$dIE =_IECreate("maxadds.com",0,0,1)
$d_login = _IEGetObjByName($dIE,"friendid")
_IEFormElementSetValue ($d_login, "442500255")
$d_signin=_IEGetObjByName($dIE,"action")
Sleep(500)
_IEAction($d_signin,"click")
_IELoadWait ($dIE)
Sleep(500)
_IEQuit($dIE)

Global $arr[2]

$arr[0]="hip"
$arr[1]="hip"
;^^ hip hip array. ^^

Share this post


Link to post
Share on other sites

The Sleep() commands are not necessary. You are not using blind mouse and keyboard, you are interacting with the browser on a programatic level.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thank you for your insight. This is the first program I've ever attempted (as I'm sure that you can see), so I'm learning all of the basics.

Just a quick question, how would I set a variable in the _IEFormElementSetValue?

I tried to declare the variable $num = 21802680

and then tried both of these:

_IEFormElementSetValue ($o_fid, "$num")

_IEFormElementSetValue ($o_fid, $num)

Neither worked. Any thoughts?

Here's my current code.

#include <IE.au3>
$oIE =_IECreate("http://infiniteadds.org",0,1,1)
$o_fid = _IEGetObjByName($oIE,"friendid")
$o_submit=_IEGetObjByName($oIE,"action")
_IEFormElementSetValue ($o_fid, "21802680")
_IEAction($o_submit,"click")
_IELoadWait ($oIE)

_IENavigate($oIE, "http://infiniteadds.org")
_IEFormElementSetValue ($o_fid, "442500255")
_IEAction($o_submit,"click")
_IELoadWait ($oIE)

_IENavigate($oIE, "http://maxadds.com",)
_IEFormElementSetValue ($o_fid, "21802680")
_IEAction($o_submit,"click")
_IELoadWait ($oIE)

_IENavigate($oIE, "maxadds.com",)
_IEFormElementSetValue ($o_fid, "442500255")
_IEAction($o_submit,"click")
_IELoadWait ($oIE)

_IEQuit($oIE)
Edited by bundyxc

Global $arr[2]

$arr[0]="hip"
$arr[1]="hip"
;^^ hip hip array. ^^

Share this post


Link to post
Share on other sites

This, adapted from your code, worked fine for me:

#include <IE.au3>

$oIE =_IEAttach("InfiniteAdds.com")

$o_fid = _IEGetObjByName($oIE,"friendid")

$o_submit=_IEGetObjByName($oIE,"action")

_IEFormElementSetValue ($o_fid, "21802680")

_IEAction($o_submit,"click")

You'll need to be more specifiec when you say "Neither worked".

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Sorry about that. My code worked, but I just wanted to know if there was a way to insert a variable, instead of plaintext. When I said neither worked, I meant that when I put in $num without quotes, then it didn't type anything at all (wrong syntax?), and then when I put it in quotes, it just typed "$num" (without quotes, obviously).


Global $arr[2]

$arr[0]="hip"
$arr[1]="hip"
;^^ hip hip array. ^^

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