tonycstech
Новичок
- Сообщения
- 94
- Репутация
- 3
Каждый раз новая страница добавляет мегабайты памяти.
Я поставил фукцыю что если более 1 гига то уничтожить GUI и тем самым уничтожить и _IECreateEmbedded ( ) обьект.
хотя эта цыфра и не правильная в сравнении с TaskManager
Но к моему сожалению это не уменшает потребление памяти.
В чём собственно проблема ? Почему она постоянно увеличевается ?
$URL любой playlist из YouTube
Я поставил фукцыю что если более 1 гига то уничтожить GUI и тем самым уничтожить и _IECreateEmbedded ( ) обьект.
Код:
If $Memory[1]/1024 > 1048576 Then ;Greater then 1 GB or ram
Но к моему сожалению это не уменшает потребление памяти.
В чём собственно проблема ? Почему она постоянно увеличевается ?
$URL любой playlist из YouTube
Код:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=icon.ico
#AutoIt3Wrapper_Outfile=YouTube Watcher.Exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.14.5
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
$Log = @DesktopDir & "\Log.log"
FileDelete ($Log)
_WriteLog("Program started")
Opt("TrayMenuMode", 1+8)
Opt("TrayOnEventMode", 1) ;to go to function on click
Opt("TrayAutoPause", 0)
Opt("WinTitleMatchMode", 2) ;searching substring of the title for a match
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_Exit")
$HideMenu = TrayCreateItem("Hide window")
TrayItemSetOnEvent(-1, "_HideShow")
$ButtonNotActivated = @ScriptDir & "\Images\Button Loop Inactive.bmp"
$ButtonActivated = @ScriptDir & "\Images\Button Loop Active.bmp"
$INI = @ScriptDir & "\Settings.ini"
$URL = IniRead($INI, "Settings", "URL", "Not specified")
$PlayListDeactivated = "yt-uix-button yt-uix-button-size-default yt-uix-button-player-controls yt-uix-button-empty yt-uix-button-has-icon toggle-loop yt-uix-button-opacity yt-uix-tooltip yt-uix-tooltip"
$PlayListActivated1 = "yt-uix-button yt-uix-button-size-default yt-uix-button-player-controls yt-uix-button-empty yt-uix-button-has-icon toggle-loop yt-uix-button-opacity yt-uix-tooltip yt-uix-tooltip yt-uix-button-toggled"
$PlayListActivated2 = "yt-uix-button yt-uix-button-size-default yt-uix-button-player-controls yt-uix-button-empty yt-uix-button-has-icon toggle-loop yt-uix-button-opacity yt-uix-tooltip yt-uix-button-toggled yt-uix-tooltip"
;There are 2 classes for activated playlist buttons.
;1st class is when button is toggled for the first time
;Class changes to 2nd when video finished and next video loaded.
;Thats why i check that button using two different class names
Global $GUI, $Reload, $Options, $StatusInput, $RAM, $IE
_ClearCache()
_Create() ;Start the page loading process
_CheckForLoopStatus() ;To activate the loop at start
$Timeout = 5000 ;delay before checking for loop status
$DelayStart = TimerInit()
_WriteLog("Entering main loop")
While 1
If TimerDiff ($DelayStart) > $Timeout Then ;Proceed only if page is NOT in a loading state.
$Loading = _IELoadWait($IE)
If $Loading = 1 Then
_CheckForLoopStatus() ;go ther only if page is not busy but page is hardly ever busy, only elements update
EndIf
$DelayStart = TimerInit() ;reset timer
EndIf
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then
_WriteLog("Window was closed. Exiting application")
GUIDelete ($GUI) ; Embeded $IE cannot be quit, it will quick with closing the GUI to whic it is embeded to.
Exit
EndIf
If $msg = $Reload Then _IENavigate($IE, $URL)
If $msg = $Options Then _Options()
$Memory = ProcessGetStats()
GUICtrlSetData ($RAM,"Using" & @CRLF & $Memory[1]/1024 & "MB")
If $Memory[1]/1024 > 1048576 Then ;Greater then 1 GB or ram, restart maybe ?
_WriteLog("Process reached 1GB of RAM usage. Restarting window.")
GUIDelete ($GUI)
_ClearCache()
_Create()
EndIf
Wend
Func _Create()
_WriteLog("Creating page started")
$GUI = GUICreate ("YouTuber",1024,680)
$Reload = GUICtrlCreateButton ("Reload page",0,0,80,40)
$Options = GUICtrlCreateButton ("Show Options",80,0,120,40)
$StatusInput = GUICtrlCreateInput ("Status:",200,0,724,40)
GUICtrlSetFont (-1,18)
$RAM = GUICtrlCreateLabel ("",924,0,100,40)
GUISetState(@SW_SHOW,$GUI)
GUICtrlSetData ($StatusInput,"Status: Loading page")
$IE = _IECreateEmbedded()
GUICtrlCreateObj ($IE,0,40,1024,640)
_IENavigate($IE, $URL)
_WriteLog("Creating page ended")
EndFunc
Func _CheckForLoopStatus()
$FoundStatus = 0
$Collection = _IETagNameGetCollection ($IE, "button") ;get collection of all names
For $btn in $Collection ;searching collection and storing it in btn
If String($btn.classname)= $PlayListDeactivated Then
_WriteLog("Activating playlist loop button")
$FoundStatus = 1
_IEAction ($btn,"click")
_WriteLog("Playlist loop button activated")
GUICtrlSetData ($StatusInput,"Status: Loop button Activated")
ElseIf String($btn.classname) = $PlayListActivated1 Then
$FoundStatus = 1
GUICtrlSetData ($StatusInput,"Status: 1st Loop is already activated")
ElseIf String($btn.classname) = $PlayListActivated2 Then
$FoundStatus = 1
GUICtrlSetData ($StatusInput,"Status: 2nd Loop is already activated")
EndIf
Next
If $FoundStatus = 0 Then
GUICtrlSetData ($StatusInput,"Status: Unable to find playlist loop button. Startingn from begining")
_WriteLog("Unable to find playlist loop button. Restarting process")
_ClearCache()
GUIDelete ($GUI)
_Create()
EndIf
EndFunc
Func _ClearCache()
;You can delete/clear others things by changing $ClearID's value:
;History Only = 1
;Cookies Only = 2
;Temporary Internet Files Only = 8
;Form Data Only = 16
;Password History Only = 32
;Everything = 255
$ClearID = "255"
Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID)
EndFunc
Func _Options()
_WriteLog("Options function started")
$GUI_Options = GUICreate ("Options",200,100,-1,-1,-1,-1,$GUI)
GUISetState(@SW_SHOW,$GUI_Options)
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
_WriteLog("Options function ended")
GUIDelete ($GUI_Options)
EndFunc
Func _WriteLog($Text)
FileWrite($Log, @CRLF & @HOUR & ":" & @MIN & " " & $Text)
EndFunc ;==>_WriteLog
Func _HideShow()
$WinState = WinGetState ($GUI)
If BitAND ($WinState,$WIN_STATE_VISIBLE) Then
_WriteLog("Application hidden")
Winsetstate ($GUI,"",@SW_HIDE)
TrayItemSetText ($HideMenu,"Show Window")
Else
_WriteLog("Application no longer hidden")
Winsetstate ($GUI,"",@SW_SHOW)
TrayItemSetText ($HideMenu,"Hide Window")
EndIf
EndFunc
Func _Exit()
Exit
EndFunc ;==>_Exit