Jump to content

help a total n00b creating his first script...


Recommended Posts

i have a program that backup my files and upload it to gmail accounts.... and i need many gmail accounts so i am trying to make this macro to semi-automatically creates gmail accounts (of course i have to enter the capchars)...

here what happened...

1- i created c:\test\ to put the files into

2- i will use browsar as the web browser and i put it's exe into c:\test\

3- i put a namelist.txt with the logins i will create in c:\test\

4- will use the password "password123" for all the accounts

5- will use the first password reminder question and the answer will be "passreminder" for all the accounts

i am using SciTe's scriptwriter to generate the code then i edit it together but i ran in some problems...

1- all the windows must be activated to send the input to them...and i must be not using the computer at all in any other activity...

Q1: is there a way to run the macro even if the window is not active and i am doing other work on the computer? or better yet is there a way to totally hide the windows even from the taskbar and still excute the macro?

2- i set 10 secs wait time for the page to load but sometimes my connection lags and the page wont load completely in 10 secs and the macro fails ....

Q2: is there a way to make the macro pause until the page is loaded eg. wait for "©2009 Google - Gmail for Organizations - Gmail Blog - Terms - Help " at the bottom of the page then execute?

3- i finished the macro till it gets to the capchar input box then i enter it then i press create my account manually....

Q3: how to popup a window with the capchar image and an input box and input button to enter it the captchar and resume the registration automatically

4- sometimes the username will be taken..

Q4: how to generate a txt only with the successfully created accounts?

any suggestions??

anyone would care to help a total n00b?

here is what i have done ...

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
Run("C:\test\browzar.exe http://mail.google.com/mail/signup")
Sleep (10000)
WinWait("Google Accounts - Browzar","")
If Not WinActive("Google Accounts - Browzar","") Then WinActivate("Google Accounts - Browzar","")
WinWaitActive("Google Accounts - Browzar","")
MouseMove(16,106)
MouseDown("left")
MouseUp("left")
Send("{TAB}{TAB}{TAB}{TAB}")
Run('C:\WINDOWS\NOTEPAD.EXE C:\VPN\NameList.txt')
WinWait("NameList.txt - Notepad","")
If Not WinActive("NameList.txt - Notepad","") Then WinActivate("NameList.txt - Notepad","")
WinWaitActive("NameList.txt - Notepad","")
Send("{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{CTRLDOWN}s{CTRLUP}{ALTDOWN}{F4}{ALTUP}")
WinWaitActive("Google Accounts - Browzar","")
Send("{CTRLDOWN}v{CTRLUP}{TAB}{CTRLDOWN}v{CTRLUP}{TAB}{CTRLDOWN}v{CTRLUP}{TAB}{TAB}password123{TAB}pas

sword123{TAB}{TAB}{TAB}{TAB}{DOWN}{TAB}{TAB}passreminder{TAB}{TAB}{TAB}{TAB}")
Link to comment
Share on other sites

is that considering the wait

would you be kind and explain more, i read the whole _IE Management ... and i still dot know what to do???

do i add ($f_wait = 1) .......and i am not using IE will it work with browzar...

thanks in advance...

ok... it's not working with browzar i will use IE ....

_IECreate ("http://mail.google.com/mail/signup $f_wait = "1" ) ???????

how to remove cookies after each round?

Edited by aeau2080
Link to comment
Share on other sites

first of all thank you oMBRa for your help so far....

i redid the whole macro ... i have some questions

Q1: how to popup a window with the captcha image and an input textbox and input button to enter the captcha and resume the registration automatically

Q2: how to make this work in the background ... ie completely invisible only pops to enter the captcha... i tested this macro while i was doing regular work and it failed .... it pasted the text to other windows

Q3:is there a better way to do the cut/paste copy/paste fron notepad??

i open NameList.txt, cut the first line to clipboard ,save and exit .... then paste it later ...

like this...

Run('C:\WINDOWS\NOTEPAD.EXE C:\VPN\NameList.txt')
sleep(2000)
WinWait("NameList.txt - Notepad","")
If Not WinActive("NameList.txt - Notepad","") Then WinActivate("NameList.txt - Notepad","")
WinWaitActive("NameList.txt - Notepad","")
Send("{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{CTRLDOWN}s{CTRLUP}{ALTDOWN}{F4}{ALTUP}")

Q4: how to generate a txt only with the successfully created accounts?

here is the whole script so far

#include <IE.au3>
Run("C:\WINDOWS\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
Run('C:\WINDOWS\NOTEPAD.EXE C:\test\NameList.txt')
WinWait("NameList.txt - Notepad","")
If Not WinActive("NameList.txt - Notepad","") Then WinActivate("NameList.txt - Notepad","")
WinWaitActive("NameList.txt - Notepad","")
Send("{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{CTRLDOWN}s{CTRLUP}{ALTDOWN}{F4}{ALTUP}")
sleep (500)
$oIE = _IECreate ("C:\test\gmail.htm")
$oForm = _IEFormGetObjByName ($oIE, "createaccount")
$oFirstName = _IEFormElementGetObjByName ($oForm, "FirstName")
_IEAction($oFirstName, "focus")
Send("{CTRLDOWN}v{CTRLUP}")
$oLastName = _IEFormElementGetObjByName ($oForm, "LastName")
_IEAction($oLastName, "focus")
Send("{CTRLDOWN}v{CTRLUP}")
$oEmail = _IEFormElementGetObjByName ($oForm, "Email")
_IEAction($oEmail, "focus")
Send("{CTRLDOWN}v{CTRLUP}")
Run('C:\WINDOWS\NOTEPAD.EXE C:\test\Password.txt')
WinWait("Password.txt - Notepad","")
If Not WinActive("Password.txt - Notepad","") Then WinActivate("Password.txt - Notepad","")
WinWaitActive("Password.txt - Notepad","")
Send("{SHIFTDOWN}{DOWN}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ALTDOWN}{F4}{ALTUP}")
sleep (500)
$oPasswd = _IEFormElementGetObjByName ($oForm, "Passwd")
_IEAction($oPasswd, "focus")
Send("{CTRLDOWN}v{CTRLUP}")
$oPasswdAgain = _IEFormElementGetObjByName ($oForm, "PasswdAgain")
_IEAction($oPasswdAgain, "focus")
Send("{CTRLDOWN}v{CTRLUP}")
_IEFormElementCheckboxSelect ($oForm, 0, "PersistentCookie", 0, "byIndex")
_IEFormElementCheckboxSelect ($oForm, 0, "smhck", 0, "byIndex")
$oSelection = _IEFormElementGetObjByName ($oForm, "Selection")
_IEFormElementSetValue ($oSelection, "What is your primary frequent flyer number")
$oIdentityAnswer = _IEFormElementGetObjByName ($oForm, "IdentityAnswer")
_IEFormElementSetValue ($oIdentityAnswer, "passreminder")
$oLoc = _IEFormElementGetObjByName ($oForm, "Loc")
_IEFormElementSetValue ($oLoc, "US")


-----------------------------------------------------------------------------------------------------------------------------------------
Here i want to ask
-----------------------------------------------------------------------------------------------------------------------------------------
Q1: how to popup a window with the captcha image and an input textbox and input button to enter it and resume the registration automatically
-----------------------------------------------------------------------------------------------------------------------------------------



$oNewAccountCaptcha = _IEFormElementGetObjByName ($oForm, "NewAccountCaptcha")
_IEAction($oNewAccountCaptcha, "focus")

didn't include _IEFormSubmit ($oForm) because i don't want it to auto submit just yet... i have to enter the captcha first...

Link to comment
Share on other sites

Q2: how to make this work in the background ... ie completely invisible only pops to enter the captcha... i tested this macro while i was doing regular work and it failed .... it pasted the text to other windows

use _IEFormElementSetValue to set the data of a form, so iexplorer dosnt have to be active

Q3:is there a better way to do the cut/paste copy/paste fron notepad??

yes, check in the help file FileOpen, FileReadLine:

open the file with the list, read one line and then use _IEFormElementSetValue setting the data u have read

Link to comment
Share on other sites

i didnt't know how to do "paste" with _IEFormElementSetValue... Just found out about "ClipGet()" & "ClipPut()"

_IEFormElementSetValue ($oFirstName,ClipGet())

i am stuck ... it keeps copying the same name over and over.... Still can't figure out how to use "FileReadLine" to cut the first line in the txt to the clipboard and save it....ie ... i want the read line to be deleted from the txt file ....

#include <IE.au3>
Run("C:\WINDOWS\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
$NameList = FileOpen("C:\test\NameList.txt", 0)
$Username= FileReadLine($NameList,1)
ClipPut($Username)
$oIE = _IECreate ("C:\test\gmail.htm")
$oForm = _IEFormGetObjByName ($oIE, "createaccount")
$oFirstName = _IEFormElementGetObjByName ($oForm, "FirstName")
_IEFormElementSetValue ($oFirstName,ClipGet())
$oLastName = _IEFormElementGetObjByName ($oForm, "LastName")
_IEFormElementSetValue ($oLastName,ClipGet())
$oEmail = _IEFormElementGetObjByName ($oForm, "Email")
_IEFormElementSetValue ($oEmail,ClipGet())
$PassswordFile = FileOpen("C:\test\Password.txt", 0)
$Pssword = FileReadLine($PassswordFile,1)
ClipPut($Pssword)
$oPasswd = _IEFormElementGetObjByName ($oForm, "Passwd")
_IEFormElementSetValue ($oPasswd,ClipGet())
$oPasswdAgain = _IEFormElementGetObjByName ($oForm, "PasswdAgain")
_IEFormElementSetValue ($oPasswdAgain,ClipGet())
_IEFormElementCheckboxSelect ($oForm, 0, "PersistentCookie", 0, "byIndex")
_IEFormElementCheckboxSelect ($oForm, 0, "smhck", 0, "byIndex")
$oSelection = _IEFormElementGetObjByName ($oForm, "Selection")
_IEFormElementSetValue ($oSelection, "What is your primary frequent flyer number")
$oIdentityAnswer = _IEFormElementGetObjByName ($oForm, "IdentityAnswer")
_IEFormElementSetValue ($oIdentityAnswer, "passreminder")
$oLoc = _IEFormElementGetObjByName ($oForm, "Loc")
_IEFormElementSetValue ($oLoc, "US")
Edited by aeau2080
Link to comment
Share on other sites

I have done it for you, not tested though:

#include <IE.au3>
#include <File.au3>
Run("C:\WINDOWS\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
$NameList = FileOpen("C:\test\NameList.txt", 0)
$PassswordFile = FileOpen("C:\test\Password.txt", 0)
$iPwLines = _FileCountLines("C:\test\Password.txt")
$iNameLines = _FileCountLines("C:\test\NameList.txt")
Dim $i = 1
$oIE = _IECreate("C:\test\gmail.htm")
Do
    _IENavigate($oIE, "C:\test\gmail.htm");change this url with the correct url
    $Username = FileReadLine($NameList, $i)
    $oForm = _IEFormGetObjByName($oIE, "createaccount")
    $oFirstName = _IEFormElementGetObjByName($oForm, "FirstName")
    _IEFormElementSetValue($oFirstName, $Username)
    $oLastName = _IEFormElementGetObjByName($oForm, "LastName")
    _IEFormElementSetValue($oLastName, $Username)
    $oEmail = _IEFormElementGetObjByName($oForm, "Email")
    _IEFormElementSetValue($oEmail, $Username)

    $Pssword = FileReadLine($PassswordFile, $i)

    $oPasswd = _IEFormElementGetObjByName($oForm, "Passwd")
    _IEFormElementSetValue($oPasswd, $Pssword)
    $oPasswdAgain = _IEFormElementGetObjByName($oForm, "PasswdAgain")
    _IEFormElementSetValue($oPasswdAgain, $Pssword)
    _IEFormElementCheckBoxSelect($oForm, 0, "PersistentCookie", 0, "byIndex")
    _IEFormElementCheckBoxSelect($oForm, 0, "smhck", 0, "byIndex")
    $oSelection = _IEFormElementGetObjByName($oForm, "Selection")
    _IEFormElementSetValue($oSelection, "What is your primary frequent flyer number")
    $oIdentityAnswer = _IEFormElementGetObjByName($oForm, "IdentityAnswer")
    _IEFormElementSetValue($oIdentityAnswer, "passreminder")
    $oLoc = _IEFormElementGetObjByName($oForm, "Loc")
    _IEFormElementSetValue($oLoc, "US")
    $i += 1
Until $i = $iPwLines Or $i = $iNameLines
FileClose($PassswordFile)
FileClose($NameList)
Edited by oMBRa
Link to comment
Share on other sites

thanks a million for this neat and organized code but unfortunately it didn't work ....

it kept reading a line, pasting in the respective fields and reloading the page, then reads the next line, paste ...etc. ... no chance or pause to enter the captcha and submit the form at all ... moreover i am looking for a was to cut the lines instead of just reading them...

Link to comment
Share on other sites

thanks a million for this neat and organized code but unfortunately it didn't work ....

it kept reading a line, pasting in the respective fields and reloading the page, then reads the next line, paste ...etc. ... no chance or pause to enter the captcha and submit the form at all ... moreover i am looking for a was to cut the lines instead of just reading them...

the purpose of my code was to show you how to read more line and how to set the data in the form
Link to comment
Share on other sites

so... is there a way to cut the line instead of reading them... controlsend ctrl+x maybe ???

the operation of reading lines is in background, you dont see the file opened in a text editor, to delete the string look in the help file for _ReplaceStringInFile
Link to comment
Share on other sites

replaced with a blank line !... any method to remove blank lines from the txt

FileClose("C:\test\NameList.txt")
FileOpen("C:\test\NameList.txt", 1)
$find= ClipGet()
$replace= ""
$Replacing= ("C:\test\NameList.txt")
_ReplaceStringInFile($Replacing,$find,$replace)
Link to comment
Share on other sites

found this code and it removed the blank line but with error...

#include <Array.au3>
#include <File.au3>
Dim $sFile = "C:\test\NameList.txt"
Dim $aLines
_FileReadToArray($sFile, $aLines)
_ArrayDelete($aLines,4)
FileDelete($sFile)
For $i=1 to $aLines[0]
    If $aLines[$i]<>"" Then FileWriteLine($sFile,$aLines[$i])
Next

Test.au3 (33) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

If $aLines[$i]<>"" Then FileWriteLine($sFile,$aLines[$i])

If ^ ERROR

when i put it together with the macro it returns that error and the macro wont continue...

Edited by aeau2080
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...