JohnOne Posted December 27, 2009 Share Posted December 27, 2009 (edited) My script gets some headlines from a website If the headline does not exist in the temp .txt file, pops up a gui, writes to temp file. If the headline exists, then continues checking every 30 minutes, until it has changed. My problem is that while the code works fine, the compiled code, pops up the gui wheter it already exists or not. If the temp.txt has no headline, it will write the new one, but continue popping up the gui. I've tried running as admin, but still no joy and I'm a little stumped The code is below and I'm win7 x86 Any pointers appreciated. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Inet.au3> #include <String.au3> #include <Array.au3> #include <File.au3> ;============================================================================== ;Main Loop ;============================================================================== While 1 ;Create temp file Local $sTempFile = @DocumentsCommonDir & "\temp.txt" If Not FileExists($sTempFile) Then _FileCreate($sTempFile) EndIf $sResTemp = _ReadTempFile($sTempFile) ;get Global vars Global $aResult = _GetNews() Global $sAddUrl = "http://www.evertonfc.com" & $aResult[1] Global $HeadLen = StringLen($aResult[2]) * 10 If $aResult[2] <> $sResTemp Then _Gui($aResult[2], $HeadLen, $sAddUrl) _WriteTempFile($sTempFile, $aResult[2]) EndIf Sleep(1800000) WEnd ;================================================================================ ;================================================================================ ;Function - Grab the Date, Link and headline fron news archive ;================================================================================ Func _GetNews() Local $SourceUrl = "http://www.evertonfc.com/news/news-archive.html" Local $sSourceText = _INetGetSource($SourceUrl) Local $pattern = '(\d{1,2}/\d{1,2}/\d{4})</span>\s*<a href="([^"]*)">([^<]*)' Local $aNewsString = _StringBetween($sSourceText, '<span class="date">', '</a>', -1) Local $aDateLinkHeadline = StringRegExp($aNewsString[0], $pattern, 3) Return $aDateLinkHeadline EndFunc ;==>_GetNews ;================================================================================ ;================================================================================ ;Function - Create a popup GUI ;================================================================================ Func _GUI($aResult, $HeadLen, $sAddUrl) $GUI = GUICreate($aResult, $HeadLen, 30, @DesktopWidth - ($HeadLen + 20), @DesktopHeight - (30 * 2), $WS_OVERLAPPEDWINDOW, $WS_EX_TOPMOST) GUISetBkColor(0xBBBBFF, $GUI) $sHeadLine = GUICtrlCreateLabel($aResult, -1, -1) GUICtrlSetColor($GUI, 0x0000FF) GUICtrlSetFont($GUI, 8, 800, 4) GUICtrlSetTip($GUI, $aResult & @CRLF & $sAddUrl) Beep(550, 300) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() ExitLoop Case $sHeadLine ShellExecute($sAddUrl) GUIDelete() ExitLoop EndSwitch WEnd EndFunc ;==>_GUI ;================================================================================ ;================================================================================ ;Function - Read the temp headline ;================================================================================ Func _ReadTempFile($sTempFile) Local $TempHeadline FileOpen($sTempFile, 0) $TempHeadline = FileRead($sTempFile) FileClose($sTempFile) Return $TempHeadline EndFunc ;==>_ReadTempFile ;================================================================================ ;================================================================================ ;Function - Write new temp headline ;================================================================================ Func _WriteTempFile($sTempFile, $sNewHeadline) FileOpen($sTempFile, 2) FileWrite($sTempFile, $sNewHeadline) FileClose($sTempFile) Return EndFunc ;==>_WriteTempFile ;================================================================================ Edited December 28, 2009 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 27, 2009 Share Posted December 27, 2009 Just fix you _Gui() function so it checks if the GUI exists already before it does GuiCreate(). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JohnOne Posted December 28, 2009 Author Share Posted December 28, 2009 (edited) Not to sure what you mean mate, or what to use, but I will try. Probably missing something quite obviouse again. But the gui gets deleted within its function, every time it gets created in both cases, or the loop dosent continue anyway EDIT: yup, I was missing something, having commented the if/endif while testing Edited December 28, 2009 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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