datkewlguy Posted January 31, 2005 Share Posted January 31, 2005 OK, i know there are a lot of things you can fix with this, but basically i need an exit button and for it to be more condense. Also, it's checking so often that the cpu usage is high and it can get in the way. Help would be greatly appreciated. expandcollapse popupOpt ("TrayIconHide", 1) #include <GUIConstants.au3> InetGet ( "http://www.olentangy.k12.oh.us/cancel.html?aolfix", "schoolstatus.txt", 1) GUICreate("hi", 180, 130, 450, 200) GUISetBkColor(0xFFFFFF) GUISetState(@Sw_SHOW) If FoundInFile("schoolstatus.txt", "hour delay") Then DllCall("kernel32.dll", "int", "Beep", "long", 600, "long", 350) EndIf If FoundInFile("schoolstatus.txt", "closed") Then DllCall("kernel32.dll", "int", "Beep", "long", 600, "long", 350) EndIf Func FoundInFile($File, $String) Local $Found Local $Content Local $FileSize If NOT FileExists($File) Then Return 0 $FileSize = FileGetSize($File) $Content = FileRead($File, $FileSize) $Found = StringInStr($Content, $String) $Content = "" If $Found Then Return 1 Return 0 EndFunc While 1 InetGet ( "http://www.olentangy.k12.oh.us/cancel.html?aolfix", "schoolstatus.txt", 1) If FoundInFile("schoolstatus.txt", "hour delay") Then $label = GUICtrlCreateLabel("Schools are delayed", 55, 55, 70, 25) EndIf If FoundInFile("schoolstatus.txt", "closed") Then $label = GUICtrlCreateLabel("Schools are closed", 55, 55, 70, 25) Sleep(100) endif WEnd Link to comment Share on other sites More sharing options...
Domonoky Posted January 31, 2005 Share Posted January 31, 2005 (edited) Hi.. i cant help you with the exit button, cause i dont know much about the GUI system.. but the problem about the cpu usage is easy... simply sleep a bit in the loop.. ( your sleep isnt in the right position) It has to look like: expandcollapse popupOpt ("TrayIconHide", 1) #include <GUIConstants.au3> InetGet ( "http://www.olentangy.k12.oh.us/cancel.html?aolfix", "schoolstatus.txt", 1) GUICreate("hi", 180, 130, 450, 200) GUISetBkColor(0xFFFFFF) GUISetState(@Sw_SHOW) If FoundInFile("schoolstatus.txt", "hour delay") Then DllCall("kernel32.dll", "int", "Beep", "long", 600, "long", 350) EndIf If FoundInFile("schoolstatus.txt", "closed") Then DllCall("kernel32.dll", "int", "Beep", "long", 600, "long", 350) EndIf Func FoundInFile($File, $String) Local $Found Local $Content Local $FileSize If NOT FileExists($File) Then Return 0 $FileSize = FileGetSize($File) $Content = FileRead($File, $FileSize) $Found = StringInStr($Content, $String) $Content = "" If $Found Then Return 1 Return 0 EndFunc While 1 InetGet ( "http://www.olentangy.k12.oh.us/cancel.html?aolfix", "schoolstatus.txt", 1) If FoundInFile("schoolstatus.txt", "hour delay") Then $label = GUICtrlCreateLabel("Schools are delayed", 55, 55, 70, 25) EndIf If FoundInFile("schoolstatus.txt", "closed") Then $label = GUICtrlCreateLabel("Schools are closed", 55, 55, 70, 25) endif sleep(100) ;moved the sleep outside of the If WEnd hope this helps.. mfg Domonoky Edited January 31, 2005 by Domonoky Link to comment Share on other sites More sharing options...
datkewlguy Posted January 31, 2005 Author Share Posted January 31, 2005 Thanks, i didn't notice that because our school IS delayed today so it read it normally anyway, but after correction it looks like this expandcollapse popupOpt ("TrayIconHide", 1) HotKeySet("{F11}", "myexit") #include <GUIConstants.au3> InetGet ( "http://www.olentangy.k12.oh.us/cancel.html?aolfix", "schoolstatus.txt", 1) GUICreate("School Status", 180, 130, 450, 200) GUISetBkColor(0xFFFFFF) GUISetState(@Sw_SHOW) If FoundInFile("schoolstatus.txt", "hour delay") Then DllCall("kernel32.dll", "int", "Beep", "long", 600, "long", 350) EndIf If FoundInFile("schoolstatus.txt", "closed") Then DllCall("kernel32.dll", "int", "Beep", "long", 600, "long", 350) EndIf Func FoundInFile($File, $String) Local $Found Local $Content Local $FileSize If NOT FileExists($File) Then Return 0 $FileSize = FileGetSize($File) $Content = FileRead($File, $FileSize) $Found = StringInStr($Content, $String) $Content = "" If $Found Then Return 1 Return 0 EndFunc While 1 InetGet ( "http://www.olentangy.k12.oh.us/cancel.html?aolfix", "schoolstatus.txt", 1) If FoundInFile("schoolstatus.txt", "hour delay") Then $label = GUICtrlCreateLabel("Schools are delayed", 55, 55, 70, 25) EndIf If FoundInFile("schoolstatus.txt", "closed") Then $label = GUICtrlCreateLabel("Schools are closed", 55, 55, 70, 25) endif sleep(500) WEnd Func myexit() exit endfunc I still need to make an exit button though/making the X actually close it, i always am not that good with GUI's. Link to comment Share on other sites More sharing options...
datkewlguy Posted January 31, 2005 Author Share Posted January 31, 2005 Nobody knows how to make an exit button using GUI? Link to comment Share on other sites More sharing options...
CyberSlug Posted January 31, 2005 Share Posted January 31, 2005 Read the manual: 1) Use either GuiGetMsg inside the While loop or use Opt("OnEventMode",1) stuff.... 2) Calling GuiCtrlCreateLabel inside the loop is a bad idea; create the label once at the beginning, and then set its data. expandcollapse popupOpt ("TrayIconHide", 1) HotKeySet("{F11}", "myexit") #include <GUIConstants.au3> InetGet ( "http://www.olentangy.k12.oh.us/cancel.html?aolfix", "schoolstatus.txt", 1) GUICreate("School Status", 180, 130, 450, 200) GUISetBkColor(0xFFFFFF) $label = GUICtrlCreateLabel("", 55, 55, 70, 25) $button = GuiCtrlCreateButton("Exit", 90, 90, 80, 30) GUISetState(@Sw_SHOW) If FoundInFile("schoolstatus.txt", "hour delay") Then DllCall("kernel32.dll", "int", "Beep", "long", 600, "long", 350) EndIf If FoundInFile("schoolstatus.txt", "closed") Then DllCall("kernel32.dll", "int", "Beep", "long", 600, "long", 350) EndIf While 1 $msg = GuiGetMsg() If $msg = $GUI_EVENT_CLOSE or $msg = $button Then myexit() InetGet ( "http://www.olentangy.k12.oh.us/cancel.html?aolfix", "schoolstatus.txt", 1) If FoundInFile("schoolstatus.txt", "hour delay") Then $label = GUICtrlCreateLabel("Schools are delayed", 55, 55, 70, 25) EndIf If FoundInFile("schoolstatus.txt", "closed") Then GuiCtrlSetData($label, "Schools are closed") endif WEnd Exit Func FoundInFile($File, $String) Local $Found Local $Content Local $FileSize If NOT FileExists($File) Then Return 0 $FileSize = FileGetSize($File) $Content = FileRead($File, $FileSize) $Found = StringInStr($Content, $String) $Content = "" If $Found Then Return 1 Return 0 EndFunc Func myexit() Exit endfunc Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! 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