Jump to content

Script GUI Very Laggy/Unresponsive


Recommended Posts

My Script doesn't respond to my clicks very well at all. I click and then a second later it responds, I rarely even see the button depress. The script isn't very complex. I download a few web pages and check for text, over and over again. The close button even takes a few seconds to respond. When I drag the GUI box it takes a few seconds to move over to where I dragged it as well.

Also, anyone know why some web pages don't get completely entered using this command:

Run(@COMSPEC & " /c start " & $webpage, "", @SW_HIDE)

They seem to stop entering text at the & symbol in some but not all of my URL's.

If I enter the text manually going to start -> run the web page loads fine.

Link to comment
Share on other sites

post your GUI code sample & Why dont you use _IECreate ?

WinSetState('my win name', "", @SW_HIDE)

Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

ignore what I said about ur GUI code post your whole code. And you can only use it with IE. There is no Firefox version. Use IE. All info is in the help file F1

This how you can hide the windows.

run('notepad')
WinActivate('Untitled -')
Sleep(2000)
WinSetState("Untitled -", "", @SW_HIDE)
Sleep(2000)
WinSetState("Untitled -", "", @SW_SHOW)
Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

@Jarobata

How often do you need to be checking for updates?

The reason the script is so laggy is that you have a continuos tight loop going that is not only hogging CPU resources, but also your OnEvent button firings are waiting for an opportunity to be registered during all that processing.

Would it hurt to check every 30 seconds or so?

Link to comment
Share on other sites

@Jarobata

How often do you need to be checking for updates?

The reason the script is so laggy is that you have a continuos tight loop going that is not only hogging CPU resources, but also your OnEvent button firings are waiting for an opportunity to be registered during all that processing.

Would it hurt to check every 30 seconds or so?

Ya I think I"m going to try that.

Link to comment
Share on other sites

Ya I think I"m going to try that.

Also, it appears a lot of your lag is coming from piling up the _IECreate Functions one after the other.

Basically your script is waiting until each page is loaded before it carries on. Is it possible to just use ShellExecute() without any waiting so the page will open in the default browser?

And do you immediately need the pages to open when the checker sees the items as being in stock?

Seems like that's not really necessary as you already have the indicator label and a button to open the page right there (???)

For what it's worth, I was playing with condensing your code somewhat and came up with the following.

Please note that it's not complete as it only checks on startup (no timed loop yet, but you could probably figure that out :))

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.12.1
    Author:      myName
    
    Script Function:
    Template AutoIt script.
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.12.1
    Author:      Jarobata
    
    Script Function:
    
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <StaticConstants.au3>
Opt("TrayIconDebug", 1)
$CheckerGui = GUICreate("Checker", 500, 300)
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "MINIMIZEClicked")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MAXIMIZEClicked")


;Declare Variables

Const $buycomstring = "Buy.com Total Price:"
Global $product1Url = "http://www.buy.com/prod/brother-mfc-465cn-photo-color-all-in-one-with-networking/q/loc/101/205663718.html"
Global $product2URL = "http://www.buy.com/prod/brother-mfc-8860dn-monochrome-laser-multifunction-printer-30-ppm-mono/q/loc/101/202473533.html"
Global $product3URL = "http://www.buy.com/prod/brother-mfc-9440cn-color-laser-muti-function-center-w-networking/q/loc/101/205503743.html"
Global $product4URL = "http://www.buy.com/prod/sandisk-4gb-cruzer-titanium-plus-usb-flash-drive/q/loc/101/206892914.html"
Global $product5URL = "http://www.buy.com/prod/nokia-n95-8gb-smart-phone-unlocked-5-mp-camera-with-carl-zeiss-optics/q/loc/101/207383634.html"
Global $product6URL = "http://www.buy.com/prod/iomega-500gb-usb-2-0-7200rpm-external-hard-drive/q/loc/101/202930159.html"
Global $product7URL = "http://www.buy.com/prod/dane-elec-2gb-zmate-pen-usb-2-0-flash-drive-2-gb-usb/q/loc/101/204304883.html"
Global $product8URL = "http://www.buy.com/prod/samsung-ml-2510-laser-printer-25ppm-monochrome-laser-desktop-printer/q/loc/101/202878936.html"

Global $product1html, $product2Html, $product3Html, $product4Html, $product5Html, $product6Html, $product7Html, $product8Html
Global $TitleId, $product1Label, $product2Label, $product3Label, $product4Label, $product5Label, $product6Label, $product7Label, $product8Label
Global $product1Stock, $product2Stock, $product3Stock, $product4Stock, $product5Stock, $product6Stock, $product7Stock, $product8Stock
Global $product1Button, $product2Button, $product3Button, $product4Button, $product5Button, $product6Button, $product7Button, $product8Button
Global $product1StockLabel, $product2StockLabel, $product3StockLabel, $product4StockLabel, $product5StockLabel, $product6StockLabel, $product7StockLabel, $product8StockLabel

Global $font = "Arial", $red = 0xff0000, $green = 0x00ff00, $grey = 0xc6c3c6
Global $OutOfStock, $StockId, $webpage, $CellNumber


;Initialize GUI
$product1Label = GUICtrlCreateLabel("product1", 20, 60)
$product2Label = GUICtrlCreateLabel("product2", 20, 90)
$product3Label = GUICtrlCreateLabel("product3", 20, 120)
$product4Label = GUICtrlCreateLabel("product4", 20, 150)
$product5Label = GUICtrlCreateLabel("product5", 20, 180)
$product6Label = GUICtrlCreateLabel("product6", 20, 210)
$product7Label = GUICtrlCreateLabel("product7", 20, 240)
$product8Label = GUICtrlCreateLabel("product8", 20, 270)

$product1StockLabel = GUICtrlCreateLabel("???", 200, 60)
GUICtrlSetStyle(-1, $SS_CENTER)
GUICtrlSetBkColor(-1, $grey)
$product2StockLabel = GUICtrlCreateLabel("???", 200, 90)
GUICtrlSetStyle(-1, BitOR($SS_CENTER, $SS_SUNKEN))
GUICtrlSetBkColor(-1, $grey)
$product3StockLabel = GUICtrlCreateLabel("???", 200, 120)
GUICtrlSetStyle(-1, BitOR($SS_CENTER, $SS_SUNKEN))
GUICtrlSetBkColor(-1, $grey)
$product4StockLabel = GUICtrlCreateLabel("???", 200, 150)
GUICtrlSetStyle(-1, BitOR($SS_CENTER, $SS_SUNKEN))
GUICtrlSetBkColor(-1, $grey)
$product5StockLabel = GUICtrlCreateLabel("???", 200, 180)
GUICtrlSetStyle(-1, BitOR($SS_CENTER, $SS_SUNKEN))
GUICtrlSetBkColor(-1, $grey)
$product6StockLabel = GUICtrlCreateLabel("???", 200, 210)
GUICtrlSetStyle(-1, BitOR($SS_CENTER, $SS_SUNKEN))
GUICtrlSetBkColor(-1, $grey)
$product7StockLabel = GUICtrlCreateLabel("???", 200, 240)
GUICtrlSetStyle(-1, BitOR($SS_CENTER, $SS_SUNKEN))
GUICtrlSetBkColor(-1, $grey)
$product8StockLabel = GUICtrlCreateLabel("???", 200, 270)
GUICtrlSetStyle(-1, BitOR($SS_CENTER, $SS_SUNKEN))
GUICtrlSetBkColor(-1, $grey)

$TitleId = GUICtrlCreateLabel("Checker", 140, 0, 300, 50)
GUICtrlSetDefColor(0x000080)
GUISetBkColor(0xfffafa)
GUICtrlSetFont($TitleId, 26)
GUICtrlSetColor($TitleId, 0xff0000)
$product1Button = GUICtrlCreateButton("Product Web Page", 325, 60, 150, 23)
$product2Button = GUICtrlCreateButton("Product Web Page", 325, 90, 150, 23)
$product3Button = GUICtrlCreateButton("Product Web Page", 325, 120, 150, 23)
$product4Button = GUICtrlCreateButton("Product Web Page", 325, 150, 150, 23)
$product5Button = GUICtrlCreateButton("Product Web Page", 325, 180, 150, 23)
$product6Button = GUICtrlCreateButton("Product Web Page", 325, 210, 150, 23)
$product7Button = GUICtrlCreateButton("Product Web Page", 325, 240, 150, 23)
$product8Button = GUICtrlCreateButton("Product Web Page", 325, 270, 150, 23)

GUICtrlSetOnEvent($product1Button, "_productPage")
GUICtrlSetOnEvent($product2Button, "_productPage")
GUICtrlSetOnEvent($product3Button, "_productPage")
GUICtrlSetOnEvent($product4Button, "_productPage")
GUICtrlSetOnEvent($product5Button, "_productPage")
GUICtrlSetOnEvent($product6Button, "_productPage")
GUICtrlSetOnEvent($product7Button, "_productPage")
GUICtrlSetOnEvent($product8Button, "_productPage")




GUISetState(@SW_SHOW)
$CellNumber = InputBox("Cell Number", "Please Enter Your 11 Digit Cell Phone Number.                Don't forget to open Pidgin!", "18604300326", "", 250, 125)

For $i = 1 To 8
    _CheckProduct($i)
Next

While 1
    Sleep(100)
WEnd


Func Message($Message)
;MsgBox(0,"Message",$CellNumber & @CRLF & $Message,1);MsgBox for testing
    If WinExists("Buddy List") Then
        WinActivate("Buddy List")
        WinWaitActive("Buddy List")
        Send("^m")
        Send("+" & $CellNumber, 1)
        Send("{TAB}")
        Send("{TAB}")
        Send("{ENTER}")
        Send($Message)
        Send("{PAUSE}")
        Send("{ENTER}")
    EndIf
EndFunc;==>Message

Func CLOSEClicked()
    Exit
EndFunc;==>CLOSEClicked

Func MINIMIZEClicked()
    GUISetState(@SW_MINIMIZE)
EndFunc;==>MINIMIZEClicked

Func MAXIMIZEClicked()
    GUISetState(@SW_MAXIMIZE)
EndFunc;==>MAXIMIZEClicked


Func _CheckProduct($iProduct)
    Local $prodURL = Eval("Product" & $iProduct & "URL")
    Local $tmpHtml = @TempDir & "\product" & $iProduct & ".html"
    Local $ProductHtml, $ProductStock
    
    If Not InetGet($prodURL, $tmpHtml) Then; if download fails, call _StockState to set to unkown (???)
        _StockState($iProduct, -1)
    Else
        $ProductHtml = FileRead($tmpHtml)
        $ProductStock = StringInStr($ProductHtml, $buycomstring)
        _StockState($iProduct, $ProductStock)
    EndIf
EndFunc;==>_CheckProduct

Func _StockState($iProduct, $iState)
    Local $StockLabel = Eval("product" & $iProduct & "StockLabel")
;MsgBox(0,"StockLabel",$Stocklabel)
    Switch $iState;unknown, InetGet Failed???
        Case - 1
            GUICtrlSetData($StockLabel, "???")
            GUICtrlSetBkColor($StockLabel, $grey)
            
        Case 0; out of Stock
            GUICtrlSetData($StockLabel, "Out")
            GUICtrlSetBkColor($StockLabel, $red)
            TraySetState(8)
            
        Case Else; inStock
            GUICtrlSetData($StockLabel, "In")
            GUICtrlSetBkColor($StockLabel, $green)
            TraySetState(4)
            Message("product" & $iProduct & " In!")
    EndSwitch
EndFunc;==>_StockState

Func _ProductPage()
    $currentButton = ControlGetFocus($CheckerGui)
    $iButton = StringReplace($currentButton,"Button","")
    $currentProductURL = Eval("product" & $iButton & "URL")
;MsgBox(0,"",$currentProductURL)
;;$webpage = _IECreate($currentProductURL)
;_IELoadWait($webpage)
    ShellExecute($currentProductURL)

EndFunc
Edited by ResNullius
Link to comment
Share on other sites

i am not shure if i understood fully what the main purpose was but

maybe it can be done in different way

wrap up the code into an external call to "wget " which writes to file[1] - file[x]

wget can be started and it will write the output file when done, independently from the script

in main message loop now only check file[1] - file [x] for contents..

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...