zackrspv Posted March 6, 2008 Posted March 6, 2008 (edited) Ok, so I have changed my code some to work better, at least in my opinion.NOTE: This script is by far not even close to being done, but i want to share it so i could get opinions, options, and better ways of doing things.Features -- Search in the window -- Delay between results (allow the source to be grabbed), visual progress bar -- If word is spelled wrong, provide a list for it -- Spelling correctly list works directly by clicking on the right word and it auto looks it up. -- Removes most markup, ie <blah></blah>&blah;&#blah;Todo -- Make it pull the links as well as the defines; haven't figured that one out yet. -- Clean up the display to make it easier to read -- Make the window look much better -- Maybe add an images search, i dunno -- Make code betterIssues -- Doesn't pull ALL of the defines from the google site; it seems to skip every other one if they are from the same source, not sure why that is. -- Doesn't tell you that when the word has no suggestions and no define is found, that no define is known. -- May not work if you have a word that is mispelled (according to google) but actually still pulls up a word (havn't tested that).Please let me know how i can make this work better expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=google.exe #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <INet.au3> #include <GUIConstants.au3> GUICreate("Google Search", 600, 500) $item2 = "" $term = GUICtrlCreateInput("Search Term", 5, 5, 190, 25) $but = Guictrlcreatebutton("Search", 199, 5, 62) $choices2 = GUICtrlCreateLabel("Not Found. Did you Mean: ", 265, 10, 169, 25) $choices = Guictrlcreatecombo("", 396, 7, 190, 25) GUICtrlSetState($choices, $GUI_HIDE) GUICtrlSetState($choices2, $GUI_HIDE) $str = "" $resultsd = GUICtrlCreateEdit($str, 0, 32,600,470,BitOR($WS_VSCROLL,$ES_READONLY)) guisetfont(12, 400) $progress = GUICtrlCreateProgress(265, 5, 300, 25) GUICtrlSetState($progress, $GUI_HIDE) Func goSearch() GUICtrlSetState($choices, $GUI_HIDE) GUICtrlSetState($choices2, $GUI_HIDE) GUICtrlSetState($resultsd, $GUI_HIDE) GUICtrlSetState($progress, $GUI_SHOW) $item = StringReplace($item2," ","+") $source = (_INetGetSource("http://www.google.com/search?hl=en&q=define%3A+" & $item & "&btnG=Google+Search")) for $i = 0 to 100 guictrlsetdata($progress, $i) sleep(5) guictrlsetdata($progress, 0) Next GUICtrlSetState($progress, $GUI_HIDE) if StringInStr($source, "Did you Mean", 0) = "0" Then Else GUICtrlSetState($choices, $GUI_SHOW) GUICtrlSetState($choices2, $GUI_SHOW) $nOffset = 1 $str = "" while 1 $array = StringRegExp($source, 'class=p>define: <b><i>(.*?)</i>', 1, $nOffset) if @error = 0 Then $nOffset = @extended Else ExitLoop EndIf for $i = 0 to UBound($array) - 1 guictrlsetdata($choices, "|"& $array[$i]) Next WEnd GUICtrlSetState($resultsd, $GUI_SHOW) GUICtrlSetData($resultsd, $str) EndIf $nOffset = 1 $str = "" while 1 $array = StringRegExp($source, '<(?i)li>(.*?)<', 1, $nOffset) if @error = 0 Then $nOffset = @extended Else ExitLoop EndIf for $i = 0 to UBound($array) - 1 $str = $str & "-" & $array[$i] & @CRLF & @CRLF $str = StringRegExpReplace($str, "&#(.*?);", " " ) $str = StringRegExpReplace($str, "<(.*?)>", " " ) $str = StringRegExpReplace($str, "</(.*?)>", " " ) $str = StringRegExpReplace($str, "&(.*?);", " " ) Next WEnd GUICtrlSetState($resultsd, $GUI_SHOW) GUICtrlSetData($resultsd, $str) EndFunc GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $but $item2 = GUICtrlRead($term) call("goSearch") Case $choices $item2 = GUICtrlRead($choices) guictrlsetdata($term, $item2) call("goSearch") EndSwitch WEnd Edited March 6, 2008 by zackrspv -_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë ë§§ëñ§ë øƒ !ïƒë.
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