Jump to content

GUI Hangs


Syed23
 Share

Recommended Posts

Hi All,

I have created a GUI which will show the information of directories to be copied. For that i was using the GUI to show the information to Users. But when i copy the directory which contains more than 1GB folder the GUI frozes.. does any one why this happens? any suggestion for not happening?

Note :-

Most important thing is i am using _GUICtrlCreateGIF()which will anitmate the gif image in GUI.

Thanks in advance for the advise.

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

Without script nobody can help you ...

Here is my script....

#RequireAdmin
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include "_XMLDomWrapper.au3"
#include "GIFAnimation.au3" ;
#include "GDIpProgress.au3"
#include <GuiRichEdit.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <ComboConstants.au3>
#include"Array.au3"
#include"Pst.au3"
#include "_XMLDomWrapper.au3"
#include<File.au3>
#include <ProgressConstants.au3>
Global $aArray
Global $Title = "Data Restoration Utility"
Global $Log = @ProgramFilesDir & "Enterprise DesktopLogsDRU.log"
Global $iProgress_1
Global $filedest = "C:TempwaitAnimated.gif"
FileInstall("C:UsersQ03200DesktopwaitAnimated.gif", $filedest,1)
$BaseGUI = GUICreate($Title, 750, 550, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))
GUISetBkColor(0xFAFAFA)
$Sourcedrive = GUICtrlCreateLabel("Select the Source Drive", 10, 10, 120, 40)
$ErrorLabel = GUICtrlCreateLabel("", 10, 440, 480, 40)
$DrivePath = GUICtrlCreateCombo("C:", 135, 5, 60, 50, $CBS_DROPDOWNLIST)
$DestDrive = GUICtrlCreateLabel("Data Destination Location", 230, 10, 200, 40)
$DestPath = GUICtrlCreateCombo("C:", 370, 5, 60, 50, $CBS_DROPDOWNLIST)
$aArray = DriveGetDrive("ALL")
$OS = GUICtrlCreateLabel("Select Source OS", 475, 10, 100, 40)
$OSver = GUICtrlCreateCombo("Win 7(64 Bit)", 570, 5, 90, 50, $CBS_DROPDOWNLIST)
GUICtrlSetData($OSver, StringUpper("Win 7|XP"))
If @error Then
; An error occurred when retrieving the drives.
MsgBox(16, $Title & "DriveGetDrive", "Error occured while trying to fetch the drive details.")
Exit
Else
For $i = 1 To $aArray[0] ; Show all the drives found and convert the drive letter to uppercase.
If $aArray[$i] <> "C:" Then
GUICtrlSetData($DrivePath, StringUpper($aArray[$i]))
EndIf
Next
EndIf

$processviewer = GUICtrlCreateGroup("Restore Options", 10, 70, 280, 340)
$DESK = GUICtrlCreateCheckbox("Desktop", 30, 100, 250, 40)
$FAV = GUICtrlCreateCheckbox("Favorites", 30, 140, 250, 40)
$OFF = GUICtrlCreateCheckbox("Office Files", 30, 180, 250, 40)
$AVA = GUICtrlCreateCheckbox("App1", 30, 220, 250, 40)
$CRYPTO = GUICtrlCreateCheckbox("App2", 30, 260, 250, 40)
$PSTS = GUICtrlCreateCheckbox("PST Files", 30, 300, 250, 40)
$Others = GUICtrlCreateCheckbox("Others", 30, 340, 250, 40)
$StartButton = GUICtrlCreateButton("Restore", 15, 490, 60, 40)
$CancelButton = GUICtrlCreateButton("Exit", 200, 490, 60, 40)


GUISetState()

While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Or $msg = $CancelButton Then
; _GUICtrlRichEdit_Destroy($iMemo)
;_FileWriteLog($Log, "INFO >End process >" & "Tool has completed the test cases. IE report launched and the tools exits!")
Exit
EndIf

If DriveGetType(GUICtrlRead($DrivePath)) <> "Fixed" And GUICtrlRead($DrivePath) <> "" And $msg = $StartButton Then
;MsgBox(48,"Source Drive Warning!","Source directory can not be a Network drive. Please select the correct drive.")
GUICtrlSetData($ErrorLabel, "Source directory can not be a Network drive. Please select the correct drive.")
GUICtrlSetColor($ErrorLabel, 0xff0000)
EndIf



If $msg = $StartButton Then
process()
EndIf
WEnd

Func process()
$hGIF = _GUICtrlCreateGIF($filedest, "", 560, 350, 200, 200)
If GUICtrlRead($OSver) = "XP" Then
If Foldexist(GUICtrlRead($DrivePath) & "Drivers") = True Then
$users = "Documents and Settings"
$prog = "Program Files"
Else
MsgBox(48, "OS Type Warning!", "Source Location OS Type was not Windows XP.Select the appropriate one!")
EndIf
ElseIf GUICtrlRead($OSver) = "Win 7(64 Bit)" Then

If Foldexist(GUICtrlRead($DrivePath) & "Program Files (x86)") = True Then
$users = "Users"
$prog = "Program Files (x86)"
Else
MsgBox(48, "OS Type Warning!", "Source Location OS Type was not Windows 7 64 Bit.Select the appropriate one!")

EndIf

ElseIf GUICtrlRead($OSver) = "Win 7" Then
$users = "Users"
$prog = "Program Files"
EndIf
If GUICtrlRead($DESK) = "1" Then
GUISetState(@SW_HIDE)
$file = _XMLFileOpen(@DesktopDir & "Location.xml")
$numberOfChannels = _XMLGetNodeCount("/root/desktop")
For $s = 1 To $numberOfChannels Step +1
$Comment = _XMLGetChildText("/root/desktop[" & $s & "]")

$m = DirCopy(GUICtrlRead($DrivePath)&$users&@UserName&$Comment[1], "C:"&$users&@UserName&$Comment[1],1)

Next
EndIf

If GUICtrlRead($FAV) = "1" Then
$file = _XMLFileOpen(@DesktopDir & "Location.xml")
$numberOfChannels = _XMLGetNodeCount("/root/fav")
For $s = 1 To $numberOfChannels Step +1
$Comment = _XMLGetChildText("/root/fav[" & $s & "]")


$m = DirCopy(GUICtrlRead($DrivePath)&$users&@UserName&$Comment[1], "C:"&$users&@UserName&$Comment[1],1)

Next
EndIf

If GUICtrlRead($OFF) = "1" Then
$file = _XMLFileOpen(@DesktopDir & "Location.xml")
$numberOfChannels = _XMLGetNodeCount("/root/off")
For $s = 1 To $numberOfChannels Step +1
$Comment = _XMLGetChildText("/root/off[" & $s & "]")
$m = DirCopy(GUICtrlRead($DrivePath)&$users&@UserName&$Comment[1], "C:"&$users&@UserName&$Comment[1],1)

Next
EndIf

If GUICtrlRead($AVA) = "1" Then
$file = _XMLFileOpen(@DesktopDir & "Location.xml")
$numberOfChannels = _XMLGetNodeCount("/root/avaya")
For $s = 1 To $numberOfChannels Step +1
$Comment = _XMLGetChildText("/root/avaya[" & $s & "]")
$m = DirCopy(GUICtrlRead($DrivePath)&$users&@UserName&$Comment[1], "C:backup"&$users&@UserName&$Comment[1],1)

Next
EndIf

If GUICtrlRead($CRYPTO) = "1" Then
$file = _XMLFileOpen(@DesktopDir & "Location.xml")
$numberOfChannels = _XMLGetNodeCount("/root/cryp")
For $s = 1 To $numberOfChannels Step +1
$Comment = _XMLGetChildText("/root/cryp[" & $s & "]")
$m = DirCopy(GUICtrlRead($DrivePath)&$prog&@UserName&$Comment[1], "C:"&$prog&@UserName&$Comment[1],1)

Next


EndIf

If GUICtrlRead($PSTS) = "1" Then
$pst = pst(@ComputerName,GUICtrlRead($DrivePath))
For $s = 0 To UBound($pst) Step +1
$m = DirCopy($pst[$s], "C:backup"&StringTrimLeft($pst[$s],2),1)
Next
EndIf

If GUICtrlRead($Others) = "1" Then
MsgBox(64,"Info!","This option will be added soon!")
GUICtrlSetState($Others,$GUI_UNCHECKED)
EndIf
EndFunc   ;==>process

Here is my Pst.au3

#include-once
#include<Array.au3>
Global $str,$drive,$objFile,$objWMIService,$colFiles,$Filepath[1],$Filename[1],$objFSO,$path

Func pst($str,$drive)
$objWMIService = ObjGet("winmgmts:" & $str & "rootcimv2")

$colFiles = $objWMIService.ExecQuery("Select * from CIM_DataFile Where Extension = 'pst' AND Drive = '"&$drive&"'")
If IsObj($colFiles) Then
For $objFile in $colFiles
    _ArrayInsert($Filepath,UBound($Filepath)-1,$objFile.Drive & $objFile.Path)
;_ArrayInsert($Filepath,UBound($Filepath)-1,$objFile.Drive & $objFile.Path &$objFile.FileName&".pst")
Next
Return $Filepath
Else
Return "No PST Found!"
EndIf
EndFunc

Func Foldexist($path)
$objFSO = ObjCreate("Scripting.FileSystemObject")

IF $objFSO.FolderExists($path) THEN
Return True
ELSE
Return False
ENDIF
EndFunc

Please let me know if you need anything else

Edited by Syed23

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

I see that you don't do cleaning of memory at some places:

Foldexist - it's called many times in loops and there is ObjCreate() without $objFSO=0

_GUICtrlCreateGIF - created each time when process is clicked - it should be created only once at start and change only its visibility (GUICtrlSetState+$GUI_SHOW/$GUI_HIDE?)

EDIT: (GUICtrlSetState+$GUI_SHOW/$GUI_HIDE?)

Edited by Zedna
Link to comment
Share on other sites

I see that you don't do cleaning of memory at some places:

Foldexist - it's called many times in loops and there is ObjCreate() without $objFSO=0

_GUICtrlCreateGIF - created each time when process is clicked - it should be created only once at start and change only its visibility (GUICtrlSetState+$GUI_SHOW/$GUI_HIDE?)

EDIT: (GUICtrlSetState+$GUI_SHOW/$GUI_HIDE?)

What is the memory clean are you talking about? about from above steps? i have done both and i am isolate exactly my gui freezes whenever it tries to copy huge data..... any suggestion for that ?

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

Do you mean that GUI can't be controled just during DirCopy and after it finished it's OK?

That is whole different story then.

Perfect! you got me know.. That is what happening! when it copies the huge size(arround 1GD) dir then GUI hangs.. once that copy done the GUI resumes normal...

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

Try this by wraithdu.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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