Jump to content



Photo

GUI Hangs


  • Please log in to reply
9 replies to this topic

#1 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 10 June 2012 - 01:21 AM

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,K.Syed Ibrahim.





#2 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 10 June 2012 - 09:34 AM

Without script nobody can help you ...

#3 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 10 June 2012 - 10:05 AM

Without script nobody can help you ...

Here is my script....

AutoIt         
#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

AutoIt         
#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, 10 June 2012 - 10:08 AM.

Thank you,Regards,K.Syed Ibrahim.

#4 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 10 June 2012 - 10:39 AM

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, 10 June 2012 - 12:00 PM.


#5 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 10 June 2012 - 12:28 PM

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,K.Syed Ibrahim.

#6 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 10 June 2012 - 12:50 PM

Try:
- check memory allocation during rinning of your script
- create as small as possible reproducing script

#7 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 10 June 2012 - 12:52 PM

am isolate exactly my gui freezes whenever it tries to copy huge data..... any suggestion for that ?


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.

#8 Syed23

Syed23

    Mass Spammer! - It's Me

  • Active Members
  • PipPipPipPipPipPip
  • 519 posts

Posted 10 June 2012 - 01:01 PM

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,K.Syed Ibrahim.

#9 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 10 June 2012 - 02:12 PM

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


Then you must use your own copy method and test GUIGetMsg() during copying.
Search this forum for "copy with progress"

#10 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,820 posts

Posted 10 June 2012 - 09:41 PM

Try this function by wraithdu.

How to ask questions the smart way!

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users