Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/30/2016 in all areas

  1. Hi guys, Bitwise operations in Autoit is possible only till 32 bit integers, but sometimes WinAPI requires to process 64 bit vectors... so? So you can use this little UDF to handle properly those integers! Func _BitAND64($iValue1, $iValue2) If Not ((VarGetType($iValue1) = "Int64") Or (VarGetType($iValue2) = "Int64")) Then Return BitAND($iValue1, $iValue2) $iValue1 = __DecToBin64($iValue1) $iValue2 = __DecToBin64($iValue2) Local $aValueANDed[64], $i For $i = 0 To 63 $aValueANDed[$i] = ($iValue1[$i] And $iValue2[$i]) ? 1 : 0 Next Return __BinToDec64($aValueANDed) EndFunc ;==>_BitAND64 Func _BitOR64($iValue1, $iValue2) If Not ((VarGetType($iValue1) = "Int64") Or (VarGetType($iValue2) = "Int64")) Then Return BitOR($iValue1, $iValue2) $iValue1 = __DecToBin64($iValue1) $iValue2 = __DecToBin64($iValue2) Local $aValueORed[64], $i For $i = 0 To 63 $aValueORed[$i] = ($iValue1[$i] Or $iValue2[$i]) ? 1 : 0 Next Return __BinToDec64($aValueORed) EndFunc ;==>_BitOR64 Func _BitXOR64($iValue1, $iValue2) If Not ((VarGetType($iValue1) = "Int64") Or (VarGetType($iValue2) = "Int64")) Then Return BitXOR($iValue1, $iValue2) $iValue1 = __DecToBin64($iValue1) $iValue2 = __DecToBin64($iValue2) Local $aValueXORed[64], $i For $i = 0 To 63 $aValueXORed[$i] = (($iValue1[$i] And (Not $iValue2[$i])) Or ((Not $iValue1[$i]) And $iValue2)) ? 1 : 0 Next Return __BinToDec64($aValueXORed) EndFunc ;==>_BitXOR64 Func _BitNOT64($iValue) If Not (VarGetType($iValue) = "Int64") Then Return BitNOT($iValue) $iValue = __DecToBin64($iValue) For $i = 0 To 63 $iValue[$i] = Not $iValue[$i] Next Return __BinToDec64($iValue) EndFunc ;==>_BitNOT64 Func __DecToBin64($iDec) Local $tDec = DllStructCreate("int64 num"), $aBin[64], $bBit, $i $tDec.num = $iDec For $i = 0 To 63 $bBit = (Mod($tDec.num, 2) ? 1 : 0) $aBin[63 - $i] = $bBit $tDec.num = Floor($tDec.num / 2) Next Return $aBin EndFunc ;==>__DecToBin64 Func __BinToDec64($aBin) Local $tDec = DllStructCreate("int64 num"), $i If $aBin[0] Then $tDec.num += 0x8000000000000000 ;2^63 = 9223372036854775808, but for Autoit the world ends at 9223372036854775807 (2^63 - 1) For $i = 1 To 63 If $aBin[$i] Then $tDec.num += 2 ^ (63 - $i) Next Return $tDec.num EndFunc ;==>__BinToDec64 If you are working with unsigned 64 bit integers and these functions return a negative value, don't worry, bitwise operations come out well, but Autoit manages all numbers as signed integers.
    1 point
  2. Yes, in Array.au3, look at the HelpFile
    1 point
  3. This is my version without all those StringReplace: #include <String.au3> #include <ie.au3> Global $sSource, $aImgURL, $sKeyWord $sKeyWord = "pug" $type = "jpg" $width = "800" $height = "600" $obj = _IECreate("http://www.google.ch/search?q="& $sKeyWord &"&as_st=y&hl=it&tbs=ift:"&$type&",isz:ex,iszw:"&$width&",iszh:"&$height&"&tbm=isch&source=lnt", 0, 0) $sSource = _IEDocReadHTML($obj) $aImgURL = _StringBetween($sSource, '"ou":"', '"') For $x = 1 to UBound($aImgURL) - 1 ;$sPattern = '(?i)(http.?://.*\.(jpg|bmp|cms|jpeg))' ; http?://.../name.ext $sPattern = '(?i).*/(.*\.(jpg|bmp|cms|jpeg))' ; name.ext $aRegEx = StringRegExp($aImgURL[$x], $sPattern, 1) If @error Then ContinueLoop ConsoleWrite($aRegEx[0] & @CRLF) InetGet($aImgURL[$x], @ScriptDir & "\" & $aRegEx[0]) Next _IEQuit($obj)
    1 point
  4. The activation of Windows can be done with slmgr /ipk <serial> /ato For the rest, you have to try by yourself and come back with your script if you have any questions
    1 point
  5. An alternative way without using IE. #include <Array.au3> #include <String.au3> Global Const $HTTP_STATUS_OK = 200 Local $sKeyWord = "house" Local $sURL = "http://www.google.com/search?q=" & $sKeyWord & "&tbm=isch" Local $sData = HttpGet($sURL) ;~ ConsoleWrite($sData & @CRLF) Local $aMetas = _StringBetween($sData, '"rg_meta">', '</div>') ;~ _ArrayDisplay($aMetas) Local $sUrlImage = "" Local $sImageName = "" Local $sExtension = "" If IsArray($aMetas) Then If UBound($aMetas) >= 5 Then For $i = 0 To 4 ConsoleWrite(">Image Number: " & $i + 1 & @CRLF) $sUrlImage = _GetImageUrl($aMetas[$i]) $sImageName = _GetImageName($aMetas[$i]) ;maybe you want to get the name from image url instead of metadata $sExtension = _GetImageExtension($aMetas[$i]) ConsoleWrite($sUrlImage & @CRLF) ConsoleWrite($sImageName & @CRLF) ConsoleWrite($sExtension & @CRLF) ConsoleWrite(@CRLF) Next EndIf EndIf Func _GetImageName($sData) Local $aData = _StringBetween($sData, '"s":"', '"') If IsArray($aData) Then Return $aData[0] EndFunc ;==>_GetImageName Func _GetImageUrl($sData) Local $aData = _StringBetween($sData, '"ou":"', '"') If IsArray($aData) Then Return $aData[0] EndFunc ;==>_GetImageUrl Func _GetImageExtension($sData) Local $aData = _StringBetween($sData, '"ity":"', '"') If IsArray($aData) Then Return $aData[0] EndFunc ;==>_GetImageExtension Func HttpGet($sURL) Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET", $sURL, False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0") $oHTTP.SetRequestHeader("Content-Type", "text/plain; charset=utf-8") If (@error) Then Return SetError(1, 0, 0) $oHTTP.Send() If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) Return SetError(0, 0, $oHTTP.ResponseText) EndFunc ;==>HttpGet Make sure to clean up the file name. Saludos
    1 point
  6. Or you could let Excel calculate the max value: Global $oAppl = _Excel_Open() Global $sWorkbook1 = @ScriptDir & "\Test.xls" Global $oWorkbook1 = _Excel_BookOpen($oAppl, $sWorkbook1, Default, Default, True) _Excel_RangeWrite($oWorkbook1, $oWorkbook1.Activesheet, "=MAX(F:F)", "A1", False) ; Modify the target "A1" range if needed $iMax = _Excel_RangeRead($oWorkbook1, $oWorkbook1.Activesheet, "A1", 1) ; Modify the source "A1" range if needed MsgBox($MB_SYSTEMMODAL, "","$iMax is : " & $iMax) _Excel_BookClose($oWorkbook1, False) ; Close book without saving
    1 point
  7. What does it mean, exatly? #include <String.au3> #include <ie.au3> Global $sSource, $aImgURL, $sKeyWord $sKeyWord = "pug" $type = "jpg" $width = "800" $height = "600" $obj = _IECreate("http://www.google.ch/search?q="& $sKeyWord &"&as_st=y&hl=it&tbs=ift:"&$type&",isz:ex,iszw:"&$width&",iszh:"&$height&"&tbm=isch&source=lnt") $sSource = _IEDocReadHTML($obj) FileWrite("log.html", $sSource) $aImgURL = _StringBetween($sSource, '"ou":"', '"') For $x = 1 to UBound($aImgURL)-1 ConsoleWrite($aImgURL[$x]&@CRLF) ;InetGet($aImgURL[$x],@ScriptDir&"\"&$x&".jpg") Next
    1 point
  8. #include <Excel.au3> #include <Array.au3> Global $oAppl = _Excel_Open() Global $sWorkbook1 = @ScriptDir & "\Test.xls" Global $oWorkbook1 = _Excel_BookOpen($oAppl, $sWorkbook1, Default, Default, True) $aResult = _Excel_RangeRead($oWorkbook1) _ArrayDisplay ($aResult) $max = _ArrayMax($aResult, 1) MsgBox($MB_SYSTEMMODAL, "","$max  is : " & $max) Please try with this. Check if array displayed correctly.
    1 point
  9. Take the data in an array using _Excel_RangeRead and use _ArrayMax to find the highest value.
    1 point
  10. JohnOne

    Header File

    $HTTP_STATUS_OK = 200
    1 point
  11. water

    Merge word documents

    Something like this? $wdPageBreak is one of the Word enumerations you can find in the WordConstants.au3 (an include which gets called by Word.au3). Test.zip
    1 point
  12. jdelaney

    Reading XML File

    $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.Load(@DesktopDir & "\test.xml") $oNode = $oXML.selectSingleNode('//rules') $sVersion = $oNode.getAttribute('version') ConsoleWrite($sVersion & @CRLF) return: 467 Only works when I made the XML valid: <rules version="467"> <docMode> <domain docMode="9">site1</domain> <domain docMode="9">site2</domain> <domain docMode="8">site3</domain> <domain docMode="5">site4</domain> <domain docMode="9">site5</domain> <domain docMode="9">site6</domain> </docMode> </rules>
    1 point
  13. Danny35d

    Auto Assign drive letter

    MsgBox(0, 'Free Letter', _GetFreeDriveLetter()) Func _GetFreeDriveLetter() For $x = 67 To 90 If DriveStatus(Chr($x) & ':\') = 'INVALID' Then Return(Chr($x) & ':') Next EndFunc
    1 point
×
×
  • Create New...