Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/13/2014 in all areas

  1. The function returns a collection of objects, so I wouldn't expect the MsgBox to show anything. Suggest that you reexamine the help file, specifically the For...Next section of the example.
    1 point
  2. Melba23

    example method 3

    EMadxcs, Are you just trolling? Because it is certainly beginning to look like that! I mentioned in post #12 above that you needed all the files in the same folder to use that line. JohnOne also posted (in post #15) that you might need the full path to Aut2Exe - from what we see there that is almost certainly the case. So assuming that you installed AutoIt in the standard location try this: "C:\Program Files\AutoIt3\Aut2Exe\Aut2exe.exe" /in mycript.au3 /out eee.exe And while we are here, why are you compiling from the command line anyway? There is a good reason why that is Method 3 - the others are much easier to use. M23
    1 point
  3. leuce, I would create an array holding 1-9 and then shuffle it - looping from 1 to 9 now will produce those values in a random order. Here is an example using the _ArrayShuffle function that will be in the next AutoIt release: #include <Array.au3> Global $aArray[10] For $i = 1 To 9 $aArray[$i] = $i Next _ArrayDisplay($aArray, "Default", Default, 8) _ArrayShuffle($aArray, 1, 0) _ArrayDisplay($aArray, "Shuffled", Default, 8) Func _ArrayShuffle(ByRef $avArray, $iStart_Row = 0, $iEnd_Row = 0, $iCol = 0) ; Fisher–Yates algorithm If $iStart_Row = Default Then $iStart_Row = 0 If $iEnd_Row = Default Then $iEnd_Row = 0 If $iCol = Default Then $iCol = 0 If Not IsArray($avArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($avArray, $UBOUND_ROWS) If $iEnd_Row = 0 Then $iEnd_Row = $iDim_1 - 1 If $iStart_Row < 0 Or $iStart_Row > $iDim_1 - 1 Then Return SetError(3, 0, -1) If $iEnd_Row < 1 Or $iEnd_Row > $iDim_1 - 1 Then Return SetError(3, 0, -1) If $iStart_Row > $iEnd_Row Then Return SetError(4, 0, -1) Local $vTmp, $iRand Switch UBound($avArray, $UBOUND_DIMENSIONS) Case 1 For $i = $iEnd_Row To $iStart_Row + 1 Step -1 $iRand = Random($iStart_Row, $i, 1) $vTmp = $avArray[$i] $avArray[$i] = $avArray[$iRand] $avArray[$iRand] = $vTmp Next Return 1 Case 2 Local $iDim_2 = UBound($avArray, $UBOUND_COLUMNS) If $iCol < 0 Or $iCol > $iDim_2 - 1 Then Return SetError(5, 0, -1) Local $iCol_Start, $iCol_End If $iCol Then $iCol_Start = $iCol $iCol_End = $iCol Else $iCol_Start = 0 $iCol_End = $iDim_2 - 1 EndIf For $i = $iEnd_Row To $iStart_Row + 1 Step -1 $iRand = Random($iStart_Row, $i, 1) For $j = $iCol_Start To $iCol_End $vTmp = $avArray[$i][$j] $avArray[$i][$j] = $avArray[$iRand][$j] $avArray[$iRand][$j] = $vTmp Next Next Return 1 Case Else Return SetError(2, 0, -1) EndSwitch EndFunc ;==>_ArrayShuffle That should do the trick for you. M23
    1 point
  4. czardas

    Snippet Dump

    Work in progress - Store guitar fingerings (within a 5 fret stretch) using base 36. Open strings may, or may not, be muted. Example: JLZ 313355 |•|||| |||||| •|••|| |||||| ||||•• ; MsgBox(0, "", _Base36ToTAB("JLZ")) ; 313355 ; Convert 6 digit Guitar TAB to 3 base 36 characters [0-9A-Z] Func _TABToBase36($sChordTAB) Static $a36 = _Base36() Local $aFingers = _StringEqualSplit($sChordTAB, 2) ; Split TAB to 3 equal length segments Local $sBase36 = "" For $i = 0 To 2 $sBase36 &= $a36[_BaseToDec($aFingers[$i], 6)] Next Return $sBase36 EndFunc ; Convert 3 base 36 characters [0-9A-Z] to 6 digit Guitar TAB Func _Base36ToTAB($sBase36) Local $sNextChar, $sChordTAB For $i = 1 To 3 $sNextChar = StringMid($sBase36, $i, 1) If StringIsAlpha($sNextChar) Then $sNextChar = Asc(StringUpper($sNextChar)) -55 $sNextChar = _DecToBase($sNextChar, 6) If $sNextChar < 6 Then $sNextChar = "0" & $sNextChar $sChordTAB &= $sNextChar Next Return $sChordTAB EndFunc Func _BaseToDec($vNumber, $iBase) Local $bNegative = False If StringLeft($vNumber, 1) = "-" Then $vNumber = StringTrimLeft($vNumber, 1) $bNegative = True EndIf Local $iNewNumber = 0, $sLen = StringLen($vNumber) For $i = 1 To $sLen $iNewNumber += $iBase^($i -1)*(Dec(StringMid($vNumber, $sLen -$i +1, 1))) Next If $bNegative Then $iNewNumber = -$iNewNumber Return $iNewNumber EndFunc ;==> _BaseToDec Func _DecToBase($iDecimal, $iBase) Local $sNewNumber, $iDigit, $iPower = 1, $bNegative = False If $iDecimal < 0 Then $bNegative = True $iDecimal = Abs($iDecimal) EndIf While $iBase^$iPower <= $iDecimal $iPower += 1 WEnd For $i = $iPower -1 To 0 Step -1 $iDigit = Floor($iDecimal/($iBase^$i)) $sNewNumber &= StringRight(Hex($iDigit), 1) $iDecimal -= $iDigit*($iBase^($i)) Next If $bNegative Then $sNewNumber = "-" & $sNewNumber Return $sNewNumber EndFunc ;==> _DecToBase ; Splits a string into equal length segments ==> czardas Func _StringEqualSplit($sString, $iNumChars) Return StringRegExp($sString, "(?s).{1," & $iNumChars & "}", 3) EndFunc ; _StringEqualSplit ; Create a 36 element array of values 0-Z Func _Base36() Local $a36[36] For $i = 0 To 9 $a36[$i] = $i Next For $i = 10 To 35 $a36[$i] = Chr($i +55) Next Return $a36 EndFunc ; Some error checks will be removed for optimization. The system only stores guitar fingerings and is intended purely as a form of compression. Simple yet effective!
    1 point
  5. water

    Gui to mail

    Looks like you use Outlook to send the mail. You could have a look at my OutlookEX UDF.
    1 point
  6. Melba23

    Help with ER

    avechuche, This seems to work: $sList = "blah q^q blah" & @CRLF & _ "blah pp blah" & @CRLF & _ "blah a^b blah" & @CRLF & _ "blah cd blah" $sNewList = StringRegExpReplace($sList, "(.)(\^)?(\1)", "$1") ConsoleWrite($sNewList & @CRLF) SRER decode: (.) - Capture a character (\^)? - There might be an optional ^ (\1) - Is it the same character again? $1 - If it was, then replace the whole lot by the single character Any use? M23
    1 point
  7. Maybe you could hire the A-Team.
    1 point
  8. JohnOne

    example method 3

    Aut2exe.exe /in mycript.au3
    1 point
  9. ValeryVal

    XDrop

    XDrop v0.16 (14/03/2005) --------------------------------------- XDrop it's a color manager/administrator which it allows easily capture it, store or use the info about a color. --------------------------------------- See "Readme_XDrop.txt" for more details. © 2004-2005. Josuй Sierra (Josbe - jzcript@yahoo.com) xdrop_0.16_src.zip
    1 point
  10. gottygolly, I presume the idea is to have a random "enabled" button when you stop - so this should work: #include <GUIConstantsEx.au3> $gui = GUICreate("", 200, 100) $b1 = GUICtrlCreateButton("Button 1", 0, 0, 100, 30) $b2 = GUICtrlCreateButton("Button 2", 100, 0, 100, 30) $start = GUICtrlCreateButton("Start", 0, 50, 100, 30) $stop = GUICtrlCreateButton("Stop", 100, 50, 100, 30) GUICtrlSetState($b1, $GUI_DISABLE) GUISetState() While 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $gui Switch $msg[0] Case $GUI_EVENT_CLOSE Exit Case $start While 1 GUICtrlSetState($b1, $GUI_DISABLE) GUICtrlSetState($b2, $GUI_ENABLE) If _Check(200) Then ExitLoop GUICtrlSetState($b1, $GUI_ENABLE) GUICtrlSetState($b2, $GUI_DISABLE) If _Check(200) Then ExitLoop WEnd EndSwitch EndSwitch WEnd Func _Check($iDelay) $nBegin = TimerInit() Do Switch GUIGetMsg() Case $stop Return 1 EndSwitch Until TimerDiff($nBegin) > $iDelay Return 0 EndFunc M23
    1 point
  11. 1 point
  12. Try this: #include <Array.au3> $sHost = @ComputerName $aNetworkAdapters = WMI_ListAllNetworkAdapters($sHost) _ArrayDisplay($aNetworkAdapters) Func WMI_ListAllNetworkAdapters($sHost) ;coded by UEZ 2013 Local $objWMIService = ObjGet("winmgmts:\\" & $sHost & "\root\cimv2") If @error Then Return SetError(1, 0, 0) Local $aStatus[13] = ["Disconnected", "Connecting", "Connected", "Disconnecting", "Hardware not present", "Hardware disabled", "Hardware malfunction", _ "Media Disconnected", "Authenticating", "Authentication Succeeded", "Authentication Failed", "Invalid Address", "Credentials Required"] $colItems = $objWMIService.ExecQuery("SELECT Name, NetConnectionID, NetConnectionStatus FROM Win32_NetworkAdapter", "WQL", 0x30) Local $aNetworkAdapters[1000][3], $i = 0, $iPointer If IsObj($colItems) Then For $objItem in $colItems With $objItem $aNetworkAdapters[$i][0] = .NetConnectionID $aNetworkAdapters[$i][1] = .Name $aNetworkAdapters[$i][2] = $aStatus[.NetConnectionStatus * 1] EndWith $i += 1 Next ReDim $aNetworkAdapters[$i][3] Return $aNetworkAdapters Else Return SetError(2, 0, 0) EndIf EndFunc Br, UEZ
    1 point
  13. SkellySoul

    Nice GUI

    Hey. I was going to name the title of this post "Steam GUI" but I didn't think it would get much attention considering this isnt new and it has been done by many before me and even I have made a previous one. Anyways here yet again is a Steam GUI look without using any files. This GUI is even pretty customizable try playing with "$Width" and "$Height", "$Steam_Arm_X" and also disable this function "_Steam_Extension" to see the GUI compared to the final product. The reason I did this is boredom but also to show people that it doesnt take much to have a professional look...although not everyone likes the steam look. Anyways Enjoy #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "_Exit") $Width = 800 $Height = 600 _Steam("Steam - " & @ComputerName, $Width, $Height, Default, Default) While 1 Sleep(1000) WEnd Func _Steam($sTitle, $sWidth, $sHeight, $sX, $sY) ;;; Steam Window Start ;;; $Steam_Win = GUICreate($sTitle, $sWidth, $sHeight, $sX, $sY , $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetFont(8, 400, 0, "Tahoma") GUISetBkColor(0x464646) ;;; Steam Window End ;;; ;;; Steam Title Bar Start ;;; $Bar = GUICtrlCreateLabel($sTitle , 0 , 0 , $sWidth - 20, 20 , $SS_NOTIFY , $GUI_WS_EX_PARENTDRAG) GUICtrlSetFont($Bar, 10, 400, 0, "Tahoma") ; Bold GUICtrlSetColor($Bar , 0xD8DED3) GUICtrlSetBkColor($Bar , 0x5A6A50) ;;; Steam Title Bar End ;;; ;;; Steam Title Exit Start ;;; $Exit = GUICtrlCreateLabel("X" , $sWidth - 20 , 0 , 20 , 20 , $SS_CENTER) GUICtrlSetFont($Exit, 10, 800, 0, "Tahoma") ; Bold GUICtrlSetColor($Exit , 0xD8DED3) GUICtrlSetBkColor($Exit, 0x5A6A50) ;;; Steam Title Exit End ;;; _Steam_Extension($Width, $Height) ; Create Full GUI GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $Exit Exit EndSwitch WEnd EndFunc Func _Steam_Extension($eWidth, $eHeight) $Steam_Arm_X = 200 ; This adjusts the Arms Width $Steam_Arm_Y = 20 ; This really shouldn't be played with... ;;; Steam Arm Start ;;; $Arm = GUICtrlCreateGraphic($Steam_Arm_X, $Steam_Arm_Y, $eWidth - $Steam_Arm_X, $eHeight - $Steam_Arm_Y) GUICtrlSetBkColor($Arm, 0x494E48) GUICtrlSetState($Arm, $GUI_DISABLE) ;;; Steam Arm End ;;; ;;; Steam Test Buttons ;;; $z = 30 For $i = 0 To 5 Step +1 GUICtrlCreateButton("Button " & $i, 10, $z, $Steam_Arm_X - $Steam_Arm_Y, 20) $z += 30 Next ;;; Steam Test Buttons ;;; ;;; Steam Border Start ;;; $Border = GUICtrlCreateGraphic($Steam_Arm_X + 10, 30, $eWidth - $Steam_Arm_X - $Steam_Arm_Y, $eHeight - $Steam_Arm_Y - $Steam_Arm_Y) $Header = GUICtrlCreateGraphic($Steam_Arm_X + 10, 30, $eWidth - $Steam_Arm_X - $Steam_Arm_Y, 20) GUICtrlSetColor($Border, 0x696A65) GUICtrlSetColor($Header, 0x696A65) GUICtrlSetState($Border, $GUI_DISABLE) GUICtrlSetState($Header, $GUI_DISABLE) ;;; Steam Border End ;;; ;;; Steam Sample Text Start ;;; $Text = GUICtrlCreateLabel("HEADER TEXT", 220, 35, 200, 20) GUICtrlSetColor($Text, 0xC3B54C) GUICtrlSetBkColor($Text, $GUI_BKCOLOR_TRANSPARENT) ;;; Steam Sample Text End ;;; ;;; Steam Sample Control ;;; GUICtrlCreateInput("", 220, 60, 100, 20) ;;; 220x60 is where controls should start. ;;; Steam Sample Control ;;; EndFunc Func _Exit() Exit EndFunc
    1 point
  14. Try this UDF...you can specify destination file name for copies also. (put @LF in b/w multiple sources) Just call _ExplorerCopy($source, $dest, [bitOr($Option1,$Option2)] ) ; see Options at top of UDF file The returns aren't as predictable as I would like them to be, but I'll look into it later. *Requires Beta* -Livewire Global Const $FO_COPY = 0x0002 ; Copies the files specified in pFrom to the location specified in pTo Global Const $FO_DELETE = 0x0003 ; Deletes the files specified in pFrom (pTo is ignored) Global Const $FO_MOVE = 0x0001 ; Moves the files specified in pFrom to the location specified in pTo Global Const $FO_RENAME = 0x0004 ; Renames the files specified in pFrom Global Const $FOF_ALLOWUNDO = 0x0040 ; Preserve Undo information, if possible Global Const $FOF_CONFIRMMOUSE = 0x0002 ; Not currently implemented Global Const $FOF_FILESONLY = 0x0080 ; Perform the operation on files only if a wildcard file name (*.*) is specified. Global Const $FOF_MULTIDESTFILES = 0x0001 ; The pTo member specifies multiple destination files (one for each sourcr file) ; rather than one directory where all source files are to be deposited. Global Const $FOF_NOCONFIRMATION = 0x0010 ; Respond with "Yes to All" for any dialog box that is displayed. Global Const $FOF_NOCONFIRMMKDIR = 0x0200 ; Does not confirm the creation of a new directory if the operation requires one to be created. Global Const $FOF_NOCOPYSECURITYATTRIBS = 0x0800 ; Do not copy NT file Security Attributes Global Const $FOF_NOERRORUI = 0x0400 ; No user interface will be displayed if an error occurs Global Const $FOF_NORECURSION = 0x1000 ; Do not recurse directories (i.e. no recursion into subdirectories) Global Const $FOF_RENAMEONCOLLISION = 0x0008 ; Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exisits. Global Const $FOF_SILENT = 0x0004 ; Does not display a progress dialog box Global Const $FOF_SIMPLEPROGRESS = 0x0100 ; Displays a progress box but does not show the file names Global Const $FOF_WANTMAPPINGHANDLE = 0x0020 ; If $FOF_RENAMEONCOLLISION is specified, the hNameMappings member will be filled in if any files were renamed ; These two apply in Internet Explorer 5 Environments Global Const $FOF_NO_CONNECTED_ELEMENTS = 0x2000 ; Do not operate on connected elements Global Const $FOF_WANTNUKEWARNING = 0x4000 ; During delete operations, warn if permanent deleting instead of placing in recycle bin (partially overrides $FOF_NOCONFIRMATION) ; ???? Global Const $FOF_NORECURSEREPARSE = 0x8000 ; ;$n = _CopyWithProgress("C:\Documents and Settings\All Users\Documents\shared\04.jpg" @LF & "C:\Documents and Settings\All Users\Documents\shared\11.jpg", "C:\Documents and Settings\Livewire\Desktop") ;MsgBox(0,"Testing","Success = " & $n) Func _ExplorerCopy($source, $dest, $Options = 0) Local $SHFILEOPSTRUCT, $source_struct, $dest_struct Local $i, $aDllRet Local Enum $hwnd = 1, $wFunc, $pFrom, $pTo, $fFlags, $fAnyOperationsAborted, $hNameMappings, $lpszProgressTitle $SHFILEOPSTRUCT = DllStructCreate("int;uint;ptr;ptr;uint;int;ptr;ptr") If @error Then MsgBox(4096,"ERROR","Error creating SHFILEOPSTRUCT structure") Return False EndIf $source_struct = DllStructCreate("char[" & StringLen($source)+2 & "]") DllStructSetData($source_struct, 1, $source) For $i = 1 To StringLen($source)+2 If DllStructGetData($source_struct, 1, $i) = 10 Then DllStructSetData($source_struct, 1, 0, $i) Next DllStructSetData($source_struct, 1, 0, StringLen($source)+2) $dest_struct = DllStructCreate("char[" & StringLen($dest)+2 & "]") DllStructSetData($dest_struct, 1, $dest) DllStructSetData($dest_struct, 1, 0, StringLen($dest)+2) DllStructSetData($SHFILEOPSTRUCT, $hwnd, 0) DllStructSetData($SHFILEOPSTRUCT, $wFunc, $FO_COPY) DllStructSetData($SHFILEOPSTRUCT, $pFrom, DllStructGetPtr($source_struct)) DllStructSetData($SHFILEOPSTRUCT, $pTo, DllStructGetPtr($dest_struct)) DllStructSetData($SHFILEOPSTRUCT, $fFlags, $Options) DllStructSetData($SHFILEOPSTRUCT, $fAnyOperationsAborted, 0) DllStructSetData($SHFILEOPSTRUCT, $hNameMappings, 0) DllStructSetData($SHFILEOPSTRUCT, $lpszProgressTitle, 0) If _SHFileOperation($SHFILEOPSTRUCT) Then $aDllRet = DllCall("kernel32.dll", "long", "GetLastError") If @error Then MsgBox(4096,"Error","Error calling GetLastError") SetError($aDllRet[0]) Return False ElseIf DllStructGetData($SHFILEOPSTRUCT,$fAnyOperationsAborted) Then MsgBox(0,"Testing","Operation aborted") Return False EndIf Return True EndFunc Func _ExplorerMove($source, $dest, $Options = 0) Local $SHFILEOPSTRUCT, $source_struct, $dest_struct Local $i, $aDllRet Local Enum $hwnd = 1, $wFunc, $pFrom, $pTo, $fFlags, $fAnyOperationsAborted, $hNameMappings, $lpszProgressTitle $SHFILEOPSTRUCT = DllStructCreate("int;uint;ptr;ptr;uint;int;ptr;ptr") If @error Then MsgBox(4096,"ERROR","Error creating SHFILEOPSTRUCT structure") Return False EndIf $source_struct = DllStructCreate("char[" & StringLen($source)+2 & "]") DllStructSetData($source_struct, 1, $source) For $i = 1 To StringLen($source)+2 If DllStructGetData($source_struct, 1, $i) = 10 Then DllStructSetData($source_struct, 1, 0, $i) Next DllStructSetData($source_struct, 1, 0, StringLen($source)+2) $dest_struct = DllStructCreate("char[" & StringLen($dest)+2 & "]") DllStructSetData($dest_struct, 1, $dest) DllStructSetData($dest_struct, 1, 0, StringLen($dest)+2) DllStructSetData($SHFILEOPSTRUCT, $hwnd, 0) DllStructSetData($SHFILEOPSTRUCT, $wFunc, $FO_MOVE) DllStructSetData($SHFILEOPSTRUCT, $pFrom, DllStructGetPtr($source_struct)) DllStructSetData($SHFILEOPSTRUCT, $pTo, DllStructGetPtr($dest_struct)) DllStructSetData($SHFILEOPSTRUCT, $fFlags, $Options) DllStructSetData($SHFILEOPSTRUCT, $fAnyOperationsAborted, 0) DllStructSetData($SHFILEOPSTRUCT, $hNameMappings, 0) DllStructSetData($SHFILEOPSTRUCT, $lpszProgressTitle, 0) If _SHFileOperation($SHFILEOPSTRUCT) Then $aDllRet = DllCall("kernel32.dll", "long", "GetLastError") If @error Then MsgBox(4096,"Error","Error calling GetLastError") SetError($aDllRet[0]) Return False ElseIf DllStructGetData($SHFILEOPSTRUCT,$fAnyOperationsAborted) Then MsgBox(0,"Testing","Operation aborted") Return False EndIf Return True EndFunc Func _ExplorerDelete($path, $Options = 0) Local $SHFILEOPSTRUCT, $path_struct Local $nError = 0 Local $i Local Enum $hwnd = 1, $wFunc, $pFrom, $pTo, $fFlags, $fAnyOperationsAborted, $hNameMappings, $lpszProgressTitle $SHFILEOPSTRUCT = DllStructCreate("int;uint;ptr;ptr;uint;int;ptr;ptr") If @error Then MsgBox(4096,"ERROR","Error creating SHFILEOPSTRUCT structure") Return False EndIf $path_struct = DllStructCreate("char[" & StringLen($path)+2 & "]") DllStructSetData($path_struct, 1, $path) For $i = 1 To StringLen($path)+2 If DllStructGetData($path_struct, 1, $i) = 10 Then DllStructSetData($path_struct, 1, 0, $i) Next DllStructSetData($path_struct, 1, 0, StringLen($path)+2) DllStructSetData($SHFILEOPSTRUCT, $hwnd, 0) DllStructSetData($SHFILEOPSTRUCT, $wFunc, $FO_DELETE) DllStructSetData($SHFILEOPSTRUCT, $pFrom, DllStructGetPtr($path_struct)) DllStructSetData($SHFILEOPSTRUCT, $pTo, 0) DllStructSetData($SHFILEOPSTRUCT, $fFlags, $Options) DllStructSetData($SHFILEOPSTRUCT, $fAnyOperationsAborted, 0) DllStructSetData($SHFILEOPSTRUCT, $hNameMappings, 0) DllStructSetData($SHFILEOPSTRUCT, $lpszProgressTitle, 0) If _SHFileOperation($SHFILEOPSTRUCT) Then $aDllRet = DllCall("kernel32.dll", "long", "GetLastError") If @error Then MsgBox(4096,"Error","Error calling GetLastError") SetError($aDllRet[0]) Return False ElseIf DllStructGetData($SHFILEOPSTRUCT,$fAnyOperationsAborted) Then MsgBox(0,"Testing","Operation aborted") Return False EndIf Return True EndFunc Func _ExplorerRename($old_name, $new_name, $Options = 0) Local $SHFILEOPSTRUCT, $old_name_struct, $new_name_struct Local $nError = 0 Local $i Local Enum $hwnd = 1, $wFunc, $pFrom, $pTo, $fFlags, $fAnyOperationsAborted, $hNameMappings, $lpszProgressTitle $SHFILEOPSTRUCT = DllStructCreate("int;uint;ptr;ptr;uint;int;ptr;ptr") If @error Then MsgBox(4096,"ERROR","Error creating SHFILEOPSTRUCT structure") Return False EndIf $old_name_struct = DllStructCreate("char[" & StringLen($old_name)+2 & "]") DllStructSetData($old_name_struct, 1, $old_name) For $i = 1 To StringLen($old_name)+2 If DllStructGetData($old_name_struct, 1, $i) = 10 Then DllStructSetData($old_name_struct, 1, 0, $i) Next DllStructSetData($old_name_struct, 1, 0, StringLen($old_name)+2) $new_name_struct = DllStructCreate("char[" & StringLen($new_name)+2 & "]") DllStructSetData($new_name_struct, 1, $new_name) DllStructSetData($new_name_struct, 1, 0, StringLen($new_name)+2) DllStructSetData($SHFILEOPSTRUCT, $hwnd, 0) DllStructSetData($SHFILEOPSTRUCT, $wFunc, $FO_RENAME) DllStructSetData($SHFILEOPSTRUCT, $pFrom, DllStructGetPtr($old_name_struct)) DllStructSetData($SHFILEOPSTRUCT, $pTo, DllStructGetPtr($new_name_struct)) DllStructSetData($SHFILEOPSTRUCT, $fFlags, $Options) DllStructSetData($SHFILEOPSTRUCT, $fAnyOperationsAborted, 0) DllStructSetData($SHFILEOPSTRUCT, $hNameMappings, 0) DllStructSetData($SHFILEOPSTRUCT, $lpszProgressTitle, 0) If _SHFileOperation($SHFILEOPSTRUCT) Then $aDllRet = DllCall("kernel32.dll", "long", "GetLastError") If @error Then MsgBox(4096,"Error","Error calling GetLastError") SetError($aDllRet[0]) Return False ElseIf DllStructGetData($SHFILEOPSTRUCT,$fAnyOperationsAborted) Then MsgBox(0,"Testing","Operation aborted") Return False EndIf Return True EndFunc Func _SHFileOperation(ByRef $lpFileOp) Local $aDllRet $aDllRet = DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($lpFileOp)) If Not @error Then Return $aDllRet[0] EndFunc
    1 point
×
×
  • Create New...