Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/27/2015 in all areas

  1. With #2, I had the same idea than UEZ, but I did not take the time to explain it, sorry. BTW, something else maybe interesting with one single loop : #include<array.au3> $sString = "B|A|A|C|C|AB|DDD|BAAS|003|100|02" $iMaxLen = 0*StringReplace($sString, "|", "") + @extended $s = Execute("'" & StringRegExpReplace($sString, "([^|]+)", "' & StringFormat('%0' & " & $iMaxLen & " & 'i', StringLen('$1')) & ';$1' & '") & "'") $res = StringRegExp($s, "[^|]+", 3) _ArraySort($res) For $i = 0 To UBound($res) - 1 $res[$i] = StringTrimLeft($res[$i], $iMaxLen + 1) Next _ArrayDisplay($res)
    2 points
  2. wolf9228

    Simple Compression

    All Files Compression.zip Compression.au3 #include <WinAPI.au3> #include <Memory.au3> Example() Func Example() Local $FileOpenA , $FileOpenB , $BinaryA , $BinaryB , $NewSizeA , $NewSizeB $NewSizeA = CompressionA("Untitled.ico","Rxr.Rxr") $NewSizeB = Decompressing("Rxr.Rxr","Untitled2.ico") $FileOpenA = FileOpen("Untitled.ico",16) $FileOpenB = FileOpen("Untitled2.ico",16) $BinaryA = FileRead($FileOpenA) $BinaryB = FileRead($FileOpenB) if $BinaryA == $BinaryB Then MsgBox(0,"MSG","OK") FileClose($FileOpenA) FileClose($FileOpenB) EndFunc Func CompressionA($InFile,$OutFile = "Rxr.Rxr") Local $nBytes , $hFile , $FileSize , $FileStruct , $Remainder , $FileStructPtr Local $TempDataStructA,$ReturnSt , $NewSize , $hFileA , $hFileB , $RemainderSt Local $NuA , $NuB , $NuC $FileSize = FileGetSize($InFile) if Not $FileSize Then Return SetError(1,0,0) $hFileA = _WinAPI_CreateFile($InFile,2,2) if Not $hFileA Then Return SetError(2,0,0) $hFileB = _WinAPI_CreateFile($OutFile,1) if Not $hFileB Then _WinAPI_CloseHandle($hFileA) Return SetError(3,0,0) EndIf if $FileSize < 254 Then $RemainderSt = DllStructCreate("byte Count;byte[" & $FileSize & "]") DllStructSetData($RemainderSt,1,$FileSize) _WinAPI_ReadFile($hFileA,DllStructGetPtr($RemainderSt,2),$FileSize,$nBytes) _WinAPI_WriteFile($hFileB,DllStructGetPtr($RemainderSt),DllStructGetSize($RemainderSt),$nBytes) _WinAPI_CloseHandle($hFileA) _WinAPI_CloseHandle($hFileB) Return SetError(0,0,($FileSize + 1)) Else $FileStruct = DllStructCreate("byte[" & $FileSize & "]") $FileStructPtr = DllStructGetPtr($FileStruct) _WinAPI_ReadFile($hFileA,$FileStructPtr,$FileSize,$nBytes) $Remainder = Mod($FileSize,254) if $Remainder Then $RemainderSt = DllStructCreate("byte Count;byte[" & $Remainder & "]") DllStructSetData($RemainderSt,1,$Remainder) _MemMoveMemory($FileStructPtr + ($FileSize - $Remainder),DllStructGetPtr($RemainderSt,2),$Remainder) _WinAPI_WriteFile($hFileB,DllStructGetPtr($RemainderSt),DllStructGetSize($RemainderSt),$nBytes) $NewSize = ($Remainder + 1) Else $RemainderSt = DllStructCreate("byte Count") DllStructSetData($RemainderSt,1,0) _WinAPI_WriteFile($hFileB,DllStructGetPtr($RemainderSt),DllStructGetSize($RemainderSt),$nBytes) $NewSize = 1 EndIf For $MovPos = 0 To ($FileSize - $Remainder) - 254 Step 254 $TempDataStructA = DllStructCreate("Byte[254]") _MemMoveMemory($FileStructPtr + $MovPos,DllStructGetPtr($TempDataStructA),254) $ReturnSt = CompressionB($TempDataStructA) _WinAPI_WriteFile($hFileB,DllStructGetPtr($ReturnSt),DllStructGetSize($ReturnSt),$nBytes) $NewSize += DllStructGetSize($ReturnSt) $NuA = "[ % " & StringLeft((($MovPos + 254) / ($FileSize - $Remainder) * 100),4) & " ]" $NuB = "[ File Size " & StringLeft((($MovPos + 254 + $Remainder) / 1024),4) & " KB ]" $NuC = "[ Compression Size " & StringLeft(($NewSize / 1024),4) & " KB ]" ToolTip( $NuA & " " & $NuB & " " & $NuC , 100, 100) Next EndIf _WinAPI_CloseHandle($hFileA) _WinAPI_CloseHandle($hFileB) Return SetError(0,0,$NewSize) EndFunc Func CompressionB($TempDataStructA) Local $TempDataStructB = DllStructCreate( "Byte[254]" ) Local $TempDataStructC = DllStructCreate( "Byte[254]" ) Local $i = 0 , $NuA = 0 ,$NuB = 0 ,$NuC = 0 ,$PtrB , $ReturnSt Local $ByteE,$ByteB,$ByteC,$ByteD,$PtrA,$ByteA,$NuBPtr,$NuCPtr While 1 if (DllStructGetSize($TempDataStructA) - $i) < 2 Then ExitLoop $i += 2 $ByteE = CompressionC($TempDataStructA) $ByteA = DllStructGetData($TempDataStructA,1,$i - 1) $ByteB = DllStructGetData($TempDataStructA,1,$i) $NuA = 0 For $j = 2 To DllStructGetSize($TempDataStructA) Step 2 if (DllStructGetSize($TempDataStructA) - $j) = 1 Then ExitLoop $ByteC = DllStructGetData($TempDataStructA,1,$j - 1) $ByteD = DllStructGetData($TempDataStructA,1,$j) if $ByteA = $ByteC And $ByteB = $ByteD Then $NuA += 1 Next if $NuA > 2 Then $NuB = 0 For $n = 2 To DllStructGetSize($TempDataStructA) Step 2 $ByteC = DllStructGetData($TempDataStructA,1,$n - 1) $ByteD = DllStructGetData($TempDataStructA,1,$n) if $ByteA = $ByteC And $ByteB = $ByteD Then $NuB += 1 DllStructSetData($TempDataStructB,1,$ByteE,$NuB) Else $NuB += 1 DllStructSetData($TempDataStructB,1,$ByteC,$NuB) $NuB += 1 DllStructSetData($TempDataStructB,1,$ByteD,$NuB) EndIf if (DllStructGetSize($TempDataStructA) - $n) = 1 Then $NuB += 1 $ByteC = DllStructGetData($TempDataStructA,1,$n + 1) DllStructSetData($TempDataStructB,1,$ByteC,$NuB) ExitLoop EndIf Next $NuC += 1 DllStructSetData($TempDataStructC,1,$ByteE,$NuC) $NuC += 1 DllStructSetData($TempDataStructC,1,$ByteA,$NuC) $NuC += 1 DllStructSetData($TempDataStructC,1,$ByteB,$NuC) $TempDataStructA = DllStructCreate("Byte[" & $NuB & "]") $PtrA = DllStructGetPtr($TempDataStructA) $PtrB = DllStructGetPtr($TempDataStructB) _MemMoveMemory($PtrB,$PtrA,$NuB) EndIf WEnd if $NuC Then $ReturnSt = DllStructCreate("Byte CountB;Byte NuB[" & $NuB & "];" & "Byte CountC;Byte NuC[" & $NuC & "]") DllStructSetData($ReturnSt,"CountB",$NuB) DllStructSetData($ReturnSt,"CountC",$NuC) $NuBPtr = DllStructGetPtr($ReturnSt,"NuB") $NuCPtr = DllStructGetPtr($ReturnSt,"NuC") _MemMoveMemory (DllStructGetPtr($TempDataStructA),$NuBPtr,$NuB) _MemMoveMemory (DllStructGetPtr($TempDataStructC),$NuCPtr,$NuC) Else $ReturnSt = DllStructCreate("Byte CountB;Byte NuB[254]") $NuBPtr = DllStructGetPtr($ReturnSt,"NuB") _MemMoveMemory (DllStructGetPtr($TempDataStructA),$NuBPtr,254) EndIf Return $ReturnSt EndFunc Func CompressionC($TempDataStructA) Local $TestByte = False , $ByteE = 0 ; (Max $TempDataStructA Size Is 254) // (Max $v is 255 Start From Zero) // One Byte Out For $v = 0 To (255 - 1) $TestByte = True For $q = 1 To DllStructGetSize($TempDataStructA) $ByteE = DllStructGetData($TempDataStructA,1,$q) if $v = $ByteE Then $TestByte = False ExitLoop EndIf Next if $TestByte Then $ByteE = $v ExitLoop EndIf Next Return $ByteE EndFunc Func Decompressing($InFile,$OutFile) Local $nBytes, $FileSize , $hFileA , $hFileB , $FileSt , $FileStPtr , $NuF Local $Remainder , $CountBSt , $CountB , $CountCSt , $CountC , $StructBPtr Local $StructCPtr , $NuG , $TempDataStructB , $TempDataStructC , $NewSize Local $ByteA , $ByteB , $ByteE , $vByteE , $TempDataStructD , $StructDPtr $FileSize = FileGetSize($InFile) if Not $FileSize Then Return SetError(1,0,0) $hFileA = _WinAPI_CreateFile($InFile,2,2) if Not $hFileA Then Return SetError(2,0,0) $hFileB = _WinAPI_CreateFile($OutFile,1) if Not $hFileB Then _WinAPI_CloseHandle($hFileA) Return SetError(3,0,0) EndIf $FileSt = DllStructCreate("Byte[" & $FileSize & "]") $FileStPtr = DllStructGetPtr($FileSt) _WinAPI_ReadFile($hFileA,$FileStPtr,$FileSize,$nBytes) $Remainder = DllStructGetData($FileSt,1,1) $FileStPtr = DllStructGetPtr($FileSt) $NuF = ($FileSize - ($Remainder + 1)) if Not $NuF Then _WinAPI_WriteFile($hFileB,$FileStPtr + 1,$Remainder,$nBytes) _WinAPI_CloseHandle($hFileA) _WinAPI_CloseHandle($hFileB) Return SetError(0,0,$Remainder) Else $FileStPtr += ($Remainder + 1) EndIf While 1 if $NuF = 0 Then ExitLoop $CountBSt = DllStructCreate("Byte",$FileStPtr) $CountB = DllStructGetData($CountBSt,1) if $CountB = 0 Then $FileStPtr += 1 _WinAPI_WriteFile($hFileB,$FileStPtr,254,$nBytes) $FileStPtr += 254 $NuF -= (254 + 1) Else $NuG = 0 $FileStPtr += 1 $TempDataStructB = DllStructCreate("Byte[" & $CountB & "]") $StructBPtr = DllStructGetPtr($TempDataStructB) _MemMoveMemory($FileStPtr,$StructBPtr,$CountB) $FileStPtr += $CountB $CountCSt = DllStructCreate("Byte",$FileStPtr) $CountC = DllStructGetData($CountCSt,1) $FileStPtr += 1 $TempDataStructC = DllStructCreate("Byte[" & $CountC & "]") $StructCPtr = DllStructGetPtr($TempDataStructC) _MemMoveMemory($FileStPtr,$StructCPtr,$CountC) $FileStPtr += $CountC $NuF -= ($CountB + $CountC + 2) For $i = $CountC To 3 Step -3 $NuG = 0 $TempDataStructD = DllStructCreate("Byte[" & 254 & "]") $ByteE = DllStructGetData($TempDataStructC,1,$i - 2) $ByteA = DllStructGetData($TempDataStructC,1,$i - 1) $ByteB = DllStructGetData($TempDataStructC,1,$i) For $j = 1 To DllStructGetSize($TempDataStructB) $vByteE = DllStructGetData($TempDataStructB,1,$j) if $vByteE = $ByteE Then $NuG += 1 DllStructSetData($TempDataStructD,1,$ByteA,$NuG) $NuG += 1 DllStructSetData($TempDataStructD,1,$ByteB,$NuG) Else $NuG += 1 DllStructSetData($TempDataStructD,1,$vByteE,$NuG) EndIf Next $TempDataStructB = DllStructCreate("Byte[" & $NuG & "]") $StructBPtr = DllStructGetPtr($TempDataStructB) $StructDPtr = DllStructGetPtr($TempDataStructD) _MemMoveMemory($StructDPtr,$StructBPtr,$NuG) Next $StructBPtr = DllStructGetPtr($TempDataStructB) _WinAPI_WriteFile($hFileB,$StructBPtr,$NuG,$nBytes) $NewSize += $NuG EndIf WEnd $FileStPtr = DllStructGetPtr($FileSt) + 1 _WinAPI_WriteFile($hFileB,$FileStPtr,$Remainder,$nBytes) $NewSize += $Remainder _WinAPI_CloseHandle($hFileA) _WinAPI_CloseHandle($hFileB) Return SetError(0,0,$NewSize) EndFunc Compression.zip
    1 point
  3. When I get an ultrabook with multi-touch panel, the idea that using autoit to handle the multi-touch message comes out. Simple enough, but it can work normally. Enjoy it:) Files in attachment: MT_GESTURE.au3 WM_GESTURE.jpg MT_TOUCH.au3 WM_TOUCH.jpg MT_TOUCH _Color_Point_V2.au3 WM_TOUCH_V2.jpg Reference: WM_TOUCH message http://msdn.microsoft.com/en-us/library/windows/desktop/dd317341(v=vs.85).aspx WM_GESTURE message http://msdn.microsoft.com/en-us/library/windows/desktop/dd353242(v=vs.85).aspx GESTURE_TOUCH.zip
    1 point
  4. Jos

    Error in ImageSearch.au3

    Really making progress here ..... not
    1 point
  5. JohnOne

    Sleep() problem!

    Adlib will interrupt Sleep function.
    1 point
  6. BrewManNH

    Sleep() problem!

    Doesn't work means less than nothing to us, what doesn't work? It doesn't sleep the script? the script didn't sleep as long as you're expecting?the script sleeps longer than you're expecting?the script crashes?the script locks up?the computer blue screens?the computer catches on fire? Help us help you, give us more than "it doesn't work".
    1 point
  7. You're right both, $iMaxlen length is too much. Instead, 10 could be enough. So now, the code is shorter : #include<array.au3> $sString = "B|A|A|C|C|AB|DDD|BAAS|003|100|02" $s = Execute("'" & StringRegExpReplace($sString, "([^|]+)", "' & StringFormat('%010i', StringLen('$1')) & '$1' & '") & "'") $res = StringRegExp($s, "[^|]+", 3) _ArraySort($res) For $i = 0 To UBound($res) - 1 $res[$i] = StringTrimLeft($res[$i], 10) Next _ArrayDisplay($res)
    1 point
  8. Maybe prefix the maximum zero digits you want to allow - probably not more than 10. A 10 digit number would be a huge string length.
    1 point
  9. Thanks @boththose : you just have to double the single quotes before the execute call $s = Execute("'" & StringRegExpReplace(StringReplace($sString, "'", "''"), "([^|]+)", "' & StringFormat('%0' & " & $iMaxLen & " & 'i', StringLen('$1')) & ';$1' & '") & "'")
    1 point
  10. Then add the @SW_HIDE flag to it.
    1 point
  11. @jguinch Very nice. Thinking about it, $iMaxlen could generate some rather long strings. Maybe you could use StringLen($iMaxlen) instead. Or use 8: because arrays can't grow beyond appox 16,000,000 elements (8 digits). Hmm that's faulty thinking. The longest string may be longer than 16,000,000 99,999,999 characters.
    1 point
  12. arraysort is a fickle whore. And I was not saying I only loop twice... I was just saying my effort is down from 3 For loops to 2, keyboard strokes. @jguinch not that its feasible, but why does yours break with a single quote, but every other character seems fine? * (looks like it terminates the execute string, but i will wait for the expert diagnosis.) $sString = "B|A|A|C'|C|AB|DDD|BAAS|003|100|02"
    1 point
  13. Broke it with: "B|A|A|C|C|AB|0DDDDDdD|BAAS|003|100|02". Your method also loops through the array multiple times.
    1 point
  14. The Run command has a HIDE parameter, which is mentioned in the Help file. You can also make sure you are using the /c switch with CMD.EXE and not the /k switch ... though use that last when needing to troubleshoot. Taken straight from the RUN command section of the Help file. Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)Use the WinSetState command to SHOW the window, if you want. WinSetState("cmd.exe", "", @SW_SHOW)I'm just guessing that "cmd.exe" is the window title, so you may have to adjust that bit.
    1 point
  15. down to two loops #include<array.au3> $sString = "B|A|A|C|C|AB|DDDDDDDdD|BAAS|003|100|02" $aSplit = stringsplit($sString , "|" , 2) _arraySort($aSplit) local $aNew[0] $i = 0 For $k = 0 to stringlen($aSplit[ubound($aSplit) - 1]) + 1 For $i = 0 to ubound($aSplit) - 1 If stringlen($aSplit[$i]) = $k Then _arrayadd($aNew , $aSplit[$i]) EndIf Next Next _ArrayDisplay($aNew)
    1 point
  16. hi SkythekidRS, welcom to Autoit forum, here link to help you : https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlTreeView_GetTree.htm
    1 point
  17. Probably RegExp can do this with the string syntax provided. I'm not sure how, but I think so.
    1 point
  18. Here another version #include <Array.au3> Local $sWord, $sWordList = ("B|A|A|C|C|AB|DDD|BAAS|003|100|02") $aResult = Sort($sWordList) _ArrayDisplay($aResult) Func Sort($sData, $sDelimiter = "|") Local $a = _ArrayUnique(StringSplit($sData, $sDelimiter, 2), 0, 0, 0, 0), $i Local $aResult[UBound($a)][2] For $i = 0 To UBound($a) - 1 $aResult[$i][0] = $a[$i] $aResult[$i][1] = StringLen($a[$i]) Next Local $aI[2] = [1, 0] _ArraySort_MultiColumn($aResult, $aI, 0) ReDim $aResult[UBound($aResult)][1] Return $aResult EndFunc ; #FUNCTION# ============================================================================= ; Name.............: _ArraySort_MultiColumn ; Description ...: sorts an array at given colums (multi colum sort) ; Syntax...........: _ArraySort_MultiColumn(ByRef $aSort, ByRef $aIndices) ; Parameters ...: $aSort - array to sort ; $aIndices - array with colum indices which should be sorted in specified order - zero based ; $oDir/$iDir - sort direction - if set to 1, sort descendingly else ascendingly ; Author .........: UEZ ; Version ........: v0.70 build 2013-11-20 Beta ; ========================================================================================= Func _ArraySort_MultiColumn(ByRef $aSort, ByRef $aIndices, $oDir = 0, $iDir = 0) If Not IsArray($aIndices) Or Not IsArray($aSort) Then Return SetError(1, 0, 0) ;checks if $aIndices is an array If UBound($aIndices) > UBound($aSort, 2) Then Return SetError(2, 0, 0) ;check if $aIndices array is greater the $aSort array Local $1st, $2nd, $x, $j, $k, $l = 0 For $x = 0 To UBound($aIndices) - 1 ;check if array content makes sense If Not IsInt($aIndices[$x]) Then Return SetError(3, 0, 0) ;array content is not numeric Next If UBound($aIndices) = 1 Then Return _ArraySort($aSort, $oDir, 0, 0, $aIndices[0]) ;check if only one index is given _ArraySort($aSort, $oDir, 0, 0, $aIndices[0]) Do $1st = $aIndices[$l] $2nd = $aIndices[$l + 1] $j = 0 $k = 1 While $k < UBound($aSort) If $aSort[$j][$1st] <> $aSort[$k][$1st] Then If $k - $j > 1 Then _ArraySort($aSort, $iDir , $j, $k - 1, $2nd) $j = $k Else $j = $k EndIf EndIf $k += 1 WEnd If $k - $j > 1 Then _ArraySort($aSort, $iDir, $j, $k, $2nd) $l += 1 Until $l = UBound($aIndices) - 1 Return 1 EndFunc
    1 point
  19. i was going for line count. efficiency would be your method. I have to think you can get rid of the stringlength loop in a smart way as well. this maybe? Edit: *No this is definitely doing something wrong, changing the array slightly messes it up
    1 point
  20. Yeah that's a possible method. You could make it go faster by replacing _ArrayAdd() to avoid ReDims. First create an empty array with all the elements needed, and then fill it using your method.
    1 point
  21. #include<array.au3> $sString = "B|A|A|C|C|AB|DDD|BAAS|003|100|02" $aSplit = stringsplit($sString , "|" , 2) _arraySort($aSplit) local $aNew[0] local $maxlen = 0 For $m = 0 to ubound($aSplit) - 1 $curlen = stringlen($aSplit[$m]) If $curlen > $maxlen Then $maxlen = $curlen Next For $k = 0 to $maxlen For $i = 0 to ubound($aSplit) - 1 If stringlen($aSplit[$i]) = $k Then _arrayadd($aNew , $aSplit[$i]) EndIf Next Next _ArrayDisplay($aNew)
    1 point
  22. 1 point
  23. SamratAtKolkata

    Hosts file

    0,0,0,0 www.domain.com0.0.0.0 sub.domain.com0.0.0.0 sub.sub.domain.com0.0.0.0 domain_name.com0.0.0.0 domain-mane.com0.0.0.0 1domain.com0.0.0.0 _domain.co0.0.0.0 I think that only nos.1 thru 6 are the valid ....
    1 point
  24. just for fun. #include <Array.au3> Local $sFile='0x123456' Local $aArray[BinaryLen($sFile)] Local $n=0 For $i=3 to StringLen($sFile) step 2 ConsoleWrite( StringMid($sFile,$i,2) & @CRLF) $aArray[$n]=int('0x' & (StringMid($sFile,$i,2))) $n+=1 Next _ArrayDisplay($aArray) ;Convert Back Local $sOutput="0x" For $i=0 to UBound($aArray)-1 ConsoleWrite(hex($aArray[$i],2) & @CRLF) $sOutput&=hex($aArray[$i],2) Next ConsoleWrite($sOutput & @CRLF)Saludos
    1 point
  25. That's old code. Try this modified version. #include <Array.au3> Local $sWordList = ["B","A","A","C","C","AB","DDD","BAAS","003","100","02"] _ArraySortByLen($sWordList) _ArrayDisplay($sWordList) Func _ArraySortByLen(ByRef $aArray, $iDescending =0, $iStart =0, $iEnd =0) If Not IsArray($aArray) Or UBound($aArray, 0) > 1 Then Return SetError(1, 0, 0) ; Not a 1D array If Not IsInt($iStart) Or Not IsInt($iEnd) Then Return SetError(5, 0, 0) ; Parameters need to be integers. Local $iBound = UBound($aArray) Local $aElementLen[$iBound][2] $iBound -=1 For $i = 0 To $iBound $aElementLen[$i][0] = StringFormat("%08i", StringLen($aArray[$i])) & $aArray[$i] ; Get the length of the element $aElementLen[$i][1] = $aArray[$i] ; The element to sort Next _ArraySort($aElementLen, $iDescending, $iStart, $iEnd) If @error Then Return SetError(@error, 0, 0) ; See _ArraySort() for error codes 2 to 4. For $i = 0 To $iBound $aArray[$i] = $aElementLen[$i][1] Next Return 1 EndFunc ;==> _ArraySortByLen()
    1 point
  26. #include <Array.au3> Local $aTest = ["Yo","Hi","1","very long","longer","long"] _ArraySortByLen($aTest) _ArrayDisplay($aTest) Func _ArraySortByLen(ByRef $aArray, $iDescending =0, $iStart =0, $iEnd =0) If Not IsArray($aArray) Or UBound($aArray, 0) > 1 Then Return SetError(1, 0, 0) ; Not a 1D array If Not IsInt($iStart) Or Not IsInt($iEnd) Then Return SetError(5, 0, 0) ; Parameters need to be integers. Local $iBound = UBound($aArray) Local $aElementLen[$iBound][2] $iBound -=1 For $i = 0 To $iBound $aElementLen[$i][0] = StringLen($aArray[$i]) ; Get the length of the element $aElementLen[$i][1] = $aArray[$i] ; The element to sort Next _ArraySort($aElementLen, $iDescending, $iStart, $iEnd) If @error Then Return SetError(@error, 0, 0) ; See _ArraySort() for error codes 2 to 4. For $i = 0 To $iBound $aArray[$i] = $aElementLen[$i][1] Next Return 1 EndFunc ;==> _ArraySortByLen()
    1 point
  27. nm, misunderstood...too early fts.
    1 point
  28. Maybe this could help you : https://www.autoitscript.com/forum/topic/124437-sort-multiple-or-multi-dimensional-arrays-with-multiple-sort-columns/
    1 point
  29. I don't know which process you want to apply to each byte, but maybe it's possible do to it in one shot : #Include <Array.au3> $string = "0x123456" $bytes = Execute( StringRegExpReplace(StringReplace($string, "0x", "'0x'"), "([[:xdigit:]]{2})", " & _DoTheWork('$1')") ) ConsoleWrite($bytes) Func _DoTheWork($val) Return Hex(BitXOR(0xFF, Binary("0x" & $val)), 2) ; for example EndFunc
    1 point
  30. Or this using an array #Include <Array.au3> InetGet("https://www.autoitscript.com/forum/cdn/images/logo_autoit_210x72.png", @scriptdir & "\test.png") $file_in = @scriptdir & "\test.png" $file_out = "out.png" ; read $file = FileOpen($file_in, 16) $bytes = StringRegExp(FileRead($file), '[[:xdigit:]]{2}', 3) FileClose($file) _ArrayDisplay($bytes, "file") ; write $txt = "" For $i = 0 to UBound($bytes)-1 $txt &= $bytes[$i] Next $file2 = FileOpen($file_out, 18) FileWrite($file2, "0x" & $txt) FileClose($file2) ;#cs Dim $result[UBound($bytes)][2] For $i = 0 to UBound($bytes)-1 $result[$i][0] = $bytes[$i] $result[$i][1] = Chr("0x" & $bytes[$i]) Next _ArrayDisplay($result) ;#ce
    1 point
  31. msdn are not the boss of me. I keep getting flashbacks of reading something where you could change how mouse buttons operated, and testing it. It never worked, so I probably never bothered changing it back but maybe it did something I was unaware of.
    1 point
  32. Maybe that's what you are looking for? Local $sFileOpenDialog = FileOpenDialog("", @WorkingDir & "\", "Exe (*.exe)", 1) If @error Then Exit Local $hFileOpen = FileOpen($sFileOpenDialog, 16) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") Exit EndIf Local $sFileRead = FileRead($hFileOpen) FileClose($hFileOpen) Local $File_struct = DllStructCreate("BYTE File[" & BinaryLen($sFileRead) & "]") DllStructSetData($File_struct, "File", $sFileRead) for $io = 0 to BinaryLen($sFileRead) msgbox(0,"","0x" & hex(DllStructGetData($File_struct, "File",$io),2)) next
    1 point
  33. Qwerty212, There is no requirement to delete the scrollbars - and using GUICtrlDelete is useless anyway as the _GUIScrollbars_Generate function does not return a ControlID but an array of interesting data, as explained in the header: ; Return values .: Success - Returns a 4-element array (see remarks for details): ; [0] = Actual aperture width ; [1] = Actual aperture height] ; [2] = Width correction factor ; [3] = Height correction factor]And as you appear to want to adjust the size of the scrollbars to match the changing size of the scrolled area, you should really be using the GUIScrollbars_Size UDF, not GUIScrollbars_Ex. Look at the example script GUIScrollbars_Size_Example_2 (which is included in the zip file) to see how to do it - you will see that you never delete and recreate the scrollbars, just adjust their parameters so that they match the size of the area to be scrolled. The width of the scrollbars is set by the system and you can change it via the _WinAPI_SystemParametersInfo function. M23
    1 point
  34. Melba23

    A New Moderator

    Hi, For those of you still using monochrome monitors, or who have some degree of colour-blindness, I would like to announce that we have a new forum Moderator - JLogan3o13. He has kindly agreed to join the Mod team and I would like to take this opportunity to welcome him - I am sure you will all join with me in wishing him well , because he will certainly need it! M23
    1 point
  35. JohnOne

    Hosts file

    haha, sorry, that was fat finger syndrome.
    1 point
  36. Melba23

    New MVPs

    Hi, Some good news today: LarsJ, mikell and mLipok have accepted the invitation to become MVPs. I am sure you will all join me in congratulating them on their new status. M23
    1 point
  37. Bert

    PC Beacon

    This tool is for the tech who supports a corporate environment. Say you are doing PC replacements. You know the IP address of the PC you need to find. You can remote into the PC. You know the floor where the PC is located. BUT...you not exactly sure where on the floor the PC is located. All the PCs on the floor are the same model, so knowing what model it is doesn't help at all. This is where this little tool will come in handy. To use the tool, just do the following: Remote into the PClog onRun the toolconfigure the tool to your need, and press start.When you find the PC, press Ctrl+Alt+C to turn off the beacon. When choosing how you want to run the beacon, you can do: flashing red screendisplay a message in LARGE COMIC SANS FONTAudio - either beep or Microsoft voice that will read the text you have put in the message.Another good use if for remote support to help a user locate a PC that they need to find. #Region converted Directives from I:\autoit scrips\PCBeacon\PCBeacon.au3.ini #AutoIt3Wrapper_aut2exe=C:\Program Files\AutoIt3\beta\Aut2Exe\Aut2Exe.exe #AutoIt3Wrapper_icon=C:\Documents and Settings\a4mh3\Desktop\autoit scrips\icons\Beaconinthenight.ico #AutoIt3Wrapper_outfile=C:\Documents and Settings\a4mh3\Desktop\autoit scrips\PCBeacon\PCBeacon.exe #AutoIt3Wrapper_PassPhrase=FnpT01 #AutoIt3Wrapper_Res_Comment=http://www.hiddensoft.com/autoit3/compiled.html #AutoIt3Wrapper_Res_Description=AutoIt v3 Compiled Script #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=n #AutoIt3Wrapper_Run_AU3Check=4 #EndRegion converted Directives from I:\autoit scrips\PCBeacon\PCBeacon.au3.ini ; Opt("TrayIconHide", 1) #include <WindowsConstants.au3> #include <inet.au3> #include <GUIConstantsEx.au3> HotKeySet("^!c", "_exit") Dim $voice = ObjCreate("Sapi.SpVoice") Dim $chk_1, $chk_2, $chk_3, $chk_4, $chk_5, $chk_6, $voice $gui1 = GUICreate("PCBeacon 1.0", 392, 323, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Checkbox_1 = GUICtrlCreateCheckbox("Flashing screen", 20, 20, 120, 20) $Checkbox_2 = GUICtrlCreateCheckbox("Audio", 20, 60, 120, 20) $Checkbox_3 = GUICtrlCreateCheckbox("Message to show", 20, 100, 120, 30) $Input_4 = GUICtrlCreateInput("", 20, 150, 350, 80) $Button_5 = GUICtrlCreateButton("Start", 60, 260, 70, 30) $Button_6 = GUICtrlCreateButton("Exit", 160, 260, 70, 30) $radio_7 = GUICtrlCreateRadio("Talk", 220, 60, 50, 20) $radio_8 = GUICtrlCreateRadio("beep", 280, 60, 50, 20) $group_9 = GUICtrlCreateGroup("", 200, 50, 150, 35) $lable_10 = GUICtrlCreateLabel("PCBeacon 1.0" & @CRLF & "Volly Productions" & @CRLF & "November 2006", 260, 260, 120, 90) GUICtrlSetData($Input_4, IniRead("PCB.inr", "text", "text", "")) GUICtrlSetState($Checkbox_3, $GUI_DISABLE) GUICtrlSetState($Input_4, $GUI_DISABLE) GUICtrlSetState($radio_7, $GUI_DISABLE) GUICtrlSetState($radio_8, $GUI_DISABLE) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Checkbox_1 $a = GUICtrlRead($Checkbox_1) If $a = $GUI_CHECKED Then GUICtrlSetState($Checkbox_3, $GUI_ENABLE) GUICtrlSetState($Input_4, $GUI_ENABLE) EndIf If $a = $GUI_UNCHECKED Then GUICtrlSetState($Checkbox_3, $GUI_DISABLE) GUICtrlSetState($Input_4, $GUI_DISABLE) EndIf Case $msg = $Checkbox_2 $b = GUICtrlRead($Checkbox_2) If $b = $GUI_CHECKED Then GUICtrlSetState($radio_7, $GUI_ENABLE) GUICtrlSetState($radio_8, $GUI_ENABLE) EndIf If $b = $GUI_UNCHECKED Then GUICtrlSetState($radio_7, $GUI_DISABLE) GUICtrlSetState($radio_8, $GUI_DISABLE) EndIf Case $msg = $radio_7 $c = GUICtrlRead($radio_7) $cc = GUICtrlRead($Checkbox_2) Select Case $c = $GUI_CHECKED GUICtrlSetState($Input_4, $GUI_ENABLE) Case $c = $GUI_UNCHECKED GUICtrlSetState($Input_4, $GUI_DISABLE) Case $cc = $GUI_UNCHECKED GUICtrlSetState($Input_4, $GUI_DISABLE) EndSelect Case $msg = $radio_8 $d = GUICtrlRead($radio_7) Select Case $d = $GUI_CHECKED GUICtrlSetState($Input_4, $GUI_DISABLE) Case $d = $GUI_UNCHECKED GUICtrlSetState($Input_4, $GUI_DISABLE) EndSelect Case $msg = $Button_5;start MsgBox(0, "Important!", 'Once started, you will need to use "CTRL + ALT + C" to end the program') _start() Case $msg = $Button_6;start Exit Case Else ;;; EndSelect WEnd Exit Func _exit() Exit EndFunc ;==>_exit Func _start() Local $splash $chk_1 = GUICtrlRead($Checkbox_1);splash $chk_2 = GUICtrlRead($Checkbox_2);beep $chk_3 = GUICtrlRead($Checkbox_3);message $chk_4 = GUICtrlRead($Input_4) IniWrite("PCB.inr", "text", "text", $chk_4) $chk_5 = GUICtrlRead($radio_7);splash $chk_6 = GUICtrlRead($radio_8) GUISetState(@SW_HIDE, $gui1) If $chk_1 = $GUI_CHECKED Then _loop1() If $chk_2 = $GUI_CHECKED Then _loop2() EndFunc ;==>_start Func _loop1() $gui2 = GUICreate("", 600, 500, -1, -1, "", 0x00000008) GUISetBkColor(0xE0FFFF, $gui2) $lable = GUICtrlCreateEdit("", 100, 25, 400, 400, 0x0004 + 0x0800 + 0x0001) If $chk_3 = $GUI_CHECKED Then $font = "Comic Sans MS" GUICtrlSetData($lable, $chk_4) GUICtrlSetFont($lable, 22, 900, "", $font) EndIf GUISetState(@SW_SHOW, $gui2) While 1 $getpos = MouseGetPos() MouseMove($getpos[0] + 1, $getpos[1], 0) MouseMove($getpos[0] - 1, $getpos[1], 0) If $chk_2 = $GUI_CHECKED Then If $chk_5 = $GUI_CHECKED Then _Talk($chk_4, 0.75, 100) Sleep(2000) EndIf if $chk_6 = $GUI_CHECKED Then Beep(500, 1000) Else Sleep(1000) EndIf SplashImageOn("", @ScriptDir & "\red.bmp", @DesktopWidth, @DesktopHeight) Sleep(1000) SplashOff() WEnd EndFunc ;==>_loop1 Func _loop2() While 1 If $chk_5 = $GUI_CHECKED Then _Talk($chk_4, 0.75, 100) Sleep(2000) EndIf if $chk_6 = $GUI_CHECKED Then Beep(300, 200) Beep(400, 500) Beep(500, 200) Beep(600, 500) Sleep(3000) EndIf WEnd EndFunc ;==>_loop2 Func _Talk($Text, $Rate, $Vol) $voice.Rate = $Rate $voice.Volume = $Vol $voice.Speak ($Text) EndFunc ;==>_Talk
    1 point
×
×
  • Create New...