mucitbey Posted November 9, 2023 Share Posted November 9, 2023 Hello friends, I shortened the script so that it is executable and you can see the problem more clearly. In its simplest form, Scrip copies a folder and its content to another location, and I designed a visual interface until this process is completed. What I want you to help me with is that the script works without any problems when it runs, but when the copy function starts, the movement of the visual interface stops until the "operation completed" message. How can I make the animated visual interface work until the copying process is completed and close it when the copying process is completed. I would like to thank those who can help in this matter in advance and wish you healthy days. expandcollapse popup#NoTrayIcon #include <Misc.au3> #include <Date.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> #Include <StaticConstants.au3> #include <WindowsConstants.au3> _Singleton(@ScriptName, 0) Global Const $WS_EX_LAYERED_BIT = 0x80000 Global Const $NUM_BUTTONS = 8 Global $Gui, $Buttons[$NUM_BUTTONS] Global $currentIndex = 0 Global $direction = 1 Global $color1 = 0x000000 Global $color2 = 0xFF0000 _KnRd() Func _Send() Local $BackUp = DirCopy("D:\Music\", "C:\PDKSSS\", 1) If $BackUp = 1 Then MsgBox(0, "COMPLETED", "Copying all data Completed...", 3) Exit EndIf EndFunc Func _LED01() GUICtrlSetBkColor($Buttons[$currentIndex], $color1) $currentIndex += $direction If $currentIndex >= $NUM_BUTTONS Or $currentIndex < 0 Then $direction *= -1 $currentIndex += $direction * 2 EndIf GUICtrlSetBkColor($Buttons[$currentIndex], $color2) Local $exStyle = _WinAPI_GetWindowLong($Gui, $GWL_EXSTYLE) If $direction = -1 Then $alpha = BitShift($exStyle, -$WS_EX_LAYERED_BIT) $alpha -= 10 If $alpha <= 0 Then $alpha = 0 $exStyle = BitAND($exStyle, BitNOT($WS_EX_LAYERED)) $exStyle = BitOR($exStyle, BitShift($alpha, $WS_EX_LAYERED_BIT)) Else $alpha = BitAND($exStyle, $WS_EX_LAYERED) $alpha = BitShift($alpha, -$WS_EX_LAYERED_BIT) $alpha += 10 If $alpha >= 255 Then $alpha = 255 $exStyle = BitAND($exStyle, BitNOT($WS_EX_LAYERED)) $exStyle = BitOR($exStyle, BitShift($alpha, $WS_EX_LAYERED_BIT)) EndIf _WinAPI_SetWindowLong($Gui, $GWL_EXSTYLE, $exStyle) _WinAPI_SetLayeredWindowAttributes($Gui, 0, $alpha, $LWA_ALPHA) EndFunc Func _KnRd() $Gui = GUICreate("", 360, 100, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($Gui, 0xABCDEF, 255) $LB01 = GUICtrlCreateLabel("DATA IS SENT TO THE SERVER...", 5, 5, 350, 30, BitOR($SS_CENTER, $SS_SUNKEN, $SS_CENTERIMAGE)) GUICtrlSetFont($LB01, 16, 400, 0, "Myriad Pro") $LB02 = GUICtrlCreateLabel("PLEASE WAIT...", 5, 65, 350, 30, BitOR($SS_CENTER, $SS_SUNKEN, $SS_CENTERIMAGE)) GUICtrlSetFont($LB02, 16, 400, 0, "Myriad Pro") $ButtonX = 20 $ButtonY = 40 $ButtonWidth = 40 $ButtonHeight = 20 For $i = 0 To $NUM_BUTTONS - 1 $Buttons[$i] = GUICtrlCreateButton("", $ButtonX, $ButtonY, $ButtonWidth, $ButtonHeight) GUICtrlSetBkColor($Buttons[$i], $color1) $ButtonX += 40 Next GUISetState() AdlibRegister("_LED01", 100) AdlibRegister("_Send", 250) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc Link to comment Share on other sites More sharing options...
Andreik Posted November 9, 2023 Share Posted November 9, 2023 AdlibRegister() calling a function that it's suppose to copy an entire directory in a different location every 250 ms? I think it's not the best design and you should reconsider. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
mucitbey Posted November 9, 2023 Author Share Posted November 9, 2023 13 minutes ago, Andreik said: AdlibRegister() calling a function that it's suppose to copy an entire directory in a different location every 250 ms? I think it's not the best design and you should reconsider. This edited version normally has a much longer running time. I shortened the code so it could be tested. Link to comment Share on other sites More sharing options...
Andreik Posted November 9, 2023 Share Posted November 9, 2023 (edited) It's still a bad design in my opinion and not very safe since you don't really know how much time would be necessary for such an operation. Why not reading the files into an array and using a loop to copy files and animate the progress? Or you can still use DirCopy() but don't call it more than once and use the AdlibRegister() to call the function that animate the progress. Edited November 9, 2023 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now