i've been asking some questions about the Lastminute program that i've still kept developping.
Now it's working quite fine and i'm ready to edit it on Script section.
However, just before doing it, i need to add in the GUI's departure dropdownlist all the cities allowed by this website http://www.travelage...m?idpart=944547
So, to grab all cities stored in it, I checked first the source code of website but no city were displayed on it.
But, I noticed that by typing the 3 first letters of any city in "departure" box, the website autocompletes them by displaying on a small list all cities matching with those 3 letters.
And that's cool ! because now, when small list is displayed, the source code is also changing and contains all the cities from the small list matching to the 3 letters. In source code it seems to be jQuery code, Ajax or something like that...but that's not the point.
So, inspired by a sinkfaze's code on this page :http://www.autohotke...=87247&p=542160 , i did this wily code below to grab all cities by typing automatically all triplets from AAA to ZZZ
(it took 2 complete days to run all letters (26x26x26 combinations from AAA to ZZZ), without touching computer because it sends letters directly on visible webpage so i couldn't touch other windows !
And it worked
that is, all the cities in the world having an airport i guess...
Pwb := ComObjCreate("InternetExplorer.Application")
Pwb.Navigate("http://www.travelagency.travel/vol/open-jaw.cfm?idpart=944547")
Pwb.Visible:=True
while pwb.readystate < 4 ; waits page is loaded
sleep, 500
while !inStr(pwb.document.documentElement.innertext, "Aller/retour")
Sleep, 200
Pwb.document.aspnetForm["ctl00$m_cphMain$m_ctrlFlightSearchMini_openjaw$rbtTrip"][0].fireEvent("onclick") ; clicks on Round-trip radio
pwb.document.aspnetForm["ctl00$m_cphMain$m_ctrlFlightSearchMini$m_txtDepart"].focus()
; clicks on departure box
Pwb.document.aspnetForm["ctl00$m_cphMain$m_ctrlFlightSearchMini$m_txtDepart"].click()
; runs all letters from aaa to zzz ("a" ascii code is 97)
Loop, 26 {
i:=A_index + 96
Sendinput, % Chr(i)
Loop, 26 {
j:=A_index + 96
Sendinput, % Chr(j)
Loop, 26 {
k:=A_index + 96
Sendinput, % Chr(k)
Sleep, 4000 ; waits some seconds for the small suggestion list to be displayed
; and the source main page code to be changed
; in the source code, i noticed cities displayed in the small list were between "<A ...." tag
loop % (cities_html:=Pwb.document.getElementsbytagname("A")).length
{
; and classname of those cities were either "ac_odd ui-corner-all" or "ac_even ui-corner-all"
if (cities_html[i].classname = "ac_odd ui-corner-all") OR (cities_html[i].classname = "ac_even ui-corner-all") {
cities := cities_html[i].innertext
FileAppend, %cities%|`n, All_cities_from_Lastmiute.txt
}
}
Sendinput, {BACKSPACE}
}
Sendinput, {BACKSPACE}
}
Sendinput, {BACKSPACE} ; erases typed letters to put next ones
}
Msgbox All cities grabbed from Lastminute ! Finished !the "|" in Fileappend, %cities%| is to be ready to include directly the resust text file in a dropdownlist in separated all_cities.ahk file :
gui, add, dropdownlist, r20 w400 vCity, ( city 1 | city 2 | city 3 | etc... )
Then i include this list in the main code :
#Include all_cities.ahk Gui, add, button, gDisplay, Show selected city Gui, show return Display: msgbox %city% return
The script works up to about 360 cities lines, but beyond, the script returns an error :
"Continuation section too long".
But i would like to include all the 9200 cities in the dropdownlist.
I tried to divide the list with several consecutive "( .... )" pairs.
( ... )but it still doesn't work.
Could anyone help me to deal with this VERY long dropdownlist ? It could be very great and will
end my program. To make test, i joined the text file with all cities.
I have also a intermediate question, just for challenge cause i need it no more...
in the above code to grab cities, is there a quicker way to grab all cities, without viewing and clicking physically on the website? to make it work in background mode? (i mean by using pwb:=False), thanks




