gseller Posted November 3, 2007 Share Posted November 3, 2007 I am trying to make a word clock like the international clock SmOke_N & Valuater made using _InetGetSource and StringRegExp but can;t make it work. Here is thge latest code I am trying: #include <INet.au3> $case = '(?i)' $read = ConsoleWrite(_INetGetSource('http://www.google.com/search?hl=en&q=time+tulsa')) $time = StringRegExp ( $read, $case & '<alt="Clock"></td><td valign="middle"></td>', 4) MsgBox(0,"International Clock","The Current Time In " & $time )oÝ÷ ØÛh©jx§µêÚrدz)éºÜ"¶®]£ ðêÞÊjznWhÂv¢fèjw,yªky×wr§¶¼¨ÈÊíÊ¢*.®'r+rýÊ.Úòjwbë`zÛ(º»{¥Ç§uúèØ^znµ©Ýi×m¢Ø^º¹méàzÛaz)ߢ¹¶*'jwky§bµúèØ^ çb½©Ý+ÞæÚrKazئz)ÞØ^©¬º1¢¶¥Ëoìz·¢²Ø^ çb¼¦¶¼¢hæjëh×6<div id="res"> <p class="e"></p> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td width="47" valign="top"> <img border="0" width="40" height="30" valign="middle" src="[url="http://www.google.com/chart?chs=40x30&chc=localtime&cht=cf&chd=s:Sd&sig=z2XuwGilwETpVX4bI8TVovXa8eU"]http://www.google.com/chart?chs=40x30&chc=localtime&cht=cf&chd=s:Sd&sig=z2XuwGilwETpVX4bI8TVovXa8eU[/url]" alt="Clock"></td> <td valign="middle"><b>6:29 PM</b> Sunday (CDT) - <b>Time</b> in <b> Tulsa</b>, Oklahoma</td> </tr> </table> <div> Can someone help me get this going? I have had code with inputs and all, just trying to make it read the time and date info from google right now. Thank You in advance... Link to comment Share on other sites More sharing options...
Nahuel Posted November 3, 2007 Share Posted November 3, 2007 hehe, my script does exactly that. Just extract the part you need:http://www.autoitscript.com/forum/index.ph...&pid=424037 Link to comment Share on other sites More sharing options...
gseller Posted November 3, 2007 Author Share Posted November 3, 2007 I know and it is brilliant but I can't seem to make it work for my project, I have been working on this for a couple weeks now and seen your time updater and was excited to try it and it looks like it is just what I need in that one function. I just can't make it work so I decided to ask for help. It was your script that helped me where I got so far, I scrapped it just before putting the code on here. Link to comment Share on other sites More sharing options...
Nahuel Posted November 4, 2007 Share Posted November 4, 2007 I'm a sucker for StringRegExp() Smoke is the expert. I can see one big mistake in your code though.. ConsoleWrite() does not return whatever you are writing. It doesn't return anything. Link to comment Share on other sites More sharing options...
gseller Posted November 4, 2007 Author Share Posted November 4, 2007 (edited) Yes, it is pretty cool stuff from what I have seen. I want to know more about it, Here is some other code I am trying but I only get the return from using you function from the time update. It is cool bu I am not sure if I am not getting my StringRegExp pattern right or not reading something right. Any ideas? expandcollapse popup#include <GUIConstants.au3> #include <inet.au3> GuiCreate("Google Anywhere Clock", 350, 200, -1, -1) $font = "Arial Bold" $SearchCity = GuiCtrlCreateButton("Search", 265, 11, 80, 20, $BS_DEFPUSHBUTTON) $Input = GuiCtrlCreateInput("tulsa", 100, 11, 160, 20) $Input1 = GUICtrlCreateEdit("", 12, 65, 330, 125,BitOR($ES_MULTILINE,$ES_AUTOVSCROLL,$WS_VSCROLL)) $SearchLabel = GuiCtrlCreateLabel("Time Search", 12, 13, 88, 30) GUICtrlSetFont(-1, 9, 400, 0, $font) GUICtrlSetColor($SearchLabel, 0xff0000) GuiCtrlCreateGroup("", 2, 0, 346, 40) GuiSetState() $Group1 = GUICtrlCreateGroup("Search Results", 2, 45, 346, 175) GUICtrlCreateGroup("", 05, 20, 1, 1) $r = GUICtrlRead($Input1) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $SearchCity _GoogleTime() EndSelect WEnd Func _GoogleTime() Local $aSRE = StringRegExp( _ _INetGetSource("http://www.google.com/search?hl=en&q=time+" & $Input), _ '<\id="res"\>\<\alt="Clock"\>\</td\>\<td valign="middle"\>(.*?)\<', 3) GUICtrlSetData($Input1, $aSRE) ;MsgBox(0, "Your Intl Clock Reult", $aSRE) If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0) Local $aINF = StringRegExp($aSRE[0], "(?i)(\w+), (\w+) (\d+), (\d+).*? (\d+):(\d+):(\d+) (\w+)",3) If IsArray($aINF) = 0 Then Return SetError(2, 0, 0) If UBound($aINF) <> 8 Then Return SetError(3, 0, 0) Return $aINF EndFunc;==>_GoogleTime() edit: typo... Edited November 4, 2007 by gesller Link to comment Share on other sites More sharing options...
Nahuel Posted November 4, 2007 Share Posted November 4, 2007 (edited) yay I did it #include <Inet.au3> MsgBox(0,"",_GoogleTime("buenos aires")) Func _GoogleTime($sCity) $sSource=_INetGetSource("http://www.google.com/search?hl=en&q=time+" & $sCity) $aSRE=StringRegExp($sSource,'<(?i)td valign=middle><(?i)b>(.*?)<(?i)/b>',1) If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0) Return $aSRE[0] EndFunc;==>_GoogleTime() I should totally learn how to use StringRegExp properly :"> Oh, and don't give me credit for that function, Smoke did the whole thing. expandcollapse popup#include <GUIConstants.au3> #include <inet.au3> GuiCreate("Google Anywhere Clock", 350, 200, -1, -1) $font = "Arial Bold" $SearchCity = GuiCtrlCreateButton("Search", 265, 11, 80, 20, $BS_DEFPUSHBUTTON) $Input = GuiCtrlCreateInput("tulsa", 100, 11, 160, 20) $Input1 = GUICtrlCreateEdit("", 12, 65, 330, 125,BitOR($ES_MULTILINE,$ES_AUTOVSCROLL,$WS_VSCROLL)) $SearchLabel = GuiCtrlCreateLabel("Time Search", 12, 13, 88, 30) GUICtrlSetFont(-1, 9, 400, 0, $font) GUICtrlSetColor($SearchLabel, 0xff0000) GuiCtrlCreateGroup("", 2, 0, 346, 40) GuiSetState() $Group1 = GUICtrlCreateGroup("Search Results", 2, 45, 346, 175) GUICtrlCreateGroup("", 05, 20, 1, 1) $r = GUICtrlRead($Input1) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $SearchCity $city=GUICtrlRead($Input) GUICtrlSetData($Input1,_GoogleTime($city)) EndSelect WEnd Func _GoogleTime($sCity) $sSource=_INetGetSource("http://www.google.com/search?hl=en&q=time+" & $sCity) $aSRE=StringRegExp($sSource,'<(?i)td valign=middle><(?i)b>(.*?)<(?i)/b>',1) If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0) Return $aSRE[0] EndFunc;==>_GoogleTime() Edited November 4, 2007 by Nahuel Link to comment Share on other sites More sharing options...
gseller Posted November 4, 2007 Author Share Posted November 4, 2007 (edited) Sweet!! That Rocks!! You are my hero for the day.. LOL Thanks! edit: Well, I thank you both! I have been pulling my hair out trying to make this work. Edited November 4, 2007 by gesller Link to comment Share on other sites More sharing options...
ptrex Posted November 4, 2007 Share Posted November 4, 2007 @All Nice In my signature there is an other example of a word clock. regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
gseller Posted November 4, 2007 Author Share Posted November 4, 2007 Your worldclock is way cool also, embeding the website is cool, have you tried google worldtime? I like it because there are less limitations on what cities/countries you can search. The only drawbacks now are when a contry or city has multiple timezones it breaks the reg expression. I am sure it can be corrected, maybe in time.. Thanks... 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