Sign in to follow this  
Followers 0
rich2323

small script big memory

5 posts in this topic

#1 ·  Posted (edited)

Hi,

I made a simple little script that goes and checks a webpage and then reports the info back to a tray tool tip. After compiling and running this script it takes close to 6 megs when running, which seems very excessive to me for the little bit its doing. I have cleaned up the script to the best of my knowledge and was wonder if you any had any suggestions to minimize the memory usage in my script. I would appreciate any suggestions.

Thanks,

Rich

#include 

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",3)
HotKeySet("{ESC}", "quit")

$oldresult = 0
$newresult = 0

Dim $howmanywho

$statuspage = TrayCreateItem("Status Page")
TrayItemSetOnEvent(-1, "statuspage")

TrayCreateItem("")

$refreshitem = TrayCreateItem("Refresh Now")
TrayItemSetOnEvent(-1, "check")

TrayCreateItem("")

$exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"quit")

TraySetToolTip ("Loading please wait.....")

TraySetState()

While 1
   check ()
Sleeptime ()
WEnd

Func check()
  Local $_InetRead = InetRead("somewebsite.com/")
  If Not @error Then
   Local $_BinaryToString = BinaryToString($_InetRead)
  EndIf
; how many is on:
$_stinginstr = StringInStr ($_BinaryToString, "There are")
$_stinginstrback = StringInStr ($_BinaryToString, "on currently")
   $totalStringinstr = $_stinginstrback - $_stinginstr
   $howmany = StringMid ($_BinaryToString,$_stinginstr,$totalStringinstr)
$asResult = StringRegExp($howmany, '([0-9]{1,3})(?: users)', 1)
ConsoleWrite (@CRLF & $asResult[0] & @CRLF)

If $asResult[0] = 0 then
; do nothing if none one is in lobby
Else
  ConsoleWrite (@CRLF & "old results: "& $oldresult & @CRLF)
  If $oldresult = 0 Then
  ; do nothing
   Else
   $newresult = $asResult[0] - $oldresult
   ;ConsoleWrite (@CRLF & "new results: "& $newresult & @CRLF)
    If $newresult > 0 Then
     SoundPlay(@WindowsDir & "mediatada.wav",1)
    Else
    EndIf
  Endif
EndIf

local $oldresult = $asResult[0]

If $newresult = "-1" then SoundPlay(@WindowsDir & "mediaWindows Error.wav",1)
  local $_InetRead1 = InetRead(somewhebsite.")
  local $howmanywho = BinaryToString($_InetRead1)

TraySetToolTip ("There are "& $asResult[0] & " people in Sanctum:" & @CRLF & $howmanywho)
  If $newresult > 0 Then TrayTip("Current Sanctum Players: ", $howmanywho, 3)
EndFunc

func Sleeptime ()
sleep (60000*5) ;5 minutes
EndFunc

func statuspage()
ShellExecute(http://somewebsite")
EndFunc

func quit ()
Exit
EndFunc
Edited by rich2323

Share this post


Link to post
Share on other sites



rich2323,

This script appears to access a game website. Please explain how this does not infringe the Forum Rules. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Sorry, I was not aware of this rule, I am just trying to under autoit better. I will delete my post. How can I learn autoit if I can use it for practical purposes? I think your being a little harsh.

Thanks anyways.

Rich

Edited by rich2323

Share this post


Link to post
Share on other sites

I changed the code to a generic website name....is that more appropriate?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

rich2323,

How can I learn autoit if I can use it for practical purposes?

Look at all the other threads which are not locked - plenty of ways to use AutoIt other than games. :)

And yes we are draconian about game threads - just look at the archived game forum to see why. ;)

M23

Edit: Just seen your last post - I am afraid not. :D

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0