03-20-2018, 06:09 PM
I am trying to write a macro that will post classified ads at classifiedsforfree.com. The way it works is: You write your ad, select a US state from the combobox. That brings up another combobox with a list of cities in that state. You select a city if you want, then hit the submit button. That brings you to another page that announces that your ad posted successfully. Then you are given the option to post that same ad in another state/city combination. Simply click the "post another ad" button and you are taken back to the ad posting page to go through the same process.
Everything works fine until I get to the end of the first list of cities for the state of Alabama. My approach was to simply let the macro generate an error (item not found) and the error handling instructions were to simply post that ad at the state level, no city selected, and then go back to the ad posting page, select the next state from the combobox (Alaska), and continue.
But every time the macro gets to this point, the next state on the list is indeed selected, but the macro puts the list of cities for ALABAMA in the cities combobox in addition to the cities for Alaska. The program then tries to post an ad for Birmingham, Alaska, which we all know doesn't exist. NO MATTER WHAT I DO, I CANNOT PREVENT THIS BEHAVIOR FROM HAPPENING.
Could somebody please tell me what I am doing wrong?
Here is the code I have so far-
int i
int j
int w
int w1
int w2
int w3
int w4
for i 1 200
w1=win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1")
act w1
for j 7 200
3
w2=wait(3 WV win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1"))
3
Acc a.Find(w2 "COMBOBOX" "" "xy=519 374" 0x3034 3)
3
a.DoDefaultAction
3
a.CbSelect(1)
3
a.CbSelect(i)
3
;label3
w=wait(3 WV win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1"))
3
Acc a1.Find(w "COMBOBOX" "" "xy=519 432[]state=0x40100400 0[]level=0 1000" 0x3034 3)
3
a1.DoDefaultAction
err goto label3
3
a1.CbSelect(1)
err goto label3
3
a1.CbSelect(j)
err
a.CbSelect(i)
3
a1.CbSelect(0)
3
act w1
3
Acc a2.Find(win() "PUSHBUTTON" "Post Ad" "value=Post Ad" 0x3005 3)
3
a2.DoDefaultAction
3
w3=wait(0 WC win("* ads in Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1" "" 0x1))
3
Acc a3.Find(w3 "PUSHBUTTON" "Want to Post Another Ad? Click Here to Go Back" "value=Want to Post Another Ad? Click Here to Go Back" 0x3005 3)
3
a3.DoDefaultAction
3
w4=wait(0 WA win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1"))
w=0
w1=0
w2=0
w3=0
w4=0
3
break
3
a2.Find(win() "PUSHBUTTON" "Post Ad" "value=Post Ad" 0x3005 3)
3
a2.DoDefaultAction
3
;label2
w3=wait(0 WC win("* ads in Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1" "" 0x1))
3
a3.Find(w3 "PUSHBUTTON" "Want to Post Another Ad? Click Here to Go Back" "value=Want to Post Another Ad? Click Here to Go Back" 0x3005 3)
err goto label2
3
a3.DoDefaultAction
err goto label2
3
w4=wait(0 WA win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1"))
3
Everything works fine until I get to the end of the first list of cities for the state of Alabama. My approach was to simply let the macro generate an error (item not found) and the error handling instructions were to simply post that ad at the state level, no city selected, and then go back to the ad posting page, select the next state from the combobox (Alaska), and continue.
But every time the macro gets to this point, the next state on the list is indeed selected, but the macro puts the list of cities for ALABAMA in the cities combobox in addition to the cities for Alaska. The program then tries to post an ad for Birmingham, Alaska, which we all know doesn't exist. NO MATTER WHAT I DO, I CANNOT PREVENT THIS BEHAVIOR FROM HAPPENING.
Could somebody please tell me what I am doing wrong?
Here is the code I have so far-
int i
int j
int w
int w1
int w2
int w3
int w4
for i 1 200
w1=win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1")
act w1
for j 7 200
3
w2=wait(3 WV win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1"))
3
Acc a.Find(w2 "COMBOBOX" "" "xy=519 374" 0x3034 3)
3
a.DoDefaultAction
3
a.CbSelect(1)
3
a.CbSelect(i)
3
;label3
w=wait(3 WV win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1"))
3
Acc a1.Find(w "COMBOBOX" "" "xy=519 432[]state=0x40100400 0[]level=0 1000" 0x3034 3)
3
a1.DoDefaultAction
err goto label3
3
a1.CbSelect(1)
err goto label3
3
a1.CbSelect(j)
err
a.CbSelect(i)
3
a1.CbSelect(0)
3
act w1
3
Acc a2.Find(win() "PUSHBUTTON" "Post Ad" "value=Post Ad" 0x3005 3)
3
a2.DoDefaultAction
3
w3=wait(0 WC win("* ads in Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1" "" 0x1))
3
Acc a3.Find(w3 "PUSHBUTTON" "Want to Post Another Ad? Click Here to Go Back" "value=Want to Post Another Ad? Click Here to Go Back" 0x3005 3)
3
a3.DoDefaultAction
3
w4=wait(0 WA win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1"))
w=0
w1=0
w2=0
w3=0
w4=0
3
break
3
a2.Find(win() "PUSHBUTTON" "Post Ad" "value=Post Ad" 0x3005 3)
3
a2.DoDefaultAction
3
;label2
w3=wait(0 WC win("* ads in Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1" "" 0x1))
3
a3.Find(w3 "PUSHBUTTON" "Want to Post Another Ad? Click Here to Go Back" "value=Want to Post Another Ad? Click Here to Go Back" 0x3005 3)
err goto label2
3
a3.DoDefaultAction
err goto label2
3
w4=wait(0 WA win("Post Ad - Classifieds For Free - Google Chrome" "Chrome_WidgetWin_1"))
3