Leaderboard
Popular Content
Showing content with the highest reputation on 02/16/2025 in all areas
-
Regarding speed maybe it makes a difference with stretchblt directly going to a smaller size instead of bitblt Example for screenshot in a smaller size. #include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Func CaptureAndResize($savePath, $newWidth, $newHeight) ; GDI+ initialiseren _GDIPlus_Startup() ; Schermresolutie ophalen Local $iScreenWidth = @DesktopWidth Local $iScreenHeight = @DesktopHeight ; HDC's ophalen Local $hDC = _WinAPI_GetDC(0) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) ; Bitmap maken Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iScreenWidth, $iScreenHeight) Local $hOldObj = _WinAPI_SelectObject($hMemDC, $hBitmap) ; Scherminhoud kopiëren met StretchBlt (resize mogelijk) _WinAPI_StretchBlt($hMemDC, 0, 0, $newWidth, $newHeight, $hDC, 0, 0, $iScreenWidth, $iScreenHeight, $SRCCOPY) ; Screenshot opslaan als bestand _ScreenCapture_SaveImage($savePath, $hBitmap) ; Opruimen _WinAPI_SelectObject($hMemDC, $hOldObj) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _WinAPI_ReleaseDC(0, $hDC) _GDIPlus_Shutdown() EndFunc ; Gebruik de functie om een screenshot te maken en te resizen naar 800x600 CaptureAndResize(@UserProfileDir & "\downloads\examples\" & "screenshot_resized.jpg", 800, 600)2 points
-
Solve possible crash after deletion. New version available1 point
-
I already tried that with my method, with no good result, to much information is lost no matter how i tried resizing it, tried all the filters and different sizes, but maybe it'll work using another method, like checksum as you mentioned earlier, and stuffed in a lookup table Though, my method already only reads 28 times, so it would have to be resized to something smaller than 28 pixels in a square to be faster. Putting a timer into my GetNumber() function i get insanely fast times like... Func Getnumber($result) $t2 = TimerInit() Local $code[4] = [0,0,0,0], $value = 64 DllCall('gdi32.dll', 'dword', 'GetBitmapBits', 'ptr', $capture, 'dword', DllStructGetSize($pixels), 'ptr', DllStructGetPtr($pixels)) For $loop = 1 To 2816 Step 440 $code[0] += DllStructGetData($pixels, 1, $loop ) > 4278190080 ? $value:0 $code[1] += DllStructGetData($pixels, 1, $loop+29) > 4278190080 ? $value:0 $code[2] += DllStructGetData($pixels, 1, $loop+58) > 4278190080 ? $value:0 $code[3] += DllStructGetData($pixels, 1, $loop+87) > 4278190080 ? $value:0 $value /= 2 Next Consolewrite("Time: " & TimerDiff($t2) & @crlf) Return String($digit[$code[0]]) & String($digit[$code[1]]) & String($digit[$code[2]]) & String($digit[$code[3]]) EndFunc Time: 0.0582 Time: 0.0583 Time: 0.0804 Time: 0.0641 Time: 0.0816 Time: 0.0582 Time: 0.0581 it's the other stuff that takes longer, here times I get for a full run. 6.0095 6.9233 6.9252 6.8122 7.2931 6.7959 6.9708 ..with the bitblt stuff. Maybe later I'll try making the getnumber() func into a C Dll, though with only 28 checks it's hardly gonna be worth it. 😛1 point
-
Cleaned up demo script Added some choices in the GUI to play around with understanding on whats happening with bits, bytes, string 8x8 resizing to compare less bits #include <GDIPlus.au3> #include <WinAPI.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ScreenCapture.au3> ;~ These are the magic bytes for the 8x8 resized image to identify the numbers 0-9 ;~ You can learn them by feeding 10 images having 0-9 at the 1 position (so 2nd character as first is a space global $digits[10] = [ _ '0x0002222002000022020002220200202002002020022000202200002000222200', _ '0x0000200000222000000020000000200000022000000200000002000000222200', _ '0x0002222002000022000000220000220000002200002000002200000022222220', _ '0x0002222002000022000000220000220000002200000000202200002000222200', _ '0x0000022000002200002202000200020002000200022222200000220000002200', _ '0x0222222202000000022222000000002000000020000000202200002000222200', _ '0x0000222000220000020000000222220002222200020000202200002000222200', _ '0x0222222200000022000002000000200000002000002000000020000000200000', _ '0x0002222002000022020000220022220000222200020000202200002000222200', _ '0x0002222002000022020000220022222200222220000000200000220000220000' _ ] local $charWidth=29 ;~Important as thats the width of te consecutive digits on screen ;~ Dont move the window during analysis as then the calculation of the matrix will be off as we dont recalculate every time dim $bmpData, $w, $h, $s dim $pic[10],$BitmapFilename, $hImage, $Bmp ; Initialize GDI+ library _GDIPlus_Startup() #Region ### START Koda GUI section ### Form= $frmCompare = GUICreate("Another bitmap brute-forcing thread", 1280, 768, 193, 125) ;~ Put all the pictures on screen for $picId=0 to 9 $BitmapFilename = @UserProfileDir & "\downloads\examples\" & string($picId) & ".png" $pBitmap = _GDIPlus_BitmapCreateFromFile($BitmapFilename) $hImage=_GDIPlus_ImageLoadFromFile($BitmapFilename) $Bmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) ;~ $hBitmap = _GDIPlus_ImageLoadFromFile($BMPFile) $Pic[$picId] = GUICtrlCreatePic("", 32, 24+($picId*60), 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) _WinAPI_DeleteObject(GUICtrlSendMsg($Pic[$picId], $STM_SETIMAGE, $iMAGE_BITMAP, $Bmp)) Next ;~ Box for analyzing showing the information $editBox = GuiCtrlCreateEdit("Analytics box", 450,14,700,750) GUICtrlSetFont($editBox, 8, 100, 0, "Courier New") Local $idLearnCheckbox = GUICtrlCreateCheckbox("Learn the digits", 44, 640, 125, 25) Local $idShowCheckbox = GUICtrlCreateCheckbox("Show the bits/highlight", 44, 672, 125, 25) Local $idSlowCheckbox = GUICtrlCreateCheckbox("Slow down", 44, 704, 95, 25) $ButtonAnalyze = GUICtrlCreateButton("Analyze", 44, 730, 75, 25, 0) $Button2 = GUICtrlCreateButton("Button2", 104, 730, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #region ### While the GUI ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Exit Case $ButtonAnalyze analyse(_IsChecked($idLearnCheckbox), _IsChecked($idShowCheckbox), _IsChecked($idSlowCheckbox)) Case $Button2 EndSwitch WEnd #EndRegion Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked func analyse($learnTheDigits=false, $showDigits=true, $slowDown=false) ;~ local $learnTheDigits=false ;~Use this to learn the 0-9 digit magic values ;~ local $showDigits=true ;~ For showing the bits in detail to show whats happening ;~ local $slowDown=false ;~ With or without sleep waiting local $charLow=1, $charHigh=1 ;~ For learning which areas to analyse WinActivate($frmCompare) Local $wPos = WinGetPos($frmCompare) ;~ $aArray[0] = X position $aArray[1] = Y position $aArray[2] = Width $aArray[3] = Height Local $aClientSize = WinGetClientSize($frmCompare) ;~ $aArray[0] = Width of window's client area $aArray[1] = Height of window's client area Local $cLeft= ($wpos[2]-$aClientSize[0])/2 Local $cTop= ($wPos[3]-$aClientSize[1])-2 Local $bytesPerDigit = 1 ;~ could be 1 or 2 or 3 bytes for $picId=0 to 9 Local $cPos = ControlGetPos ( $frmCompare, "", $pic[$picId] ) ;~ $aArray[0] = X position ;~ $aArray[1] = Y position ;~ $aArray[2] = Width ;~ $aArray[3] = Height if ($learnTheDigits = false) Then $charLow=0 $charHigh=5 EndIf for $charId=$charlow to $charHigh ;~ Calculate the matrix where the digit is based on the control where the picture is in, as absolute coordinates so window location also in the calculation local $leftMatrix=($charId*$charWidth)+$wpos[0]+$cLeft+$cPos[0] local $rightMatrix=$charWidth+($charId*$charWidth)+$wPos[0]+$cLeft+$cPos[0] local $topMatrix= $wPos[1] + $cTop +$cPos[1] + 10 local $bottomMatrix=$wPos[1] + $cTop + $cPos[1] + $cPos[3] -2 -11 local $x, $y Local $bytesDataForDigit="", $widthMatrix=0, $heightMatrix=0, $stride=0 ;~ Func GetImageDataFromScreen($left, $right, $top, $bottom, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $picIdmgBytes=3) ;~Play with this to take a smaller area GetImageDataFromScreen($leftMatrix, $topMatrix, $rightMatrix, $bottomMatrix, $bytesDataForDigit, $widthMatrix, $heightMatrix, $stride, $bytesPerDigit) ;~ consolewrite(BinaryLen($bytesDataForDigit) & " " & stringlen($bytesDataForDigit) & " " & $widthMatrix & "-" & $heightMatrix & "-" & $stride &@CRLF) local $stringForDigit=string($bytesDataForDigit) if ($learnTheDigits=true) then consolewrite("'" & $stringforDigit & "', _") Else $num=getNumber($stringForDigit) consolewrite($num) EndIf if ($showDigits=true) then showDigitInEditbox($stringForDigit, $heightMatrix, $stride) ;~ Not working propertly? ;~ local $checkSum=PixelChecksum($leftMatrix, $rightMatrix , $topMatrix, $bottomMatrix, 1, 0 ,1) ;~ Just draw a redbox around what we are analysing ;~ Minus 4 just as it influences the next screenshot _Screen_DrawRect( $leftMatrix, $rightMatrix-4 , $topMatrix, $bottomMatrix) if $SlowDown then SLEEP (100) EndIf Next consolewrite(@crlf) Next EndFunc func showDigitInEditbox($stringForDigit, $heightMatrix, $stride) local $textoutput $textOutput=stringmid($stringForDigit,3) $textOutput=StringRegExpReplace($textOutput,"[0-9a-z]{8}","$0"&@CRLF) $textOutput=StringReplace($textoutput,"0",".") ;~ $textOutput=StringRegExpReplace($textOutput,"[1-9A-Za-z]+","X") ControlSetText("","",$editBox,$textOutput) EndFunc func getNumber($stringForDigit) local $num=" " for $i=0 to 9 if ($digits[$i]=$stringForDigit) then return $i next return $num EndFunc Func GetImageDataFromScreen($left, $top, $right, $bottom, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $picIdmgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle, $bitMapdata, $pixelFormat ; Capture screen to load the bitmap to search in ;~ _ScreenCapture_Capture(@UserProfileDir & "\downloads\examples\test.png",$left, $top, $right, $bottom,False) ;~ _ScreenCapture_Capture("",$left, $top, $right, $bottom,False) $hbScreen=_ScreenCapture_Capture("",$left, $top, $right, $bottom,False) local $pBitmap1 = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap _WinAPI_DeleteObject($hbScreen) ;release GDI bitmap resource because not needed anymore Local $pBitmap= _GDIPlus_ImageResize($pBitmap1, 8, 8) ;resize image ;~ Local $pBitmap= _GDIPlus_ImageResize($pBitmap1, 4, 4) ;resize image ;~ Local $pBitmap= _GDIPlus_ImageScale($pBitmap1, 0.15, 0.15) ;resize image ;Get $tagGDIPBITMAPDATA structure ;~ ConsoleWrite("Bitmap Width: " & _GDIPlus_ImageGetWidth($pBitmap) & @CRLF ) ;~ ConsoleWrite("Bitmap Height: " & _GDIPlus_ImageGetHeight($pBitmap) & @CRLF) ;~ 24 bits (3 bytes) or 16 bits (2 bytes) comparison or 1 byte local $iFormat=$GDIP_PXF16RGB555 if ($picIdmgBytes=1) then $iFormat=$GDIP_PXF04INDEXED if ($picIdmgBytes=2) then $iFormat=$GDIP_PXF16RGB555 if ($picIdmgBytes=3) then $iFormat=$GDIP_PXF24RGB $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $iFormat) If @ERROR Then MsgBox(0,"","Error locking region " & @error) $Stride = DllStructGetData($BitmapData, "Stride");Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. $Width = DllStructGetData($BitmapData, "Width");Image width - Number of pixels in one scan line of the bitmap. $Height = DllStructGetData($BitmapData, "Height");Image height - Number of scan lines in the bitmap. $PixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap $Scan0 = DllStructGetData($BitmapData, "Scan0");Scan0 - Pointer to the first (index 0) scan line of the bitmap. $pixelData = DllStructCreate("ubyte lData[" & (abs($Stride) * $Height) & "]", $Scan0) $BMPDataStart = $BMPDataStart & DllStructGetData($pixeldata,"lData") _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose ($pBitmap) _WinAPI_DeleteObject ($pBitmap) _WinAPI_DeleteObject ($hbScreen) EndFunc;==>GetImage ; Draw rectangle on screen. Func _Screen_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 1) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = $tLeft $x2 = $tRight $y1 = $tTop $y2 = $tBottom $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_UIA_DrawRect1 point
-
In this thread, it was discussed how to intercept the special Func keys press (Fn keys like muting speakers) coming from laptop and keyboards. It has always been a challenge to find a way to perform such task. The solution was passing through the monitoring of OutputDebugString API messages. Using this UDF, it was possible to read the debug stream coming from any process and see when a Fn key was pressed. The problem with the UDF is that it requires a DLL and there is no support to x64. Looking the C++ code, it became clear that there was no need for C++ DLL as the code was simply requesting a few WinAPI. So here's a rewrite of the code solely in AutoIt. For those interested into the mechanics of the OutputDebugString API, you can read about the protocol here. The original code can be found there. Included in the file is the UDF and a simple Debug Event Viewer. DebugViewer.zip1 point
-
My understanding is: AutoIt is a wrapper for Windows functions. The documentation describes the AutoIt language. It ends where the Windows documentation starts.1 point
-
Come to think of it, if you used the loop you posted for the other tool with 3 digits from your first thread, then you might have gotten wrong results, as the "Do" in the Do-Until loop is placed wrong, if an error/false positive occur then it repeats and ControlClick's one more time, thereby changing the number it was supposed to be checking, so if you had gotten 37 false positives you would have ControlClicked 1000037 times instead of 1000000 times, missing out on some, causing the order of the results to be out of sync... For $loop = 0 To 999999 Do $serial = StringFormat('%06i', $loop) ControlClick($tool, "", "TTabSheet1", "primary", 1, 100, 100) $hDDC = _WinAPI_GetDC(0) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBmp = _WinAPI_CreateCompatibleBitmap($hDDC, 34, 20) _WinAPI_SelectObject($hCDC, $hBmp) ;Do should be here _WinAPI_BitBlt($hCDC, 0, 0, 34, 20, $hDDC, $posx, $posy, 0x00CC0020) _WinAPI_DeleteDC($hCDC) $result = GetNumber($result) Until ((StringLen($result) = 4) and StringIsDigit($result)) FileWrite($db, $serial & "," & $result & @LF) Next We have changed it in this new version, just concerned that you used it in your first thread about the tool with 3 digits, then you'd have a wrong list and have to redo it.1 point
-
Another AutoIt extension for Visual Studio Code
seadoggie01 reacted to genius257 for a topic
Version 1.8.2 has just been released! I should have been 1.8.0, but issues with deployment pipeline after bigger changes to how the parser code and types are generated (internally) meant that i had to increment patch version 2 times, to successfully be able to release to the extension marketplaces. Notable changes: Added au3 DocBlock `@link` tag support Added syntax highlighting for au3 DocBlock and legacy UDF headers 2 things i would like feedback on, if possible: About the new syntax highlighting: Let me know if and/or how you like or dislike it. Performance: small changes to how the parser worked with some parser rules, to better generate types. Smaller tests indicated it was same or faster, but it can very much depend how it traverses through the code. Let me know if you notice any slow down, so I can look into fixing it ASAP! Feedback can be here, via an issue or via the discussion for the release.1 point -
Uploaded a new beta installer that has the following updates: Added VSCode wrapper to show output in user tasks Added example user tasks Fixed some /AddIncludes issues with constants and duplicate local includes Just take a look at the tasks.json included in the autoit3Wrapper directory, which will allow you to add AutoIt3Wrapper tasks like /addincludes and /au3stripper to the tasks in VScode. These tasks will shell an already included powershell script (see below) in the AutoIt3Wrapper directory that will ensure that the output will be shown in the VScode terminal window. The powershell wrapper included with some more detailed description: # # # # powershell script to wrap AutoIt3Wrapper to use in VSCODE and show the console output when ran as Task # # # When you get: File C:\Program Files (x86)\AutoIt3\SciTE\run_autoit.ps1 cannot be loaded # because running scripts is disabled on this system. For more information...... # The error message indicates that PowerShell script execution is disabled on your system. # You need to enable script execution by setting the execution policy. # You can do this by # 1. running PowerShell as an administrator and executing the following command: # 2. Do command: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser # This command sets the execution policy to RemoteSigned for the current user, allowing locally created scripts to run. param ( [string]$AutoitPath, [string]$Options, [string]$ScriptFile ) # Run AutoIt3 Wrapper & "$autoitPath\Autoit3.exe" "$autoitPath\Scite\AutoIt3Wrapper\AutoIt3Wrapper.au3" $options /in "$scriptfile" | Write-Output echo "--Done--" Thoughts?1 point