Leaderboard
Popular Content
Showing content with the highest reputation on 07/13/2019 in all areas
-
The other day mikeytown2 posted one post in HTTP UDF's thread that got me thinking if there is better (different) method to send requests through the HTTP protocol to HTTP servers. There is Winhttp.dll that ships with windows and that is its main purpose. I couldn't find any examples of using this dll in AutoIt, so I came up with this. Microsoft about Windows HTTP Services: Microsoft Windows HTTP Services (WinHTTP) provides developers with an HTTP client application programming interface (API) to send requests through the HTTP protocol to other HTTP servers... .. blah, blah, and so on... This is an example of getting page header: #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Open needed handles Local $hOpen = _WinHttpOpen() Local $hConnect = _WinHttpConnect($hOpen, "msdn.microsoft.com") ; Specify the reguest: Local $hRequest = _WinHttpOpenRequest($hConnect, Default, "en-us/library/aa384101(VS.85).aspx") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) Local $sHeader = _WinHttpQueryHeaders($hRequest) ; ...get full header ; Clean _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Display retrieved header MsgBox(0, "Header", $sHeader)Everything you need to be able to use this UDF can be found at WinHttp site. Remember, basic understanding of the HTTP protocol is important to use this interface. ProgAndy, trancexx WinHttp.au3 is completely free and no one has right to charge you for it. That's very important. If you feel WinHttp.au3 was helpful to you and you wish to support my further work you can donate to my personal account via PayPal address: trancexx at yahoo dot com I will appreciate that very much. Thank you in advance! :kiss:1 point
-
As the WebDriver UDF - Help & Support thread has grown too big, I started a new one. The prior thread can be found here.1 point
-
I clicked together a quick&dirty check routine for your data. It checks for objects, cells > 255 characters and cells > 32767 characters. You get a count for each category or a detailed listing so you can identify the cells you need to change. Or you can set flag $bFix and all or individual categories get fixed. #include <String.au3> ; Create an array with invalid data Global $aData[2][2] = [[ObjCreate("Scripting.Dictionary"), _StringRepeat("1", 256)], [_StringRepeat("1", 32768), _StringRepeat("1", 256)]] Global $bDetail = True ; If set to True each cell with invalid data is listed with zero based row, column and explanation Global $bFix = 7 ; If set to <> 0 cells with invalid data will be modified or shortened so, as a result, they hold valid data ; Can be a combination of any of the following values: ; 1 - Set all objects to "" ; 2 - Strip all cells with more than 32767 characters to 32767 characters using StringLeft ; 4 - Strip all cells with more than 255 but less than 32767 characters to 255 characters using StringLeft Global $aCount[] = [0, 0, 0] For $i = 0 To UBound($aData, 1) - 1 For $j = 0 To UBound($aData, 2) - 1 Select Case IsObj($aData[$i][$j]) If $bDetail Then ConsoleWrite("Row " & $i & ", Col " & $j & ": IsObj" & @CRLF) If BitAND($bFix, 1) = 1 Then $aData[$i][$j] = "" $aCount[0] += 1 Case StringLen($aData[$i][$j]) > 32767 If $bDetail Then ConsoleWrite("Row " & $i & ", Col " & $j & ": Length > 32767" & @CRLF) If BitAND($bFix, 2) = 2 Then $aData[$i][$j] = StringLeft($aData[$i][$j], 32767) $aCount[1] += 1 Case StringLen($aData[$i][$j]) > 255 If $bDetail Then ConsoleWrite("Row " & $i & ", Col " & $j & ": Length > 255" & @CRLF) If BitAND($bFix, 4) = 4 Then $aData[$i][$j] = StringLeft($aData[$i][$j], 255) $aCount[2] += 1 EndSelect Next Next ConsoleWrite("SUMMARY" & @CRLF) ConsoleWrite("Cells containing data type object : " & $aCount[0] & ". Fixed: " & (BitAND($bFix, 1) = 1) & @CRLF) ConsoleWrite("Cells containing data > 32.767 characters: " & $aCount[1] & ". Fixed: " & (BitAND($bFix, 2) = 2) & @CRLF) ConsoleWrite("Cells containing data > 255 characters : " & $aCount[2] & ". Fixed: " & (BitAND($bFix, 4) = 4)) If (BitAND($bFix, 4) <> 4) Then ConsoleWrite(". Use $bForceFunc = True in _Excel_RangeWrite.") ConsoleWrite(@CRLF) Example console output: Row 0, Col 0: IsObj Row 0, Col 1: Length > 255 Row 1, Col 0: Length > 32767 Row 1, Col 1: Length > 255 SUMMARY Cells containing data type object : 1. Fixed: True Cells containing data > 32.767 characters: 1. Fixed: True Cells containing data > 255 characters : 2. Fixed: True1 point
-
add a file version
PedroWarlock reacted to Zedna for a topic
Simple solution is to add to begin of TXT file one line with actual "file version" (for example: version=1.32) so later you can read first line of TXT to get its version and do comparing. Of course this can be done only when original TXT files can be modified Another variant is to use some type of HASH to compare if file is latest version or not.1 point -
1 point
-
I used _BmpSearch quite often. And I made some changes to improve usability: now it is not a UDF, but a function now the function accepts not only gdi32 hBitmap, but also GDI+ hImage or simply path to image file now there is no problem with the alpha channel now you can search for a 1x1 pixel image and get array of pixels now the search time is returned to the $aCoords[0][1] in milliseconds added error checking #include <GDIPlus.au3> #pragma compile(x64, false) ; #FUNCTION# ==================================================================================================================== ; Name : _BmpSearchEx ; Description : Searches for Bitmap in a Bitmap ; Syntax : _BmpSearchEx($vPic1, $vPic2, $iMax = 5000) ; Parameters : $vPic1 - Handle to bitmap (gdi32 or GDI+) to search or path to image file ; : $vPic2 - Handle to bitmap (gdi32 or GDI+) to find or path to image file ; : $iMax - Max matches to find ; Return values : Success: Returns a 2d array with the following format: ; : $aCoords[0][0] = Total matches found (0 if not found) ; : $aCoords[0][1] = Time of search in ms ; : $aCoords[$i][0] = Width of bitmap ; : $aCoords[$i][1] = Height of bitmap ; : $aCoords[$i][2] = X coordinate ; : $aCoords[$i][3] = Y coordinate ; : Failure: Returns 0 and sets @error: ; : @error = 1 - file $vPic1 not found ; : @error = 2 - file $vPic2 not found ; : @error = 3 - $vPic1 is not a bitmap ; : @error = 4 - $vPic2 is not a bitmap ; : @error = 5 - error decode opcode ; Author : Brian J Christy (Beege) ; Modified : InnI ; =============================================================================================================================== Func _BmpSearchEx($vPic1, $vPic2, $iMax = 5000) If $iMax < 1 Then $iMax = 5000 Local $hImg1, $hImg2, $iErr1, $iErr2, $iTime = TimerInit() _GDIPlus_Startup() If IsString($vPic1) Then If Not FileExists($vPic1) Then Return SetError(1, _GDIPlus_Shutdown(), 0) $hImg1 = _GDIPlus_BitmapCreateFromFile($vPic1) Else $hImg1 = _GDIPlus_BitmapCreateFromHBITMAP($vPic1) $iErr1 = @error EndIf If IsString($vPic2) Then If Not FileExists($vPic2) Then Return SetError(2, _GDIPlus_Shutdown(), 0) $hImg2 = _GDIPlus_BitmapCreateFromFile($vPic2) Else $hImg2 = _GDIPlus_BitmapCreateFromHBITMAP($vPic2) $iErr2 = @error EndIf $hSource = ($iErr1) ? _GDIPlus_BitmapCreateHBITMAPFromBitmap($vPic1) : _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg1) If Not $iErr1 Then _GDIPlus_BitmapDispose($hImg1) $hFind = ($iErr2) ? _GDIPlus_BitmapCreateHBITMAPFromBitmap($vPic2) : _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg2) If Not $iErr2 Then _GDIPlus_BitmapDispose($hImg2) _GDIPlus_Shutdown() Static Local $aMemBuff, $tMem, $fStartup = True If $fStartup Then ;####### (BinaryStrLen = 490) #### (Base64StrLen = 328 )##################################################################### Local $Opcode = 'yBAAAFCNRfyJRfSNRfiJRfBYx0X8AAAAAItVDP8yj0X4i10Ii0UYKdiZuQQAAAD38YnBi0X4OQN0CoPDBOL36akAAACDfSgAdB1TA10oO10YD4OVAAAAi1UkORN1A1vrBluDwwTrvVOLVSyLRTADGjtdGHd3iwg5C3UhA1oEi0gEO10Yd2Y5C3USA1oIi0gIO10Yc1c5' & _ 'C3UDW+sGW4PDBOuCi1UUid6LfQyLTRCJ2AHIO0UYczfzp4P5AHcLSoP6AHQNA3Uc6+KDwwTpVP///4tFIIkYg0UgBIPDBP9F/ItVNDlV/HQG6Tj///9bi0X8ycIwAA==' Local $aDecode = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "str", $Opcode, "dword", 0, "dword", 1, "struct*", DllStructCreate("byte[254]"), "dword*", 254, "ptr", 0, "ptr", 0) If @error Or (Not $aDecode[0]) Then Return SetError(5, 0, 0) $Opcode = BinaryMid(DllStructGetData($aDecode[4], 1), 1, $aDecode[5]) $aMemBuff = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", BinaryLen($Opcode), "dword", 4096, "dword", 64) $tMem = DllStructCreate('byte[' & BinaryLen($Opcode) & ']', $aMemBuff[0]) DllStructSetData($tMem, 1, $Opcode) ;############################################################################################################################ $fStartup = False EndIf Local $tSizeSource = _WinAPI_GetBitmapDimension($hSource) If @error Then Return SetError(3, 0, 0) Local $tSizeFind = _WinAPI_GetBitmapDimension($hFind) If @error Then Return SetError(4, 0, 0) Local $iRowInc = ($tSizeSource.X - $tSizeFind.X) * 4 Local $tSource = DllStructCreate('dword[' & ($tSizeSource.X * $tSizeSource.Y) & ']') _WinAPI_GetBitmapBits($hSource, DllStructGetSize($tSource), DllStructGetPtr($tSource)) Local $tFind = DllStructCreate('dword[' & ($tSizeFind.X * $tSizeFind.Y) & ']') _WinAPI_GetBitmapBits($hFind, DllStructGetSize($tFind), DllStructGetPtr($tFind)) _WinAPI_DeleteObject($hSource) _WinAPI_DeleteObject($hFind) ;####### (BinaryStrLen = 106) ################################################################################################# Static Local $Opcode_ = '0xC80000008B5D0C8B1383C3048B4D103913750C83C304E2F7B800000000EB118B5508FF338F028B451029C883C002EB00C9C20C00' Static Local $aMemBuff_ = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", BinaryLen($Opcode_), "dword", 4096, "dword", 64) Static Local $tMem_ = DllStructCreate('byte[' & BinaryLen($Opcode_) & ']', $aMemBuff_[0]) DllStructSetData($tMem_, 1, $Opcode_) ;############################################################################################################################## Local $iFirstDiffIdx, $iFirstDiffPix, $aFirstDiffCoords[2], $iMaxLoops = (DllStructGetSize($tFind) / 4) - 1 If $iMaxLoops Then Local $aFD = DllCallAddress('dword', DllStructGetPtr($tMem_), 'dword*', 0, 'struct*', $tFind, 'dword', $iMaxLoops) $iFirstDiffIdx = $aFD[0] $iFirstDiffPix = $aFD[1] Else $iFirstDiffIdx = 1 $iFirstDiffPix = DllStructGetData($tFind, 1, 1) EndIf $aFirstDiffCoords[1] = Int(($iFirstDiffIdx - 1) / $tSizeFind.X) $aFirstDiffCoords[0] = ($iFirstDiffIdx - 1) - ($aFirstDiffCoords[1] * $tSizeFind.X) Local $iFirst_Diff_Inc = (($aFirstDiffCoords[1] * $tSizeSource.X) + $aFirstDiffCoords[0]) * 4 If $iFirst_Diff_Inc < 0 Then $iFirst_Diff_Inc = 0 Local $tCornerPixs = DllStructCreate('dword[3]') DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X), 1) DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X * ($tSizeFind.Y - 1) + 1), 2) DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X * $tSizeFind.Y), 3) Local $tCornerInc = DllStructCreate('dword[3]') DllStructSetData($tCornerInc, 1, ($tSizeFind.X - 1) * 4, 1) DllStructSetData($tCornerInc, 1, (($tSizeSource.X - $tSizeFind.X) + $tSizeSource.X * ($tSizeFind.Y - 2) + 1) * 4, 2) DllStructSetData($tCornerInc, 1, ($tSizeFind.X - 1) * 4, 3) Local $pStart = DllStructGetPtr($tSource) Local $iEndAddress = Int($pStart + DllStructGetSize($tSource)) Local $tFound = DllStructCreate('dword[' & $iMax & ']') Local $ret = DllCallAddress('dword', DllStructGetPtr($tMem), 'struct*', $tSource, 'struct*', $tFind, _ 'dword', $tSizeFind.X, 'dword', $tSizeFind.Y, _ 'dword', $iEndAddress, 'dword', $iRowInc, 'struct*', $tFound, _ 'dword', $iFirstDiffPix, 'dword', $iFirst_Diff_Inc, _ 'struct*', $tCornerInc, 'struct*', $tCornerPixs, _ 'dword', $iMax) Local $aCoords[$ret[0] + 1][4] = [[$ret[0], Round(TimerDiff($iTime))]] If Not $ret[0] Then Return SetError(0, 0, $aCoords) For $i = 1 To $ret[0] $iFoundIndex = ((DllStructGetData($tFound, 1, $i) - $pStart) / 4) + 1 $aCoords[$i][3] = Int(($iFoundIndex - 1) / $tSizeSource.X) $aCoords[$i][2] = ($iFoundIndex - 1) - ($aCoords[$i][3] * $tSizeSource.X) $aCoords[$i][0] = $tSizeFind.X $aCoords[$i][1] = $tSizeFind.Y Next $aCoords[0][1] = Round(TimerDiff($iTime)) Return SetError(0, 0, $aCoords) EndFunc ;==>_BmpSearchEx1 point