Witam! Bawie sie w delphi juz spory czas, ale nie moge tego rozgryzc. Sasiad poprosil mnie o napisanie bota do gry footballteam.pl - program powstal ale najwyrazniej jest tam zabezpieczenie tzn autokick co iles tam ruchow. Nie jestem jeszcze az tak obeznany wiec znalazlem gotowa fukcje ktora zmienia wartosc pola select(jest to numer servera na stronie gry).
function SetComboboxValue(WB: TWebBrowser; SelectName, ItemName: string): Boolean;
var
iForms, iFormItems, iSelectItems: Word;
FormItem: OleVariant;
begin
Result := false;
for iForms := 0 to WB.OleObject.Document.Forms.length - 1 do
begin
FormItem := WB.OleObject.Document.Forms.item(iForms);
for iFormItems := 0 to FormItem.length - 1 do
begin
if (FormItem.item(iFormItems). type = 'select-one') and SameText
(FormItem.item(iFormItems).Name, SelectName) then
begin
for iSelectItems := 0 to FormItem.item(iFormItems).Options.length - 1 do
begin
if SameText(FormItem.item(iFormItems).Options.item(iSelectItems)
.Text, ItemName) then
begin
FormItem.item(iFormItems).SelectedIndex := iSelectItems;
Result := true;
Break;
end;
end;
end;
end;
end;
end;
Funkcja dziala, ale niestety tylko wizualnie. Poczytalem ze trzeba wywolac odpowiedni skrypt w javie ktory jest podany w onchange="xxx", do tego tez znalazlem procedure
uses
MSHTML;
var
Doc: IHTMLDocument2;
HTMLWindow: IHTMLWindow2;
begin
Doc := WebBrowser1.Document as IHTMLDocument2;
if not Assigned(Doc) then
Exit;
HTMLWindow := Doc.parentWindow;
if not Assigned(HTMLWindow) then
Exit;
HTMLWindow.execScript('yourfunctioname()', 'JavaScript');
end;
Ale nie dziala... Przekopalem doklanie google, zwracam sie z prozba o pomoc do Was. Podam jeszcze kod html input'a
<select name="serwer" tabindex="3" onchange="document.logowanie.action=this.value" id="serwer"> <option selected="selected" value="http://s1.footballteam.pl/start.php">Serwer 1 </option> <option value="http://s4.footballteam.pl/start.php">Serwer 4 </option> <option value="http://s3.footballteam.pl/start.php">Serwer 3 </option> <option value="http://s2.footballteam.pl/start.php">Serwer 2 </option> </select> Problem polega na tym ze w onchange nie ma podanego skryptu w javie, prawde mowiac nie wiem co to jest... Licze na pomoc. Z gory dzieki i pozdro!