Sign in to follow this  
Followers 0
datkewlguy

buggy script

5 posts in this topic

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.

Opt ("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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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:

Opt ("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 by Domonoky

Share this post


Link to post
Share on other sites

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

Opt ("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.

Share this post


Link to post
Share on other sites

Nobody knows how to make an exit button using GUI?

Share this post


Link to post
Share on other sites

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.

Opt ("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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0