I want help cleaning up this code to make it both neater and shorter. This code is to test account creation in my personal website.
Code: Select all
; this script opens the bookmark, generates a random name, and inputs an age.
SetWorkingDir %A_ScriptDir%
#SingleInstance, Force
name := ""
Loop 10 {
random, c, 97, 97 + 26
random, n, 0, 10
name .= chr(c) . n
}
; this presses the bookmark
MouseMove, 40, 85
Click
; this make sures the page is fully loaded.
loop {
CoordMode Pixel
ImageSearch, x0, y0, 560, 565, 1200, 670, loaded1.png
if(!ErrorLevel) {
break
}
else if(ErrorLevel = 1 ) {
CoordMode Pixel
ImageSearch, x1, y1, 560, 565, 1200, 670, loaded2.png
if(!ErrorLevel) {
break
}
else if (ErrorLevel = 1 ) {
CoordMode Pixel
ImageSearch, x2, y2, 560, 565, 1200, 670, loaded3.png
if(!ErrorLevel) {
break
}
else if (ErrorLevel = 1 ) {
continue
}
}
}
}
sleep, 2000
; this presses the name field in the page.
MouseMove, 955, 630
Click
sleep, 100
; this fills in the name field in the page.
Send, %name%
sleep, 100
; this presses the continue button in the page.
MouseMove, 830, 690
Click
sleep, 100
; this makes sure the age page is loaded.
loop {
CoordMode Pixel
ImageSearch, x3, y3, 745, 590, 1325, 700, loadedAge1.png
if(!ErrorLevel) {
break
}
else if (ErrorLevel = 1 ) {
CoordMode Pixel
ImageSearch, x4, y4, 745, 590, 1325, 700, loadedAge2.png
if(!ErrorLevel) {
break
}
else if (ErrorLevel = 1 ) {
CoordMode Pixel
ImageSearch, x5, y5, 745, 590, 1325, 700, loadedAge3.png
if(!ErrorLevel) {
break
}
else if (ErrorLevel = 1 ) {
CoordMode Pixel
ImageSearch, x6, y6, 745, 590, 1325, 700, loadedAge4.png
if(!ErrorLevel) {
break
}
else if (ErrorLevel = 1 ) {
continue
}
}
}
}
}
sleep, 1000
; this fills in the birthday parameters randomly.
Send {tab}
Random, month, 1, 12
Send, %month%
sleep, 1000
Send {tab}
Random, day, 1, 28
Send, %day%
sleep, 1000
Send {tab}
Random, year, 1970, 2000
Send, %year%
sleep, 1000
Send {enter}
sleep, 1000
Send {enter}
sleep, 5000
; this exits out of the prompts.
MouseMove, 925, 975
loop, 10 {
Click
}
return