_Kurt Posted November 18, 2006 Share Posted November 18, 2006 Hey guys, I've tried to study some scripts but I'm not quite getting there. How can you make it so you can "click" a button on a site and return something? Let's use an example translator script found in Scripts and Scraps. expandcollapse popup#include <GuiConstants.au3> #Include <Misc.au3> ;#NoTrayIcon Opt("GUIOnEventMode", 1) TranslateInit() While 1 Sleep(100) WEnd Func TranslateInit() Global $oHTTP HotKeySet("{F2}", "TranslateStart") $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") EndFunc Func TranslateStart() ToolTip("Translating", 0, 0) Send("^c") $Text = ClipGet() $Translation = _Translate($Text, "en", "fr") $Translation = Web2Text($Translation) ClipPut($Translation) guiTranslationText($Text, $Translation) EndFunc Func Web2Text($Text) $Text = StringReplace($Text, "." & @CRLF, "." & @CR) $Text = StringReplace($Text, @CR & @CRLF, @CR & @CR) $Text = StringReplace($Text, @CRLF, " ") $Text = StringReplace($Text, @CR, @CRLF) Return $Text EndFunc Func guiTranslationText($Original, $Translated) GuiCreate("Translation Service", 805, 425,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GUISetOnEvent($GUI_EVENT_CLOSE, "TranslationTextClose") GuiCtrlCreateEdit($Original, 10, 10, 780, 190, $ES_MULTILINE) GuiCtrlCreateEdit($Translated, 10, 210, 780, 200, $ES_MULTILINE) GuiSetState() EndFunc Func TranslationTextClose() GUIDelete(@GUI_WinHandle) EndFunc Func String2WWW($Text) $Text = StringReplace($Text, "&", "&") $Text = StringReplace($Text, " ", "+") $Text = StringReplace($Text, "à", "à") $Text = StringReplace($Text, "é", "é") $Text = StringReplace($Text, "ï", "ï") $Text = StringReplace($Text, "ô", "ô") $Text = StringReplace($Text, "ç", "ç") $Text = StringReplace($Text, "À", "À") $Text = StringReplace($Text, "É", "É") $Text = StringReplace($Text, "©", "©") $Text = StringReplace($Text, "<", "<") $Text = StringReplace($Text, ">", ">") ;$Text = StringReplace($Text, @CRLF, "%0D%0A") ;$Text = StringReplace($Text, '"', "%22") $string = "" For $i=1 To StringLen($text) $char = StringMid($Text, $i, 1) If $char <> "+" And $char <> "&" And $char <> ";" And StringIsAlNum($char)<>1 Then $char = "%" & Hex(Asc($char),2) $string = $string & $char Next Return $string EndFunc Func _Translate($Text, $From, $To) $Text = String2WWW($Text) $oHTTP.Open("GET","http://babelfish.altavista.digital.com/tr?doit=done&intl=1&tt=urltext&trtext=" & $Text & "&lp=" & $From & "_" & $To & "&btnTrTxt=Translate") $oHTTP.Send() $HTMLSource = $oHTTP.Responsetext ToolTip("Done", 0, 0) Sleep(10) ToolTip("") $Text = _StringBetween($HTMLSource, "<div style=padding:10px;>", "</div>") $Text = StringReplace($Text, @LF, @CRLF) Return $Text EndFunc Func _StringBetween($s, $from, $to) $x = StringInStr($s, $from) + StringLen($from) $y = StringInStr(StringTrimLeft($s, $x), $to) Return StringMid($s, $x, $y) EndFunc 1) Which lines are the ones that "change the input box on the site and click the button" 2) I've also looked over the sites source code, I'm not finding which lines are used for this script, any reason why? Thanks, Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
theguy0000 Posted November 18, 2006 Share Posted November 18, 2006 Well IE Automation can click a button for you, but I'm not sure what you mean by "return something"...return what exactly? The source of the page after clicking the button? The web location? The browser state? "Return Something: could mean dozens of things, you'll have to be more specific. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
GaryFrost Posted November 18, 2006 Share Posted November 18, 2006 http://www.autoitscript.com/forum/index.ph...st&p=265894 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
_Kurt Posted November 18, 2006 Author Share Posted November 18, 2006 Like what the example script does, it (ClipGets) the highlighted text and puts the text in the input and clicks "Translate" on http://babelfish.altavista.digital.com/tr?...ext&trtext=It returns the translated text. Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
_Kurt Posted November 18, 2006 Author Share Posted November 18, 2006 (edited) I still do not understand how to type in something in an input box (on a site) or click a button for the user. I'm not a fast learner as you can see, and I have no experience in HTML. If you are nice enough to help me, I will appreciate it very much. Here's the part of the source code: </td> <td width="33%" valign="top" align="center"> <form method="GET" action="http://www.a2zwordfinder.com/cgi-bin/wordfinder.cgi" name="Anagram"> <a href="anagram.html" target="_top"><font Face="Arial"><strong>Anagram WordFinder</strong></font><br> <img src="images/anagram.jpg" alt="" width="83" height="82" border="0"></a><br> <font Face="Arial"><strong><u>Example</u></strong><br>Build Words From 'EEHST'</font><br> <input type=hidden name="SearchType" value="Anagram"> <input type=hidden name="MinLetters" value="2"> <input type=hidden name="SortBy" value="Length"> Letters: <input type=text name="Letters" value="eehst" size="5"><br> <input type="submit" value="Find Words" name="Search"><br> (<a href="http://www.gamesville.lycos.com/games/wordWrangler?FOD=1" target="_blank">Word Wrangler Pays Prizes...</a>) </form> </td> The button displayed on the site is "Find Words" and the input default is "eehst". So the program basically is an input in a GUI and if the user types something in and presses the button, the prog takes the words from the input box and puts it in automatically in the site and clicks the button. Sorry if i took lots of your time explaning. If someone could write a small example I'd love that, but if that's too much to ask, just post in some functions to use/how to use them. Thanks again, Kurt Edited November 18, 2006 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
AzKay Posted November 18, 2006 Share Posted November 18, 2006 (edited) Where are my credits? Edited November 18, 2006 by AzKay # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
AzKay Posted November 18, 2006 Share Posted November 18, 2006 (edited) Like what the example script does, it (ClipGets) the highlighted text and puts the text in the input and clicks "Translate" on http://babelfish.altavista.digital.com/tr?...ext&trtext=It returns the translated text.Shouldnt have to "click" anything. The .Open does it all. Edited November 18, 2006 by AzKay # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now