Leaderboard
Popular Content
Showing content with the highest reputation on 08/23/2023 in all areas
-
Wait until a window is a specified size?
emendelson and one other reacted to Nine for a topic
You can also do it in a single line : WinWait("[TITLE:window title here;W:1024;H:768]", "", 30) ; timeout of 30 secs2 points -
Advanced Pixel Search Library
robertocm reacted to FastFrench for a topic
As I was too limited by what was feasible with PixelSearch in Autoit, I wrote an optimized DLL in C++ for searching pixels on the screen. The most basic function allows you to find the pixel in a given color - as PixelSearch - but instead of returning the first found, it returns the closest to a given point. It can go much further: - Search for 'spot' the closest (NxN square containing P pixels that meet the criteria of color mentioned) - Maintains a list containing up to 1024 colors (search pixels with one color in this list) - Manages up to 1024 exclusion rectangles. We can define precisely the search pattern that you want (with a rectangle from which you "substract" several "exclusion rectangles"). You can have up to 1024 exclusion rectangles. - You can also set a 'shade variation' (same idea as with PixelSearch). - Can work on several 'snapshots' (screen captures) in memory. It is possible to retain up to 1024 snapshots simultaneously (of course, each capture consumes memory, so only use the "slots" you really need). - Works on full screen or specific window (HWND optionnal parameter) or part of it. - Also includes functions to identify the changes between two SnapShots (minimum rectangle containing all changes + number of pixels that have changed). Useful to detect movement on the screen, object state changes... - Fairly sophisticated tools provided for debugging are also included in the UDF. You can choose the type of logs you want, including the ability to view on screen the detected areas (most useful during development phasis) and record the transaction details in a log file. - For even more performance, you can capture the content of a screen memory (SnapShot, takes about the same time as or PixelSearch PixelGetColor) then do all the research you want in this snapshots (very fast functions : nearly 1000 times as fast as the native PixelGetColor). - [v1.4] : find the "best spot" - meaning the spot that has the best number of "right" colors. - [v1.4] : now provided with a tool, FFShowPixels.exe, to find colors, manage color lists, show all occurences of them on the Captured Window, and... automatically generates AutoIt or C++ code. - [v1.6] : Saves SnapShots on BitMaps (BMP and JPG supported) - [v1.6] : Modifies SnapShots with "filters" (Keep only some colors or only pixels that have changes. All other pixels can be turned to black). - [v1.7] : Can change pixels colors on SnapShots (SetPixel) - [v1.7] : Can access the Raw pixel data of SnapShots (GetRawData) - [v1.7] : Can draw back SnapShots on Screen. - [v1.8] : Bug fixes. Deleted - [v1.8.1] : Bug fixes (FastFind.au3). - [v1.8.2] : Bug fixes (FastFind.au3). - [v1.8.3] : Bug fixes (FastFind.au3). Deleted - [v1.8.4] : Should now run on early XP and Windows 2000 OS. - [v2.0] : Documentation file in english (FastFind.chm), several new functions and new feature on some old functions. - [v2.1] : Bug fixes (removed those nasty errors in message boxes) - [v2.2] : Bug fix Included in the archive: both the 32 bits and 64 bits dll (written in Visual C++ 2010), the AutoIt Wrapper, a demonstration script and a tiny Benchmark script. Here it is, your comments and suggestions are welcome. [updates/Changelog] Last Version : 2.2 FastFind 2_2.zip Version 2.2 Bug fixes FastFind 2_2.zip Version 2.1 Bug fixes FastFind 2_1.zip Version 2.0 A new documentation file, in chm format (thanks to CeramicWeasel) New functions : DrawSnapShotXY (same as DrawSnapShot, with specific top-left position for drawing). ComputeMeanValues (Gives mean Red, Green and Blue values of a SnapShot) ApplyFilterOnSnapShot (apply a AND filter on each pixels in the SnapShot) FFGetRawData (provide access to all pixel data) ShadeVariation parameter added in the following functions : KeepChanges LocalizeChanges HasChanged FastFind 2_0.zip jan 5 2012: ShowPixel Link should work now ?do=embed' frameborder='0' data-embedContent> Version 1.8 -> bug fixes Updates : FastFind 1_8_4.zip Version 1.7 -> bug fix with client coordinates -> Can change pixels colors on SnapShots (SetPixel) -> Can access the Raw pixel data of SnapShots (GetRawData). Not that this feature is not allready wrapped into autoit: you have to do it with dllcall. -> Can draw back SnapShots on Screen (DrawSnapShot). -> New function to duplicate a SnapShot (DuplicateSnapShot) FastFind 1_7.zip FFShowPixels + FastFind complete 1.7 package : ?do=embed' frameborder='0' data-embedContent> Version 1.6 -> bug fix (restriction rectangles + FFColorCount) -> New functions to export captures into BMP or JPEG Files -> New functions to create SnapShots with changes or selected colors from a previous SnapShot(FFKeepChanges & FFKeepColors). FFShowPixels1_6 wo FFShowPixels.zip Version 1.5 -> FFGetPixel bug fix. FastFind1_5.zip (Update) Version 1.4 -> A new optional parameter in SetHWnd : You can now choose to take either the full Window or only the Client area of the window. -> Several bug fixes (more reliable and consistent) -> A new search fonction : FFBestSpot. It will find the spot that contains the most "good" pixels. -> A new tool - ShowPixels.exe - will allow you to easily manage list of colors (find them on the screen, make stats...) and automatically generate AutoIt or C++ code from them. Unfortunately, the zip is too big to include ShowPixel.exe in it. So if you want this tool, just ask with pm or mail. (Update) Version 1.3 -> comments in demo scripts now in english -> Some minor bug fixed -> now both 32 bits and 64 bits dll are provided -> Several function calls are now more simple to use : the x1,y1,x2,y2 limits of the area for search functions are now optional. Default values means full window (or screen)) ** Warning ** I've changed the order of the parameters in some fonctions, to make them easier to use. So if you use any of the 3 following function, you will need to reorder the parameters if you want to update to the version 1.3 of FastFind. Func FFNearestPixel($PosX, $PosY, $Color, $Left=0, $Top=0, $Right=0, $Bottom=0, $ForceNewSnap=true, $NoSnapShot=$FFLastSnap, $WindowHandle=-1) Func FFNearestSpot($SizeSearch, $NbPixel, $PosX, $PosY, $Color, $ShadeVariation=0, $Left=0, $Top=0, $Right=0, $Bottom=0, $ForceNewSnap=true, $NoSnapShot=$FFLastSnap, $WindowHandle=-1) Func FFColorCount($ColorToCount, $ShadeVariation=0, $Left=0, $Top=0, $Right=0, $Bottom=0, $ForceNewSnap=true, $NoSnapShot=$FFLastSnap, $WindowHandle=-1) (Update) Version 1.2 I hope these library will prove useful. Please tell me how you use it and how you like it. FF1 point -
MousePointerWithCircle
ioa747 reacted to argumentum for a file
Version 0.0.0.3
1,437 downloads
This started in help thread. ( https://www.autoitscript.com/forum/topic/210715-special-effect-for-the-mouse-cursor ) Moved the files here, so I can free the user forum file quota. The ini file has the comments to get you going. What is not there is that you can run this again and will close the one loaded before, add to that, that you can declare an ini file as a command and you can test different settings. Hence can create shortcuts with different ini profile files. Ex: MousePointerWithCircle.exe MousePointerWithCircle_NoRing.ini The compiled ZIP, is compiled with v3.2 to run anywhere. There are 2 pictures of it running on Windows 2000 just to show. And yes, it runs in all versions of Windows, including the current, Windows 11. That is something the newer versions of AutoIt no longer support.1 point -
You can use _FileListToArrayRec() to get all files with certain extensions into an array and then loop through the array and use FileCopy().1 point
-
Wait until a window is a specified size?
emendelson reacted to Andreik for a topic
It would be fairly simple: Local $hWin = WinGetHandle('Title of your window') Local $aPos Local $iWidth = 1024 Local $iHeight = 768 Do $aPos = WinGetPos($hWin) Sleep(10) Until $aPos[2] = $iWidth And $aPos[3] = $iHeight ; Do your other stuff ; Send your keystroke1 point -
Solved! I managed to get all the html it generates returned by changing the "SetRequestHeaders" and therefore also the type of response that the server provides me. Obviously now I have to redo all the response parsing work (it no longer responds in json) but I can see everything and it's what I needed. I report below the code that I changed in case it is also useful to someone else Original: $oHTTP.Open("GET", $url&"/dynamic_load/0", False) $oHTTP.SetRequestHeader("Accept", "application/json") $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status Consolewrite($oReceived & @crlf) Modified: $oHTTP.Open("GET", $url&"/dynamic_load/0", False) $oHTTP.SetRequestHeader("Accept", "text/html, application/xhtml+xml, image/jxr, */*") $oHTTP.SetRequestHeader("Accept-Encoding", "zip, deflate, text/html, application/xhtml+xml, image/jxr, */*") $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko") $oHTTP.SetRequestHeader("Referer", $url) $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status Consolewrite($oReceived & @crlf) Thanks Marco1 point
-
Since I have been programming with Freebasic for several years, I would like to say that Freebasic has many advantages compared to Autoit, such as speed (compiler), inline assembler, multi-platform, open source, etc.. Autoit on the other hand scores in terms of UDFs, i.e. a large part of WinAPI is implemented in UDFs, whereas in FB you have to create everything yourself. Both languages are relatively easy to learn, a BASIC language, have good IDEs and are easy to install (no gigabytes of installation!) BASIC languages are unfortunately outdated and replaced by other languages. I personally work primarily with both languages and I am completely satisfied.1 point
-
Special effect for the mouse cursor.
pixelsearch reacted to Nine for a topic
Another way with pretty much the same original script : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> Opt("MustDeclareVars", True) HotKeySet("^!{ESC}", _Exit) ; ctrl-alt Esc Local $hGui = GUICreate("", 100, 100, 0, 0, $WS_POPUp, $WS_EX_TRANSPARENT + $WS_EX_TOPMOST) GUISetBkColor(0xFFEA00) ; * <-- set the color GUISetState() Local $aPos = WinGetPos($hGui) Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $aPos[2], $aPos[3], $aPos[2], $aPos[3]) Local $hRgn2 = _WinAPI_CreateRoundRectRgn(5, 5, $aPos[2]-5, $aPos[3]-5, $aPos[2]-5, $aPos[3]-5) _WinAPI_CombineRgn($hRgn, $hRgn, $hRgn2, $RGN_DIFF) _WinAPI_SetWindowRgn($hGui, $hRgn) _WinAPI_DeleteObject($hRgn2) Local $iX = $aPos[0], $iY = $aPos[1], $iCount = 0 While Sleep(20) $aPos = MouseGetPos() If $iX <> $aPos[0] Or $iY <> $aPos[1] Then WinMove($hGui, "", $aPos[0] - 50, $aPos[1] - 50) WinSetTrans($hGui, '', 100) $iX = $aPos[0] $iY = $aPos[1] $iCount = 0 Else If $iCount = 10 Then ContinueLoop $iCount += 0.5 ; set speep of vanishing here WinSetTrans($hGui, '', 100 - ($iCount * 10)) EndIf WEnd Func _Exit() Exit EndFunc ;==>_Exit1 point -
You might build a 2D array $txt = "PS C:\> Dism /Get-ImageInfo /ImageFile:H:\sources\install.wim /English /Format:Table" & @crlf & _ @crlf & _ "Deployment Image Servicing and Management tool" & @crlf & _ "Version: 10.0.19041.844" & @crlf & _ @crlf & _ "Details for image : H:\sources\install.wim" & @crlf & _ @crlf & _ "Index : 1" & @crlf & _ "Name : Windows Server 2016 Standard" & @crlf & _ "Description : This option (recommended) reduces management and servicing by installing only what is needed to run most server roles and applications. It does not include a GUI, but you can fully manage the server locally or remotely with Windows PowerShell or other tools. For more details see ""Windows Server Installation Options.""" & @crlf & _ "Size : 9,180,501,839 bytes" & @crlf & _ @crlf & _ "Index : 2" & @crlf & _ "Name : Windows Server 2016 Standard (Desktop Experience)" & @crlf & _ "Description : This option is useful when a GUI is required—for example, to provide backward compatibility for an application that cannot be run on a Server Core installation. All server roles and features are supported. For more details see ""Windows Server Installation Options.""" & @crlf & _ "Size : 15,196,490,590 bytes" & @crlf & _ @crlf & _ "Index : 3" & @crlf & _ "Name : Windows Server 2016 Datacenter" & @crlf & _ "Description : This option (recommended) reduces management and servicing by installing only what is needed to run most server roles and applications. It does not include a GUI, but you can fully manage the server locally or remotely with Windows PowerShell or other tools. For more details see ""Windows Server Installation Options.""" & @crlf & _ "Size : 9,175,696,563 bytes" & @crlf & _ @crlf & _ "Index : 4" & @crlf & _ "Name : Windows Server 2016 Datacenter (Desktop Experience)" & @crlf & _ "Description : This option is useful when a GUI is required—for example, to provide backward compatibility for an application that cannot be run on a Server Core installation. All server roles and features are supported. For more details see ""Windows Server Installation Options.""" & @crlf & _ "Size : 15,198,865,664 bytes" & @crlf & _ @crlf & _ "The operation completed successfully." ; Msgbox(0,"", $txt) #Include <Array.au3> ;$txt = ClipGet() $a = StringRegExp($txt, 'Index : (\d+)\RName : (\N+)', 3) Local $res[UBound($a)/2][2] For $i = 0 to UBound($res)-1 $res[$i][0] = $a[$i*2] $res[$i][1] = $a[$i*2+1] Next _ArrayDisplay($res)1 point
-
If you look at the raw data in the string $sHex, it looks like the image has loaded with 32 bit colours with a RRGGBBAA colour format. The AA being the alpha channel. All the colours have "FF" in the alpha channel meaning that the RGB colour is fully opaque. The search only needed to return the RGB colour. This is my explanation of what I found in the $sHex string, and I hope that the colours are not really in ARGB format, and I've screwed something up. Here is an example of two functions One converts RGB to CMYK - the RGBToCMYK () function, and the other converts CMYK to RGB - the CMYKToRGB () function. It is not completely accurate. A small error can be seen on some of the darker colours. #include <Math.au3> $Black = RGBToCMYK("000000") $Yellow = RGBToCMYK("FFFF00") $Mag = RGBToCMYK("FF00FF") $Cyan = RGBToCMYK("00FFFF") $Mar = RGBToCMYK("8B1C62") $Dark = RGBToCMYK("011C02") MsgBox(0, "Converts RGB Colour to CMYK and then converts CMYK to RGB", _ "RGB Colour black 0x000000 = CMYK " & $Black & " -> RGB " & CMYKToRGB($Black) & @CRLF & @CRLF & _ "RGB Colour yellow 0xFFFF00 = CMYK " & $Yellow & " -> RGB " & CMYKToRGB($Yellow) & @CRLF & @CRLF & _ "RGB Colour magenta 0xFF00FF = CMYK " & $Mag & " -> RGB " & CMYKToRGB($Mag) & @CRLF & @CRLF & _ "RGB Colour cyan 0x00FFFF = CMYK " & $Cyan & " -> RGB " & CMYKToRGB($Cyan) & @CRLF & @CRLF & _ "RGB Colour maroon 0x8B1C62 = CMYK " & $Mar & " -> RGB " & CMYKToRGB($Mar) & @CRLF & @CRLF & _ "RGB a dark colour 0x011C02 = CMYK " & $Dark & " -> RGB " & CMYKToRGB($Dark) & @CRLF & @CRLF) ;http://www.autoitscript.com/forum/index.php?s=&showtopic=54567&view=findpost&p=413494 ; RGBToCMYK() by corz ; ; Very simple calculations. Basically, rgb is "additive" color, and ; CMYK is "subtractive", in other words, with CMYK, you start with ; white, and work up to black (paper) substracting brightness; and ; with rgb, you start with black, and work up to white (peecee monitor), ; adding brightness. So it's the same, but backwards. You could do it ; on your fingers. ; ; Set the optional second paramter to True get the values "normalized", ; that is, re-scaled to percentages, which is a commonly found CMYK format. ; ; Returns a comma-delimited string; "c,m,y,k", e.g. "0.761,0.08,0,0.016" ; By the way, that same value "normalized", is.. "76.1,8,0,1.6" ; Modified Malkey Func RGBToCMYK($rgb_color, $norm = 1) If $rgb_color = "000000" Then Local $k = 1, $c = 0, $m = 0, $y = 0 Else ; get decimal rgb values and scale to 0-1.. $rc_r = (Dec(StringLeft($rgb_color, 2))) / 255 $rc_g = Dec(StringMid($rgb_color, 3, 2)) / 255 $rc_b = Dec(StringRight($rgb_color, 2)) / 255 ConsoleWrite("$rc_b " & $rc_b & @CR) $k = _Min(_Min(1 - $rc_r, 1 - $rc_g), 1 - $rc_b) ConsoleWrite(" $k " & $k & @CR) $c = (1 - $rc_r - $k) / (1 - $k) $m = (1 - $rc_g - $k) / (1 - $k) $y = (1 - $rc_b - $k) / (1 - $k) ConsoleWrite(" $y " & $y & @CR) EndIf If $norm Then Return Round($c * 100, 1) & ", " & Round($m * 100, 1) & ", " & Round($y * 100, 1) & ", " & Round($k * 100, 1) Else Return Round($c, 3) & ", " & Round($m, 3) & ", " & Round($y, 3) & ", " & Round($k, 3) EndIf EndFunc ;==>RGBToCMYK ; Not by corz Func CMYKToRGB($cmyk_color) Local $k, $rc_r, $rc_g, $rc_b, $rgb_color $aCMCK = StringRegExp(StringStripWS($cmyk_color, 8) & ",", "([0-9.]+),", 3) If $aCMCK[3] > 1 Or $aCMCK[0] > 1 Or $aCMCK[1] = 0 Or $aCMCK[2] > 1 Then $aCMCK[0] = $aCMCK[0] / 100 $aCMCK[1] = $aCMCK[1] / 100 $aCMCK[2] = $aCMCK[2] / 100 $aCMCK[3] = $aCMCK[3] / 100 EndIf If $aCMCK[3] = 1 And $aCMCK[0] = 0 And $aCMCK[1] = 0 And $aCMCK[2] = 0 Then $rgb_color = "000000" Else $k = $aCMCK[3] $rc_r = ($aCMCK[0] - 1) * (-1 + $k) * 255 $rc_g = ($aCMCK[1] - 1) * (-1 + $k) * 255 $rc_b = ($aCMCK[2] - 1) * (-1 + $k) * 255 $k = $k * 255 If $rc_r < 0 Then $rc_r = $k If $rc_g < 0 Then $rc_g = $k If $rc_b < 0 Then $rc_b = $k $rgb_color = Hex(Ceiling($rc_r), 2) & Hex(Ceiling($rc_g), 2) & Hex(Ceiling($rc_b), 2) EndIf Return $rgb_color EndFunc ;==>CMYKToRGB1 point
-
Black is colour 0x000000, in the RGB and BGR colour systems. 0x010101 may look black, and if searching for black,0x000000 will not find 0x010101. This example scripts finds all colours in an image file below 0x202020. You may be able to change it to suit your needs. ;========================================================= ; Produces an array of pixel colours used in an image that are below the colour 0x202020 (array[n][0]), ; Number of times that colour is used (array[n][1]), and, ; the percentage of the numer of times the colour is used over the total number of pixels in the image (array[n][2]). ; Array[0][0] contains the number of unique pixels used in the image below 0x202020 colour. ; Array[0][1] contains the total number of pixels used in the image below 0x202020 colour. ; Array[0][2] contains the percentage of the total number of pixels used in the image below 0x202020 colour. ;============================================================ #include <WinAPI.au3> #include <ScreenCapture.au3> #include <GDIPlus.au3> #include <Array.au3> Dim $pixels, $iTotalReplace Local $Path = FileOpenDialog("Choose Image File", @ScriptDir & "", "Images (*.gif;*.png;*.jpg;*.bmp)| All (*.*)") If $Path <> "" Then _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($Path) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $aSize = DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBmp, 'int', 0, 'ptr', 0) If $aSize[0] Then $tBits = DllStructCreate('byte[' & $aSize[0] & ']') DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBmp, 'int', $aSize[0], 'ptr', DllStructGetPtr($tBits)) $sHex = Hex(DllStructGetData($tBits, 1)) ; Selects all pixels below/less than 0x202020 $pixels = StringRegExp($sHex, "([01][0-9A-F][01][0-9A-F][01][0-9A-F])FF", 3) ; Selects all pixels below/less than 0x505050 (Can take a while) ;$pixels = StringRegExp($sHex, "([0-5][0-9A-F][0-5][0-9A-F][0-5][0-9A-F])FF", 3) $sHexReduced = _ArrayToString($pixels) & "|" Dim $pixels[1][3] While StringLen($sHexReduced) > 6 ReDim $pixels[UBound($pixels) + 1][3] $PixTemp = StringLeft($sHexReduced, 7) $sHexReduced = StringReplace($sHexReduced, $PixTemp, "", 0) $numreplacements = @extended $pixels[UBound($pixels) - 1][1] = $numreplacements $pixels[UBound($pixels) - 1][0] = StringTrimRight($PixTemp, 1) $pixels[UBound($pixels) - 1][2] = StringFormat("%1.4f%%", $numreplacements * 100 / ($height * $width)) $iTotalReplace += $numreplacements WEnd $pixels[0][0] = UBound($pixels) - 1 $pixels[0][1] = $iTotalReplace $pixels[0][2] = StringFormat("%1.4f%%", $iTotalReplace * 100 / ($height * $width)) EndIf _ArraySort($pixels, 0, 1, 0, 0) _ArrayDisplay($pixels,$Path) _WinAPI_DeleteObject($hBmp) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndIf Edit: Added & "|" to $sHexReduced = _ArrayToString($pixels) & "|" . At the end of the loop $sHexReduced is now empty.1 point