Jump to content

Confirm File Replace


Recommended Posts

As I'm sure some of you have noticed if you try to replace several files at once you get shown a gui that asks you what you want to do... Without making a GUI of my own, would any know how I could just call a .dll function and get shown the Confirm File Replace window... I've included a picture of it.

post-14131-1180411761_thumb.jpg

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Hi,

I don't realy know how to execute this dialog, but while ago i has a need to make my own such dialog, so here it is:

Global Const $COPYANI = 161
Global Const $DELANI = 162
Global Const $CHECKANI = 165
Global Const $WEBSEARCHANI = 166
Global Const $COPYFROMWEBANI = 170


$hWnd = WinGetHandle(WinGetTitle(""))

$Ret = _MsgBoxEx($hWnd, "Confirm replacing...", "Replace this file?" & @LF & "test.zip", $COPYANI)

ConsoleWrite($Ret)

Func _MsgBoxEx($hWnd, $Title="Confirm...", $Promt="", $Animation=0, $OnTop=0)
    Local $OldOptGOEM = Opt("GuiOnEventMode", 0)
    Local $ReturnedValue = 2
    
    WinSetState($hWnd, "", @SW_DISABLE)
    
    Local $MsgBoxHwnd = GUICreate($Title, 400, 240, -1, -1, 0, -1, $hWnd)
    If $OnTop Then WinSetOnTop($MsgBoxHwnd, "", 1)
    
    GUICtrlCreateAvi(@SystemDir & "\Shell32.dll", $Animation, 65, 0)
    GUICtrlSetState(-1, 1)
    
    GUICtrlCreateLabel($Promt, 0, 90, 400, 40, 1)
    
    Local $YesButton = GUICtrlCreateButton("Yes", 20, 150, 60, 20)
    Local $YesForAllButton = GUICtrlCreateButton("Yes for all", 90, 150, 60, 20)
    
    Local $NoButton = GUICtrlCreateButton("No", 170, 150, 60, 20)
    GUICtrlSetState(-1, 512)
    
    Local $NoForAllButton = GUICtrlCreateButton("No for all", 240, 150, 60, 20)
    
    Local $CancelButton = GUICtrlCreateButton("Cancel", 320, 150, 60, 20)
    
    Local $AutoBackupFilesButton = GUICtrlCreateButton("AutoBackup Existing Files", 20, 180, 150, 20)
    
    GUISetState()
    
    While 1
        $GetMsg = GUIGetMsg()
        Switch $GetMsg
            Case $YesButton
                $ReturnedValue = 6
                ExitLoop
            Case $YesForAllButton
                $ReturnedValue = 12
                ExitLoop
            Case $NoButton
                $ReturnedValue = 7
                ExitLoop
            Case $NoForAllButton
                $ReturnedValue = 14
                ExitLoop
            Case $CancelButton
                $ReturnedValue = 2
                ExitLoop
            Case $AutoBackupFilesButton
                $ReturnedValue = 10
                ExitLoop
        EndSwitch
    WEnd
    
    WinSetState($hWnd, "", @SW_ENABLE)
    GUIDelete($MsgBoxHwnd)
    Opt("GuiOnEventMode", $OldOptGOEM)
    Return $ReturnedValue
EndFunc

Returned values:

"Cancel" pressed: 2

"No" pressed (default button): 7

"No for all" pressd: 14

"Yes" pressed: 6

"Yes for all" pressed: 12

"Autobackup" pressed: 10

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

I found this a while ago , but I don't have a link to the original thread I found it in..

Hope JdeB doesn't mind me posting his efforts..

; Windows - copy with progress
; Author - JdeB

;~ 4 Do not display a progress dialog box.  
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.  
;~ 16 Respond with "Yes to All" for any dialog box that is displayed.  
;~ 64 Preserve undo information, if possible.
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.  
;~ 256 Display a progress dialog box but do not show the file names.  
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.  
;~ 1024 Do not display a user interface if an error occurs.  
;~ 2048 Version 4.71. Do not copy the security attributes of the file.
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories.
;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.  

_FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")

Func _FileCopy($fromFile,$tofile)
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)
EndFuncoÝ÷ Ù:^+zZqæ§jZÞiÜÆ+-xW­éëzj/{MúáQ#Î46IúèØ^)^
r~éܶ*'z®¶­sbb33c·vå6VÆÂææÖW76Rb33c·FöfÆRä6÷W&Rb33c¶g&öÔfÆR

Cheers

Edited by smashly
Link to comment
Share on other sites

I found this a while ago

Wow, it's great!

Maby it is possible to add support for multiple files copy?

I have tried like this:

_FileCopy("C:\test.txt|C:\test2.txt", "C:\test\")oÝ÷ Ø­¶¬Éè·
+°S[öÌ¢ø§+Ê)¢Ë"nW°Øm+&zØhu«­¢+ÙÕ¹}¥±5½Ù ÀÌØíɽµ¥±°ÀÌØíQ½¥±¤(1½°ÀÌØí=}IMA=9}eLôÄØ(1½°ÀÌØí=}M%5A1AI=IMLôÈÔØ(ÀÌØí]¥¹M¡±°ô=©
ÉÑ ÅÕ½ÐíÍ¡±°¹ÁÁ±¥Ñ¥½¸ÅÕ½Ðì¤(ÀÌØí]¥¹M¡±°¹9µMÁ ÀÌØíQ½¥±¤¹5½Ù!É ÀÌØíɽµ¥±¤)¹Õ¹
Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 1 year later...

Did you ever find a solution to your question?

Try this:

Global Const $FO_COPY = 0x0002
Global Const $FOF_ALLOWUNDO = 0x0040


_ExplorerCopy("d:\Video\Clips\New\02.avi|d:\Video\Clips\New\03.avi", "C:\")

Func _ExplorerCopy($source, $dest)
    Local $SHFILEOPSTRUCT, $aFiles, $SourceStruct, $DestStruct, $iSourceList, $iLen
    
    $SHFILEOPSTRUCT = DllStructCreate("hwnd hWnd;uint wFunc;ptr pFrom;ptr pTo;int fFlags;" & _
                                      "int fAnyOperationsAborted;ptr hNameMappings;ptr lpszProgressTitle")
    
    $aFiles = StringSplit($source, "|")
    
    For $i = 1 To $aFiles[0]
        $iSourceList &= $aFiles[$i] & Chr(0)
    Next
    
    $iSourceList &= Chr(0) & Chr(0)
    
    $iSourceList = StringToBinary($iSourceList)
    
    $iLen = BinaryLen($iSourceList)
    
    $SourceStruct = DllStructCreate("byte[" & $iLen & "]")
    
    DllStructSetData($SourceStruct, 1, $iSourceList)

    $DestStruct = DllStructCreate("char[" & StringLen($dest) + 2 & "]")
    DllStructSetData($DestStruct, 1, $dest)
    DllStructSetData($DestStruct, 1, 0, StringLen($dest) + 1)
    DllStructSetData($DestStruct, 1, 0, StringLen($dest) + 2)

    DllStructSetData($SHFILEOPSTRUCT, "hWnd", 0)
    DllStructSetData($SHFILEOPSTRUCT, "wFunc", $FO_COPY)
    DllStructSetData($SHFILEOPSTRUCT, "pFrom", DllStructGetPtr($SourceStruct))
    DllStructSetData($SHFILEOPSTRUCT, "pTo", DllStructGetPtr($DestStruct))
    DllStructSetData($SHFILEOPSTRUCT, "fFlags", $FOF_ALLOWUNDO)
    
    DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($SHFILEOPSTRUCT))
EndFunc   ;==>_ExplorerCopy

;)

Link to comment
Share on other sites

Try this:

Thanks -

just need to change

DllStructSetData($SHFILEOPSTRUCT, "fFlags", $FOF_ALLOWUNDO)

to

DllStructSetData($SHFILEOPSTRUCT, "fFlags", $FOF_NOCONFIRMATION)

and add of course

Global Const $FOF_NOCONFIRMATION        = 0x0010       ; Respond with "Yes to All" for any dialog box that is displayed.

so that you do not get any messages during the copy.

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