Leaderboard
Popular Content
Showing content with the highest reputation on 10/14/2021 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
-
Do you mean Y coordinates, or Z order ?1 point
-
Checked on Win11 Not happend to me. This can be related to some GFX problem and GFX setting in yours intalation. What GFX card you have ? Take a look for: SciTEUser.properties For example I use: font.quality=4 Which is not standard settings: https://www.scintilla.org/SciTEDoc.html Check also "technology" settings.1 point
-
Hello. I've checked and it seems to be AutoIt DllCall is failing maybe It's a bug( or it was not designed to handle structure as C++ Compilers). Here is a way to solve the issue. it supports x86 only. #AutoIt3Wrapper_UseX64 = no #include <Array.au3> #include <WinAPISys.au3> #include <WinAPIDiag.au3> #include <Memory.au3> #include <GDIPlus.au3> Global $__gh_DLL_IRL = -1 Enum _ $IR_OK, _ $IR_ERROR_UNKNOWN, _ $IR_ERROR_NOT_ENOUGH_MEMORY, _ $IR_ERROR_LOADING, _ $IR_ERROR_OBJECT, _ $IR_ERROR_DIMENSIONS, _ $IR_ERROR_NOT_AVAILABLE, _ $IR_ERROR_OCL_NOT_AVAILABLE, _ $IR_ERROR_OCL_NOT_INITIALIZED, _ $IR_ERROR_OCL_NO_SEARCH_IN_SET, _ $IR_ERROR_OCL_NO_SEARCH_FOR_SET, _ $IR_ERROR_NO_SEARCH_QUEUE_SET, _ $IR_ERROR_OCL_SET_SEARCH_IN, _ $IR_ERROR_OCL_SET_SEARCH_FOR, _ $IR_ERROR_NO_LOAD_QUEUE_SET #Status types Enum $IR_STATUS_PROGRESS #Compare type modes Enum _ $IR_COMPARE_TYPE_EXACT, _ ;Perform an exact search with an allowed pixel difference count. This requires that the search for bitmap is pixel identical with the search in bitmap, although you can set a "DifferenceTolerance" value to allow a concrete pixel count to differ. Exact mode is the fastest of the available modes. $IR_COMPARE_TYPE_RELATIVE_ARGB, _ ;Perform a search with an allowed pixel difference in Alpha-Red-Green-Blue color space. This mode is usefull when searching a similar picture in another picture. Setting a "DifferenceTolerance" value will allow a concrete pixel count to differ completly. This mode is slower than exact mode but faster than AHSL mode. $IR_COMPARE_TYPE_RELATIVE_AHSL, _ ;Perform a search with an allowed pixel difference in Alpha-Hue-Saturation-Lightness color space. AHSL component values range from 0 to 1. This mode is usefull when searching a similar picture in another picture but AHSL mode is required. Setting a "DifferenceTolerance" value will allow a concrete pixel count to differ completly. $IR_COMPARE_TYPE_RELATIVE_ARGB_ALPHA, _ ;Same as ARGB but the search for bitmap's pixels transparency value (alpha chanel) is considered when searching. Usefull when searching for a non-rectangular image, for example to find a logo put on a picture with transparency. Recommended that the search for bitmap is a PNG image with transparency. Slower then ARGB mode. $IR_COMPARE_TYPE_RELATIVE_AHSL_ALPHA ;Same as AHSL but the search for bitmap's pixels transparency value (alpha chanel) is considered when searching. Usefull when searching for a non-rectangular image, for example to find a logo put on a picture with transparency but AHSL mode is required. Recommended that the search for bitmap is a PNG image with transparency. This is the slowest of the available modes. #Queue modes Enum _ $IR_SEARCH_MODE_CPU, _ $IR_SEARCH_MODE_OPENCL, _ $IR_SEARCH_MODE_ANY #Queue threads Enum _ $IR_THREAD_PRIORITY_IDLE, _ $IR_THREAD_PRIORITY_LOWEST, _ $IR_THREAD_PRIORITY_LOWER, _ $IR_THREAD_PRIORITY_NORMAL, _ $IR_THREAD_PRIORITY_HIGHER, _ $IR_THREAD_PRIORITY_HIGHEST, _ $IR_THREAD_PRIORITY_TIMECRITICAL #Pre-process types Enum _ $IR_PROCESS_TYPE_NONE, _ $IR_PROCESS_TYPE_RESAMPLE #Pre-process resample modes Enum _ $IR_RESAMPLER_BOX, _ ; 0 // Box, pulse, Fourier window, 1st order (constant) b-spline $IR_RESAMPLER_BICUBIC, _ ; 1 // Mitchell & Netravali's two-param cubic filter $IR_RESAMPLER_BILINEAR, _ ;2 // Bilinear filter $IR_RESAMPLER_BSPLINE, _ ; 3 // 4th order (cubic) b-spline $IR_RESAMPLER_CATMULLROM, _ ; 4 // Catmull-Rom spline, Overhauser spline $IR_RESAMPLER_LANCZOS3 ; 5 // Lanczos3 filter #type LongBool Global Const $sIRDimensions = _ 'long Width;' & _ 'long Height' Global Const $sGUID = _ 'byte GUID[16]' Global Const $sIRObject = _ 'long Status;' & _ 'ptr lpszFileName;' & _ 'ptr pImageObject;' & _ 'struct ID;' & $sGUID & ';endstruct;' & _ 'struct OriginalDimensions;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'struct ProcessedDimensions;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'ptr User' Global Const $sIRCreateObjectParameters = _ 'long ProcessType;' & _ 'struct Dimensions;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'long Resampler' Global Const $sIRProcessParameters = _ 'long CompareType;' & _ 'byte ARGBATolerance;' & _ 'byte ARGBRTolerance;' & _ 'byte ARGBGTolerance;' & _ 'byte ARGBBTolerance;' & _ 'double AHSLATolerance;' & _ 'double AHSLHTolerance;' & _ 'double AHSLSTolerance;' & _ 'double AHSLLTolerance;' & _ 'long DifferenceTolerance;' & _ 'long StretchCompare;' & _ ;//* Stretch compare is experimental and very slow! 'struct MinimalStretchSize;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'struct MaximalStretchSize;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'long StretchResampler;' & _ 'long MultipleMatches;' & _ 'long MultiThreadedProcessing;' & _ 'long MultiThreadCount;' & _ ;//* 0 means all available CPU cores 'ptr StatusCallback;' & _ ; TIRStatusCallback *StatusCallback; 'long RotateSearch;' & _ 'float RotateSearchStartDegrees;' & _ 'float RotateSearchEndDegrees;' & _ 'float RotateSearchStepDegrees;' & _ 'long SearchSorroundingPixels' Global Const $sIRPoint = _ 'dword X;' & _ 'dword Y' Global Const $sIRResultMatches = _ 'struct Position;' & $sIRPoint & ';endstruct;' & _ ;TPoint 'struct Dimensions;' & $sIRDimensions & ';endstruct;' & _ ;TIRDimensions 'float Angle;' & _ 'long Difference;' & _ 'float MatchPercentage' Global Const $sIRResult = _ 'long Success;' & _ 'long MatchCount;' & _ 'ptr pMatches' ;OpenCL accelerated search right now is supported with IR_COMPARE_TYPE_EXACT and IR_COMPARE_TYPE_RELATIVE_ARGB_ALPHA. ;Rotate search is supported with only IR_COMPARE_TYPE_RELATIVE_ARGB_ALPHA. #Region 3 Steps ImageRecognition_StartUp() Local $TIRObject_SearchIn = ImageRecognition_CreateObject(@ScriptDir & '\SearchIn.bmp') ;_WinAPI_DisplayStruct($TIRObject_SearchIn, $sIRObject) Local $TIRObject_SearchFor = ImageRecognition_CreateObject(@ScriptDir & '\SearchFor.bmp') ;_WinAPI_DisplayStruct($TIRObject_SearchFor, $sIRObject) #Region ImageRecognition_Compare #typedef void (CALLBACK TIRStatusCallback)(double Progress, int StatusType, void *User); Local $sIRStatusCallback = 'double;long;ptr*' Local $hIRStatusCallback = DllCallbackRegister('IRStatusCallback', 'none', $sIRStatusCallback) Volatile Func IRStatusCallback($Progress, $StatusType, $User) ConsoleWrite("IRStatusCallback Progress: " & $Progress & @CRLF) EndFunc ;==>IRStatusCallback Local $TIRProcessParameters = DllStructCreate($sIRProcessParameters) $TIRProcessParameters.CompareType = $IR_COMPARE_TYPE_EXACT $TIRProcessParameters.MultipleMatches = True $TolerancePercent = 1 ; 0 - 99 $TIRProcessParameters.DifferenceTolerance = Int($TIRObject_SearchFor.Width * $TIRObject_SearchFor.Height * ($TolerancePercent / 100)) $TIRProcessParameters.MultiThreadedProcessing = 0 ;~ $TIRProcessParameters.StatusCallback = DllCallbackGetPtr($hIRStatusCallback) ;_WinAPI_DisplayStruct($TIRProcessParameters, $sIRProcessParameters) ;~ Local $TIRResultMatches = DllStructCreate($sIRResultMatches) ;_WinAPI_DisplayStruct($TIRResultMatches, $sIRResultMatches) Local $TIRResult = DllStructCreate($sIRResult) ;~ $TIRResult.pMatches = DllStructGetPtr($TIRResultMatches) ;_WinAPI_DisplayStruct($TIRResult, $sIRResult) #typedef int(IRLIBCALL *t_ImageRecognition_Compare)(TIRObject IRObjectSearchIn, TIRObject IRObjectSearchFor, TIRProcessParameters Parameters, TIRResult *CompareResult, void *User); Local $User = 0 # Danyfirex - This should work but it seems to be AutoIt DllCall doesn't handle big structures O_o ;~ $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_Compare', 'struct', $TIRObject_SearchIn, 'struct', $TIRObject_SearchFor, 'struct', $TIRProcessParameters, 'struct*', $TIRResult, 'ptr', $User) ;~ _ArrayDisplay($ret) #EndRegion ImageRecognition_Compare #So here is a ugly fix. (Just for x86) Local $hLibraryRec = _WinAPI_LoadLibrary("ImageRecognition.dll") Local $pFunctionRec = _WinAPI_GetProcAddress($hLibraryRec, "ImageRecognition_Compare") Local $sByteCode = "0x5589E56A00B8" & _SwapEndian(DllStructGetPtr($TIRResult)) & _ "5083EC68B91A0000008D35" & _SwapEndian(DllStructGetPtr($TIRProcessParameters)) & _ "89E7F3A583EC30B90C0000008D35" & _SwapEndian(DllStructGetPtr($TIRObject_SearchFor)) & _ "89E7F3A583EC30B90C0000008D35" & _SwapEndian(DllStructGetPtr($TIRObject_SearchIn)) & _ "89E7F3A5B8" & _SwapEndian($pFunctionRec) & _ "FFD089EC5DC3" Local $iRemoteCodeSize = BinaryLen($sByteCode) Local $pRemoteCode = _MemVirtualAlloc(0, $iRemoteCodeSize, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) Local $tCodeBuffer = DllStructCreate("byte[" & $iRemoteCodeSize & "]", $pRemoteCode) DllStructSetData($tCodeBuffer, 1, $sByteCode) DllCallAddress("int", $pRemoteCode) _MemVirtualFree($pRemoteCode, $iRemoteCodeSize, $MEM_DECOMMIT) Local $iMatchCount = $TIRResult.MatchCount ConsoleWrite("$iMatchCount: " & $iMatchCount & @CRLF) _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\SearchIn.bmp") Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) Local $hBrush = _GDIPlus_BrushCreateSolid(0x40FFFF00) Local $hPen = _GDIPlus_PenCreate(0xFFFF0000) Local $TIRResultMatches = 0 Local $pFirstMatch = $TIRResult.pMatches Local $pIncrement = DllStructGetSize(DllStructCreate($sIRResultMatches)) For $i = 0 To $iMatchCount - 1 $TIRResultMatches = DllStructCreate($sIRResultMatches, $pFirstMatch + ($i * $pIncrement)) ConsoleWrite("X: " & $TIRResultMatches.X & ", Y: " & $TIRResultMatches.Y & @TAB & _ "Width: " & $TIRResultMatches.Width & ", Height: " & $TIRResultMatches.Height & @TAB & "MatchPercentage: " & $TIRResultMatches.MatchPercentage & @CRLF) If $i = 1 Then _GDIPlus_GraphicsFillRect($hGraphics, $TIRResultMatches.X, $TIRResultMatches.Y, $TIRResultMatches.Width, $TIRResultMatches.Height, $hBrush) _GDIPlus_GraphicsDrawRect($hGraphics, $TIRResultMatches.X, $TIRResultMatches.Y, $TIRResultMatches.Width, $TIRResultMatches.Height, $hPen) $TIRResultMatches = 0 Next _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\SearchIn-Result.bmp") _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hImage) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_Shutdown() ShellExecute(@ScriptDir & "\SearchIn-Result.bmp") ImageRecognition_FreeObject($TIRObject_SearchFor) ImageRecognition_FreeObject($TIRObject_SearchIn) #EndRegion 3 Steps Func _SwapEndian($hex) Return Hex(Binary($hex)) EndFunc ;==>_SwapEndian Func ImageRecognition_StartUp($sDllPath = 'ImageRecognition.dll') If Not FileExists($sDllPath) Then Exit MsgBox(16, 'Fatal Error', 'Not found ' & $sDllPath) $__gh_DLL_IRL = DllOpen($sDllPath) If @error Or $__gh_DLL_IRL = -1 Then Exit MsgBox(16, 'Fatal Error', 'Could not open ' & $sDllPath) OnAutoItExitRegister(ImageRecognition_Shutdown) EndFunc ;==>ImageRecognition_StartUp Func ImageRecognition_Shutdown() DllClose($__gh_DLL_IRL) EndFunc ;==>ImageRecognition_Shutdown Func ImageRecognition_CreateObject($FilePath_or_Binary_or_hBitmap, $ProcessType = Default, $Resampler = Default, $Dimensions_Width = Default, $Dimensions_Height = Default) #Set Parameters Local $TIRCreateObjectParameters = DllStructCreate($sIRCreateObjectParameters) ;Pre-process the images: It can be usefull to resize the images when loading for faster processing and also usefull if you want to compare two images that differ in dimensions. When acquireing the picture object specify the "ProcessType" parameter of the "TIRCreateObjectParameters" structure to "IR_PROCESS_TYPE_RESAMPLE". And specify a resampler ("Resampler" variable). Resampling the images is performed by FreeImage.dll. If $ProcessType = Default Then $ProcessType = $IR_PROCESS_TYPE_NONE If $Resampler = Default Then $Resampler = $IR_RESAMPLER_BOX $TIRCreateObjectParameters.ProcessType = $ProcessType $TIRCreateObjectParameters.Resampler = $Resampler $TIRCreateObjectParameters.Width = $Dimensions_Width $TIRCreateObjectParameters.Height = $Dimensions_Height ;_WinAPI_DisplayStruct($TIRCreateObjectParameters, $sIRCreateObjectParameters) #T?o Struct nh?n Object Local $TIRObject = DllStructCreate($sIRObject) ;Local $tUser = DllStructCreate('byte[100]') ;$TIRObject.User = DllStructGetPtr($tUser) #T?o Object If IsBinary($FilePath_or_Binary_or_hBitmap) Then Local $lImage = BinaryLen($FilePath_or_Binary_or_hBitmap) Local $tImage = DllStructCreate('byte[' & $lImage & ']') DllStructSetData($tImage, 1, $FilePath_or_Binary_or_hBitmap) ;typedef int(IRLIBCALL *t_ImageRecognition_CreateObjectFromMemory)(void *Address, QWORD DataSize, TIRObject *IRObject, TIRCreateObjectParameters Parameters); Local $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_CreateObjectFromMemory', 'ptr', DllStructGetPtr($tImage), 'uint64', $lImage, 'struct*', $TIRObject, 'struct', $TIRCreateObjectParameters) ElseIf IsPtr($FilePath_or_Binary_or_hBitmap) Then ;typedef int(IRLIBCALL *t_ImageRecognition_CreateObjectFromBitmapHandle)(HBITMAP BitmapHandle, TIRObject *IRObject, TIRCreateObjectParameters Parameters); Local $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_CreateObjectFromBitmapHandle', 'handle', $FilePath_or_Binary_or_hBitmap, 'struct*', $TIRObject, 'struct', $TIRCreateObjectParameters) Else ;typedef int(IRLIBCALL *t_ImageRecognition_CreateObject)(LPWSTR FileName, TIRObject *IRObject, TIRCreateObjectParameters Parameters); Local $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_CreateObject', 'wstr', $FilePath_or_Binary_or_hBitmap, 'struct*', $TIRObject, 'struct', $TIRCreateObjectParameters) EndIf Local $err = @error #Clear Params _WinAPI_ZeroMemory($TIRCreateObjectParameters, DllStructGetSize($TIRCreateObjectParameters)) #Tr? k?t qu? If $err Or $ret[0] <> $IR_OK Then Return SetError(1) If Not @Compiled Then ConsoleWrite(_WinAPI_GetString($TIRObject.lpszFileName) & ' / ImageObj=' & $TIRObject.pImageObject & ' / W=' & $TIRObject.Width & ' / H=' & $TIRObject.Height & @CRLF) EndIf Return $TIRObject EndFunc ;==>ImageRecognition_CreateObject Func ImageRecognition_FreeObject(ByRef $TIRObject) If Not IsDllStruct($TIRObject) Then Return SetError(1) ;typedef int(IRLIBCALL *t_ImageRecognition_FreeObject)(TIRObject *IRObject); Local $ret = DllCall($__gh_DLL_IRL, 'long', 'ImageRecognition_FreeObject', 'struct*', $TIRObject) Local $err = @error _WinAPI_ZeroMemory($TIRObject, DllStructGetSize($TIRObject)) If Not @Compiled Then ConsoleWrite('Free: ' & _WinAPI_GetString($TIRObject.lpszFileName) & ' / ImageObj=' & $TIRObject.pImageObject & ' / W=' & $TIRObject.Width & ' / H=' & $TIRObject.Height & @CRLF) EndIf If $err Or $ret[0] <> $IR_OK Then Return SetError(2) EndFunc ;==>ImageRecognition_FreeObject PD: try to use correct parameters in structure tag You're using long where you should have bool etc. Saludos1 point
-
@JockoDundee : Funny video ! However, I could imagine that the enjoyment of this game would suffer a lot if you play it with the used paper I was talking about .1 point
-
Excel VBA - TextToColumns
SkysLastChance reacted to Subz for a topic
@creaciones, you should really open a new post rather than resurrect these old posts as AutoIt code has changed a lot since 2010. With that said here is a basic example of TextToColumns #include <Array.au3> #include <Excel.au3> #include <ExcelConstants.au3> $oExcel = _Excel_Open() $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\DemoData.csv") ;~ Column A = 16/03/2019 2:30 pm $oRange1 = $oWorkbook.ActiveSheet.Range("A:A") ;~ Source Range $oRange2 = $oWorkbook.ActiveSheet.Range("C:C") ;~ Destination Range ;~ Reference: https://www.oreilly.com/library/view/programming-excel-with/0596007663/re515.html $oRange1.TextToColumns($oRange2, $xlDelimited, $xlTextQualifierDoubleQuote, True, False, False, False, True, True, "/") ;~ Results ;~ Column C = Day ;~ Column D = Month ;~ Column E = Year ;~ Column F = Time ;~ Column H = Am/Pm1 point -
Counting the number of rows with data in an excel fille
SkysLastChance reacted to Subz for a topic
Do you have an example spreadsheet that displays the behavior? Haven't been able to replicated it myself. Also wouldn't CountA give you a more accurate count as it will skip any blanks? Example: $oRange = $oExcel.ActiveSheet.Range("A:A") MsgBox(4096, "Excel Count Non-Blank Cells", $oExcel.WorksheetFunction.CountA($oRange))1 point -
Couple of ways: #include <Excel.au3> ;~ Example 1 Local $oExcel = _Excel_Open() $oExcel.ActiveWindow.FreezePanes = False Local $sWorkbook = @ScriptDir & "\FileName.xlsx" Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) $oWorkbook.ActiveSheet.Range("B2").Select $oExcel.ActiveWindow.FreezePanes = True ;~ Example 2 Local $oExcel = _Excel_Open() $oExcel.ActiveWindow.FreezePanes = False Local $sWorkbook = @ScriptDir & "\FileName.xlsx" Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) _Excel_FreezePanes($oExcel, 2, 2) Func _Excel_FreezePanes($oExcel, $iCol = 0, $iRow = 1) If Not IsObj($oExcel) Or ObjName($oExcel, 1) <> "_Application" Then Return $oExcel.ActiveWindow.SplitColumn = $iCol $oExcel.ActiveWindow.SplitRow = $iRow $oExcel.ActiveWindow.FreezePanes = True EndFunc1 point