After my last post on how to get the Windows 7 RSS Feeder gadget to start on logon, I started to write my own RSS feed in Autoit. Im sorry to say that it was slightly more than I could do on my own so I had a bit of a Google on it. There were several good examples available and I found one that showed you the basic ways to do it using the XMLDomWapper.au3 file and the appbarhelper.au3 files.
Here's the code.
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <inet.au3>
#include <array.au3>
#include <_XMLDomWrapper.au3>
#include <appbarHelper.au3>
Local $update_freq = 18000
Local $rss_source = "http://RESTOFTHEURLTOTHEXMLFILE"
Global $rss_gui = _AppbarNew("RSS FEED", "NEWS")
GUISetBkColor(0xFFFFFF)
Local $rss_text = _GetFeedData($rss_source)
Global $rss_label = GUICtrlCreateLabel($rss_text, -1, -1, @DesktopWidth, 40)
GUICtrlSetFont(-1, 14, 400, 2, "Verdana")
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
GUISwitch($rss_gui)
_AppbarSetDockingEdges(False, False, True, True)
_AppbarDock($rss_gui, $ABE_TOP, 40, 10)
GUISetState(@SW_SHOW, $rss_gui)
While 1
Sleep(200)
If Not isMouseOverRSS() Then
Local $TempText = GUICtrlRead($rss_label)
GUICtrlSetData($rss_label, StringTrimLeft($TempText, 1) & StringLeft($TempText, 1))
EndIf
WEnd
Func _GetFeedData($rss_source)
Local $strXML = _INetGetSource($rss_source)
_XMLLoadXML($strXML, "")
Local $title_node = "//rss/channel/item/title";
Local $title_array = _XMLGetValue($title_node)
Local $descr_node = "//rss/channel/item/description";
Local $descr_array = _XMLGetValue($descr_node)
Local $link_node = "//rss/channel/item/link";
Local $link_array = _XMLGetValue($link_node)
Local $feed_data = ""
For $i = 1 To $title_array[0]
$feed_data = $feed_data & $title_array[$i] & ": " & $descr_array[$i] & " - "
If $i = $title_array[0] Then $feed_data = $feed_data & " --END-- "
Next
Return $feed_data
EndFunc
Func isMouseOverRSS()
Local $mouse_info = GUIGetCursorInfo($rss_gui)
If $mouse_info[4] = $rss_label Then Return True
Return False
EndFunc
Its pretty simple really and I really should have been able to do it on my own. Still have fun playing with it.
No comments:
Post a Comment