BigDaddyO Posted May 6, 2009 Posted May 6, 2009 (edited) I am using the sample script below for testing. run it once, and it's great, run it a second time and you get prompts to overwrite even though I have set the Yes to All option. Anybody know how I can get it to just overwrite without prompting me? I am getting the same issue on Vista & XP sp2. I have found a bunch of stuff online about this and some say the options don't work, but some seem to have no problems at all. Also, the msdn site says to use &H10& instead of 16 but my script doesn't like that either. _FileCopy(@DesktopDir, 0 , @TempDir & "\TestYestoAll") Func _FileCopy($sSource, $iType, $sTarget) ;if $sSource is a folder than append \*.* to copy the entire contents if $iType = 0 Then $sSource &= "\*.*" EndIf ;Ensure the $sTarget location exists if not FileExists($sTarget) Then DirCreate($sTarget) ;Variables for use with the copy command Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 ;Execute the copy command for this file/folder $winShell = ObjCreate("shell.application") $winShell.namespace($sTarget).CopyHere($sSource,$FOF_RESPOND_YES) EndFunc Edited May 6, 2009 by MikeOsdx
smashly Posted May 6, 2009 Posted May 6, 2009 Hi, Not sure about the Yes To All problem. But the "&H10&" is correct, the H10 means hex value which is equal to 16 ConsoleWrite(Hex(16,2)& @LF)
Zedna Posted May 6, 2009 Posted May 6, 2009 (edited) use &H10& instead of 16Right syntax is: Local $FOF_RESPOND_YES = 0x10 But I think it will be the same. Edited May 6, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted May 6, 2009 Posted May 6, 2009 (edited) I don't know fix for your script but maybe this similar script can be used as workaround: expandcollapse popupGlobal Const $FO_COPY = 0x0002 Global Const $FOF_CONFIRMMOUSE = 0x0002 Global Const $FOF_RENAMEONCOLLISION = 0x0008 Global Const $FOF_NOCONFIRMATION = 0x0010 Global Const $FOF_WANTMAPPINGHANDLE = 0x0020 Global Const $FOF_ALLOWUNDO = 0x0040 Global Const $FOF_FILESONLY = 0x0080 Global Const $FOF_SIMPLEPROGRESS = 0x0100 Global Const $FOF_NOCONFIRMMKDIR = 0x0200 Global Const $FOF_NOERRORUI = 0x0400 Global Const $FOF_NOCOPYSECURITYATTRIBS = 0x0800 Global Const $FOF_NORECURSION = 0x1000 Global Const $FOF_NO_CONNECTED_ELEMENTS = 0x2000 Global Const $FOF_WANTNUKEWARNING = 0x4000 Global Const $FOF_NORECURSEREPARSE = 0x8000 Func _CopyWithProgress($sFrom, $sTo) Local $SHFILEOPSTRUCT, $pFrom, $pTo, $aDllRet, $nError = 0 $SHFILEOPSTRUCT = DllStructCreate("hwnd hwnd;uint wFunc;ptr pFrom;ptr pTo;int fFlags;int fAnyOperationsAborted;ptr hNameMappings;ptr lpszProgressTitle") DllStructSetData($SHFILEOPSTRUCT, "hwnd", 0) DllStructSetData($SHFILEOPSTRUCT, "wFunc", $FO_COPY) $pFrom = DllStructCreate("char[" & StringLen($sFrom)+2 & "]") DllStructSetData($pFrom, 1, $sFrom) DllStructSetData($pFrom, 1, Chr(0), StringLen($sFrom)+2) ; second null at the end DllStructSetData($SHFILEOPSTRUCT, "pFrom", DllStructGetPtr($pFrom)) $pTo = DllStructCreate("char[" & StringLen($sTo)+2 & "]") DllStructSetData($pTo, 1, $sTo) DllStructSetData($pTo, 1, Chr(0), StringLen($sTo)+2) ; second null at the end DllStructSetData($SHFILEOPSTRUCT, "pTo", DllStructGetPtr($pTo)) DllStructSetData($SHFILEOPSTRUCT, "fFlags", BitOR($FOF_NOCONFIRMATION, $FOF_NOERRORUI)) DllStructSetData($SHFILEOPSTRUCT, "fAnyOperationsAborted", 0) DllStructSetData($SHFILEOPSTRUCT, "hNameMappings", 0) DllStructSetData($SHFILEOPSTRUCT, "lpszProgressTitle", 0) $aDllRet = DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($SHFILEOPSTRUCT)) If @error Or $aDllRet[0] <> 0 Then $aDllRet = DllCall("kernel32.dll", "long", "GetLastError") If Not @error Then $nError = $aDllRet[0] EndIf ; test if button Abort was pressed If DllStructGetData($SHFILEOPSTRUCT, "fAnyOperationsAborted") Then $nError = -1 $pFrom = 0 $pTo = 0 $SHFILEOPSTRUCT = 0 If $nError <> 0 Then SetError($nError) Return False EndIf Return True EndFunc Edited May 6, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
BigDaddyO Posted May 6, 2009 Author Posted May 6, 2009 I don't know fix for your script but maybe this similar script can be used as workaround:The Hex value didn't help but this script worked great.one more question though?I am also using .MoveHere with the same problem. Do you have the hex value for $FO_MOVE or a link to a site that contains further info?Thanks,Mike
Zedna Posted May 6, 2009 Posted May 6, 2009 The Hex value didn't help but this script worked great.one more question though?I am also using .MoveHere with the same problem. Do you have the hex value for $FO_MOVE or a link to a site that contains further info?Thanks,MikeMSDNhttp://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspxhttp://msdn.microsoft.com/en-us/library/bb759795(VS.85).aspx#define FO_MOVE 0x0001#define FO_COPY 0x0002#define FO_DELETE 0x0003#define FO_RENAME 0x0004When you need some system constant then use google: define FO_MOVE;-) Resources UDF ResourcesEx UDF AutoIt Forum Search
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