Jump to content

****Excessive consumption of the CPU****


Recommended Posts

Could you please post your code so we can have a look at it? Makes debugging much easier >_

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I think the error may be here because what other functions and are nothing if not push them to come

Opt("GUIOnEventMode", 1)

#Region ### ###

$Form1_1 = GUICreate("::: ::: E 1.0", 640, 480, -1, -1)

GUISetIcon("favicon.ico")

GUISetOnEvent($GUI_EVENT_CLOSE, "Form1_1Close")

$Button1 = GUICtrlCreateButton("Actualizar", 560, 10, 70, 40, 0)

GUICtrlSetOnEvent(-1, "Button1Click")

$Combo = GUICtrlCreateCombo("Seleccionar ruta...",33,28, 525, 300)

GUICtrlSetOnEvent(-1, "ComboChange")

$Button2 = GUICtrlCreateButton("+", 10, 28, 22, 20, 0)

GUICtrlSetOnEvent(-1, "Button2Click")

$Listado = GUICtrlCreateListView("Archivo|Tamaño|Fecha de modificación",10,60,620, 410,$LVS_SHOWSELALWAYS)

_GUICtrlListView_JustifyColumn($Listado, 0,0)

_GUICtrlListView_JustifyColumn($Listado, 1,1)

_GUICtrlListView_JustifyColumn($Listado, 2,0)

GUICtrlSendMsg(-1, 0x101E, 0, 370)

GUICtrlSendMsg(-1, 0x101E, 1, 121)

GUICtrlSetOnEvent(-1, "ListView1Click")

GUISetState(@SW_SHOW)

GUISetState(@SW_MINIMIZE);Muestro, minimizo y restauro para liberar memoria ram

GUISetState(@SW_RESTORE)

#EndRegion ### ###

Dim $Archivos

Dim $Origen = ""

Dim $Destino = ""

$Rutas = FileOpen("Rutas.txt",0)

If $Rutas = -1 Then

MsgBox(0, "Error", "Archivo no se pudo abrir.Se creara uno",8)

EndIf

Dim $Origenes[_FileCountLines("Rutas.txt")+1]

Dim $Destinos[_FileCountLines("Rutas.txt")+1]

$Origenes[0] = _FileCountLines("Rutas.txt")

$Destinos[0] = _FileCountLines("Rutas.txt")

$i=1

While 1

$linea = FileReadLine($Rutas)

If @error = -1 then ExitLoop

$aux = StringSplit( $linea, "|")

$Origenes[$i] = $aux[1]

$Destinos[$i] = $aux[2]

_GUICtrlComboBox_AddString($Combo, $Origenes[$i] &" --> " & $Destinos[$i])

$i=$i+1

WEnd

FileClose($Rutas)

Do

Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()

Edited by vitimgm01
Link to comment
Share on other sites

You've created a very tight loop. According to the examples in the AutoIt help file you should insert a Sleep in your code

Do
    Sleep(100)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I think the error may be here because what other functions and are nothing if not push them to come

Opt("GUIOnEventMode", 1)

#Region ### ###

$Form1_1 = GUICreate("::: ::: E 1.0", 640, 480, -1, -1)

GUISetIcon("favicon.ico")

GUISetOnEvent($GUI_EVENT_CLOSE, "Form1_1Close")

$Button1 = GUICtrlCreateButton("Actualizar", 560, 10, 70, 40, 0)

GUICtrlSetOnEvent(-1, "Button1Click")

$Combo = GUICtrlCreateCombo("Seleccionar ruta...",33,28, 525, 300)

GUICtrlSetOnEvent(-1, "ComboChange")

$Button2 = GUICtrlCreateButton("+", 10, 28, 22, 20, 0)

GUICtrlSetOnEvent(-1, "Button2Click")

$Listado = GUICtrlCreateListView("Archivo|Tamaño|Fecha de modificación",10,60,620, 410,$LVS_SHOWSELALWAYS)

_GUICtrlListView_JustifyColumn($Listado, 0,0)

_GUICtrlListView_JustifyColumn($Listado, 1,1)

_GUICtrlListView_JustifyColumn($Listado, 2,0)

GUICtrlSendMsg(-1, 0x101E, 0, 370)

GUICtrlSendMsg(-1, 0x101E, 1, 121)

GUICtrlSetOnEvent(-1, "ListView1Click")

GUISetState(@SW_SHOW)

GUISetState(@SW_MINIMIZE);Muestro, minimizo y restauro para liberar memoria ram

GUISetState(@SW_RESTORE)

#EndRegion ### ###

Dim $Archivos

Dim $Origen = ""

Dim $Destino = ""

$Rutas = FileOpen("Rutas.txt",0)

If $Rutas = -1 Then

MsgBox(0, "Error", "Archivo no se pudo abrir.Se creara uno",8)

EndIf

Dim $Origenes[_FileCountLines("Rutas.txt")+1]

Dim $Destinos[_FileCountLines("Rutas.txt")+1]

$Origenes[0] = _FileCountLines("Rutas.txt")

$Destinos[0] = _FileCountLines("Rutas.txt")

$i=1

While 1

$linea = FileReadLine($Rutas)

If @error = -1 then ExitLoop

$aux = StringSplit( $linea, "|")

$Origenes[$i] = $aux[1]

$Destinos[$i] = $aux[2]

_GUICtrlComboBox_AddString($Combo, $Origenes[$i] &" --> " & $Destinos[$i])

$i=$i+1

WEnd

FileClose($Rutas)

Do

Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()

Hi,

just put a Sleep (20) in your while loop.

;-)

Stefan

Link to comment
Share on other sites

I was under the impression that you should avoid using sleep in a GUIGetMsg() loop because it can cause the GUI to become unresponsive.

GUIGetMsg()

This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU.

Or does this only apply when GUIGetMsg() is actually inside the loop?

Link to comment
Share on other sites

I was under the impression that you should avoid using sleep in a GUIGetMsg() loop because it can cause the GUI to become unresponsive.

Or does this only apply when GUIGetMsg() is actually inside the loop?

Actually, sleep() works in milliseconds, and 1000 of those equals one second, so very small amounts won't be noticeable for most - plus Windows creates a big queue for all the messages sent to a program - and AutoIT (or the default handler) handles most of them, even when GuiGetMsg() isn't called. Don't worry about an app getting a 'hung' status either - that doesn't usually happen for like 5 seconds of not responding to messages..

MSDN:

An application is considered to be not responding if it is not waiting for input, is not in startup processing, and has not called PeekMessage within the internal timeout period of 5 seconds.

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...