Leaderboard
Popular Content
Showing content with the highest reputation on 01/28/2025 in all areas
-
Alright one last attempt : #include <GUIConstants.au3> #include <WinAPIGdi.au3> #include <ColorConstants.au3> Example() Func Example() Local $hGUI1 = GUICreate('Move region 1', 300, 300, 300, 200, -1, $WS_EX_CONTROLPARENT) GUISetBkColor($COLOR_RED) GUISetState() Local $hRgn1 = _WinAPI_CreateRectRgn(0, 0, 80, 80) _WinAPI_SetWindowRgn($hGUI1, $hRgn1) Local $hGUI2 = GUICreate('Move region 2', 300, 300, 420, 320, -1, $WS_EX_CONTROLPARENT) GUISetBkColor($COLOR_RED, $hGUI2) GUISetState(@SW_SHOW, $hGUI2) $hRgn2 = _WinAPI_CreateRectRgn(30, 30, 110, 110) _WinAPI_SetWindowRgn($hGUI2, $hRgn2) Sleep(2000) WinMove($hGUI1, "", 500, 500) _WinAPI_DeleteObject($hRgn1) _WinAPI_DeleteObject($hRgn2) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example You can also drag each square (button ?) independently...1 point
-
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WinAPIHObj.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> Global $hGUI = GUICreate('Move region - is it possible.. ?', 600, 600) GUISetBkColor($COLOR_RED, $hGUI) GUISetState(@SW_SHOW, $hGUI) Global $x = 0, $y = 0, $iWidth = 80, $iHeight = 80 Global $hRgn1 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight) $x = 120 $y = 120 Global $hRgn2 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight) Global $hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3]) _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1) _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3) _WinAPI_SetWindowRgn($hGUI, $hCombinedRgn) Sleep(3000) ; Move the first region to (50, 50) $x = 50 ; New X position $y = 50 ; New Y position $hRgn1 = MoveRegion($hRgn1, $x, $y) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Clean up _WinAPI_DeleteObject($hRgn1) _WinAPI_DeleteObject($hRgn2) GUIDelete($hGUI) ;--------------------------------------------------------------------------------------- Func MoveRegion($hRegion, $newX, $newY) Local $hNewRgn = _WinAPI_CreateRectRgn($newX, $newY, $newX + $iWidth, $newY + $iHeight) Local $hNewCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3]) _WinAPI_CombineRgn($hNewCombinedRgn, $hNewCombinedRgn, $hNewRgn, 1) _WinAPI_CombineRgn($hNewCombinedRgn, $hNewCombinedRgn, $hRgn2, 3) ; Keep the second region _WinAPI_SetWindowRgn($hGUI, $hNewCombinedRgn) _WinAPI_DeleteObject($hRegion) _WinAPI_DeleteObject($hNewCombinedRgn) Return $hNewRgn EndFunc ;---------------------------------------------------------------------------------------1 point
-
1 point
-
DirMove and DirCopy are different in usage, try to understand it. Here is an example script for backing up and restoring folders: #RequireAdmin ; ----------------------------------------------- #include <AutoItConstants.au3> #include <FileConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- ; ------------------------------------------------------------- INPUT : Global Const $sUserName = @UserName Global $sNAME_Path[6] $sNAME_Path[0] = 4 $sNAME_Path[1] = 'SAC64' ; App Folder Name $sNAME_Path[2] = 'Software Audio Console64' ; Start Menu Folder Name $sNAME_Path[3] = 'SAWStudio' ; App Folder Name $sNAME_Path[4] = 'SAWStudio' ; Start Menu Folder Name $sNAME_Path[5] = 'RML' ; App Data Folder Name Global Const $aDirNAME_Path = $sNAME_Path Global Const $sORGAPP_Path = @HomeDrive Global Const $sBACKUP_Path = "D:\Backup" Global Const $sPathDir_BACKUP_Data = $sBACKUP_Path & "\Data" Global Const $sPathDir_BACKUP_App = $sBACKUP_Path & "\Apps" Global Const $sPathDir_BACKUP_Start_Menu = $sBACKUP_Path & "\Start_Menu" Global Const $iSleep_Time = 2500 ; ms Stop Show Result ; ---------------------------------------------------------------------- Global Const $sPathDir_ORG_StartMenuPrograms = @HomeDrive & "\Users\" & $sUserName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs" ; @AppDataDir & "\Microsoft\Windows\Start Menu\Programs" Global $sPathDir_ORG[6] $sPathDir_ORG[0] = 5 $sPathDir_ORG[1] = $sORGAPP_Path & "\" & $aDirNAME_Path[1] $sPathDir_ORG[2] = $sPathDir_ORG_StartMenuPrograms & '\' & $aDirNAME_Path[2] $sPathDir_ORG[3] = $sORGAPP_Path & "\" & $aDirNAME_Path[3] $sPathDir_ORG[4] = $sPathDir_ORG_StartMenuPrograms & '\' & $aDirNAME_Path[4] $sPathDir_ORG[5] = $sPathDir_ORG_StartMenuPrograms & '\' & $aDirNAME_Path[5] Global Const $aPathDir_ORG = $sPathDir_ORG ; ---------------------------------------------------------------------- Global $sPathDir_BACKUP[6] $sPathDir_BACKUP[0] = 5 $sPathDir_BACKUP[1] = $sPathDir_BACKUP_App & "\" & $aDirNAME_Path[1] $sPathDir_BACKUP[2] = $sPathDir_BACKUP_Start_Menu & "\" & $aDirNAME_Path[2] $sPathDir_BACKUP[3] = $sPathDir_BACKUP_App & "\" & $aDirNAME_Path[3] $sPathDir_BACKUP[4] = $sPathDir_BACKUP_Start_Menu & "\" & $aDirNAME_Path[4] $sPathDir_BACKUP[5] = $sPathDir_BACKUP_Data & "\" & $aDirNAME_Path[5] Global Const $aPathDir_BACKUP = $sPathDir_BACKUP ; ---------------------------------------------------------------------- _Remove_RMLData_Backup() _Backup_RMLData() ;_Remove_RMLData_AppDir() ;_Restore_RMLData() ; ----------------------------------------------- Func _Backup_RMLData() ; ----------------------------------------------- Local $sResult, $iResult = 0, $sMessage = "Backup data..." & @CRLF & @CRLF ; ----------------------------------------------- For $i = 1 To $aPathDir_ORG[0] ToolTip('> COPY: ' & $aPathDir_ORG[$i] & ' -> TO: ' & $aPathDir_BACKUP[$i], (@DesktopWidth / 2) - 50, 5, 'Backing up data [' & $i & '/' & $aPathDir_ORG[0] & '] please wait...') ConsoleWrite('> COPY: ' & $aPathDir_ORG[$i] & ' (FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF) ConsoleWrite('- TO: ' & $aPathDir_BACKUP[$i] & ' (FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF) ConsoleWrite('! Please wait: Copying ....' & @CRLF) If Not FileExists($aPathDir_BACKUP[$i]) Then DirCreate($aPathDir_BACKUP[$i]) If FileExists($aPathDir_ORG[$i]) Then $sResult = DirCopy($aPathDir_ORG[$i], $aPathDir_BACKUP[$i], $FC_OVERWRITE) Else $sResult = 0 EndIf Switch $sResult Case 0 ConsoleWrite('!> Result (0): ERROR: Data was not backed-up! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF) $sResult = "[" & $aDirNAME_Path[$i] & "] ERROR: Data was not backed up" Case 1 $iResult += 1 ConsoleWrite('-> Result (1): The data WAS backed-up successfully! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF) $sResult = "[" & $aDirNAME_Path[$i] & "] The data WAS backed-up successfully!" EndSwitch ; ----------------- $sMessage &= $sResult & @CRLF $sResult = '' ToolTip('') Next ToolTip('') ; ----------------------------------------------- $sMessage &= @CRLF & "The Backup of data completed..." & @CRLF ; ----------------------------------------------- ToolTip($sMessage, (@DesktopWidth / 2) - 50, 5, "NOTICE!!", 1) Sleep($iSleep_Time) ToolTip('') $sResult = $aPathDir_ORG[0] - $iResult If ($sResult < 1) Then ConsoleWrite('+> The data WAS backed-up successfully!' & @CRLF) Return True Else ConsoleWrite('!> ERROR: Data was not backed-up!' & @CRLF) Return False EndIf ; ----------------------------------------------- EndFunc ;==>_Backup_RMLData ; ----------------------------------------------- Func _Restore_RMLData() ; ----------------------------------------------- Local $sResult, $iResult = 0, $sMessage = "Restore data..." & @CRLF & @CRLF ; ----------------------------------------------- For $i = 1 To $aPathDir_BACKUP[0] ToolTip('> COPY: ' & $aPathDir_BACKUP[$i] & ' -> TO: ' & $aPathDir_ORG[$i], (@DesktopWidth / 2) - 50, 5, 'Restoring data [' & $i & '/' & $aPathDir_BACKUP[0] & '] please wait...') ConsoleWrite('- COPY: ' & $aPathDir_BACKUP[$i] & ' (FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF) ConsoleWrite('> TO: ' & $aPathDir_ORG[$i] & ' (FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF) ConsoleWrite('! Please wait: Copying ....' & @CRLF) If Not FileExists($aPathDir_ORG[$i]) Then DirCreate($aPathDir_ORG[$i]) If FileExists($aPathDir_BACKUP[$i]) Then $sResult = DirCopy($aPathDir_BACKUP[$i], $aPathDir_ORG[$i], $FC_OVERWRITE) Else $sResult = 0 EndIf Switch $sResult Case 0 ConsoleWrite('+> Result (0): ERROR: Data not restored! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF) $sResult = "[" & $aDirNAME_Path[$i] & "] ERROR: Data not restored!" Case 1 $iResult += 1 ConsoleWrite('+> Result (1): Data restored successfully! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF) $sResult = "[" & $aDirNAME_Path[$i] & "] Data restored successfully!" EndSwitch ; ----------------- $sMessage &= $sResult & @CRLF $sResult = '' ToolTip('') Next ToolTip('') ; ----------------------------------------------- $sMessage &= @CRLF & "Data recovery completed." & @CRLF ; ----------------------------------------------- ToolTip($sMessage, (@DesktopWidth / 2) - 50, 5, "NOTICE!!", 1) Sleep($iSleep_Time) ToolTip('') $sResult = $aPathDir_ORG[0] - $iResult If ($sResult < 1) Then ConsoleWrite('+> Data restored successfully!' & @CRLF) Return True Else ConsoleWrite('!> ERROR: Data not restored!' & @CRLF) Return False EndIf EndFunc ;==>_Restore_RMLData ; ----------------------------------------------- Func _Remove_RMLData_Backup() ; ----------------------------------------------- Local $sResult, $iResult = 0, $sMessage = "Remove data..." & @CRLF & @CRLF ; ----------------------------------------------- For $i = 1 To $aPathDir_BACKUP[0] ToolTip('> Remove: ' & $aPathDir_BACKUP[$i], (@DesktopWidth / 2) - 50, 5, 'Removing data [' & $i & '/' & $aPathDir_BACKUP[0] & '] please wait...') ConsoleWrite('! Remove: ' & $aPathDir_BACKUP[$i] & ' (FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF) ConsoleWrite('- Please wait: removing...' & @CRLF) If FileExists($aPathDir_BACKUP[$i]) Then $sResult = DirRemove($aPathDir_BACKUP[$i], $DIR_REMOVE) Else $sResult = 1 EndIf Switch $sResult Case 0 ConsoleWrite('+> Result (0): ERROR: Data not Removed! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF) $sResult = "[" & $aDirNAME_Path[$i] & "] ERROR: Data not Removed!" Case 1 $iResult += 1 ConsoleWrite('+> Result (1): Data Removed successfully! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_BACKUP[$i]) & ') ' & @CRLF) $sResult = "[" & $aDirNAME_Path[$i] & "] Data Removed successfully!" EndSwitch ; ----------------- $sMessage &= $sResult & @CRLF $sResult = '' ToolTip('') Next ToolTip('') ; ----------------------------------------------- $sMessage &= @CRLF & "Data Removal Completed." & @CRLF ; ----------------------------------------------- ToolTip($sMessage, (@DesktopWidth / 2) - 50, 5, "NOTICE!!", 1) Sleep($iSleep_Time) ToolTip('') $sResult = $aPathDir_ORG[0] - $iResult If ($sResult < 1) Then ConsoleWrite('+> Data Removed successfully!' & @CRLF) Return True Else ConsoleWrite('!> ERROR: Data not Removed!' & @CRLF) Return False EndIf EndFunc ;==>_Remove_RMLData_Backup ; ----------------------------------------------- Func _Remove_RMLData_AppDir() ; ----------------------------------------------- Local $sResult, $iResult = 0, $sMessage = "Remove data..." & @CRLF & @CRLF ; ----------------------------------------------- For $i = 1 To $aPathDir_ORG[0] ToolTip('> Remove: ' & $aPathDir_ORG[$i], (@DesktopWidth / 2) - 50, 5, 'Removing data [' & $i & '/' & $aPathDir_ORG[0] & '] please wait...') ConsoleWrite('!> Remove: ' & $aPathDir_ORG[$i] & ' (FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF) ConsoleWrite('- Please wait: removing ....' & @CRLF) If FileExists($aPathDir_ORG[$i]) Then $sResult = DirRemove($aPathDir_ORG[$i], $DIR_REMOVE) Else $sResult = 1 EndIf Switch $sResult Case 0 ConsoleWrite('+> Result (0): ERROR: Data not Removed! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF) $sResult = "[" & $aDirNAME_Path[$i] & "] ERROR: Data not Removed!" Case 1 $iResult += 1 ConsoleWrite('+> Result (1): Data Removed successfully! (' & $aDirNAME_Path[$i] & ' - FileExists: ' & FileExists($aPathDir_ORG[$i]) & ') ' & @CRLF) $sResult = "[" & $aDirNAME_Path[$i] & "] Data Removed successfully!" EndSwitch ; ----------------- $sMessage &= $sResult & @CRLF $sResult = '' ToolTip('') Next ToolTip('') ; ----------------------------------------------- $sMessage &= @CRLF & "Data Removal Completed." & @CRLF ; ----------------------------------------------- ToolTip($sMessage, (@DesktopWidth / 2) - 50, 5, "NOTICE!!", 1) Sleep($iSleep_Time) ToolTip('') $sResult = $aPathDir_ORG[0] - $iResult If ($sResult < 1) Then ConsoleWrite('+> Data Removed successfully!' & @CRLF) Return True Else ConsoleWrite('!> ERROR: Data not Removed!' & @CRLF) Return False EndIf EndFunc ;==>_Remove_RMLData_AppDir ; -----------------------------------------------1 point