Leaderboard
Popular Content
Showing content with the highest reputation on 01/23/2025 in all areas
-
So here some partial recognition based on the png files. As its italic it will be more complicated to properly first cut the characters nicely. I hope the script gives you some insights on how to do the analysis. When thats done you could directly bitblit line11 and 27 and 41 from the screen as that seems to be a proper discriminator to identify the number. From the screen you can probably directly bitblt with black/white pixels directly which should speed up even more. Due to italic it seems a little harder to calculate the exact position for each digit calculated (maybe even easier to just hardcode them as it seems to be off by 1 or 2 bytes for each digit. #Region includes Opt('MustDeclareVars', 1) ;#include <GUIConstants.au3> #include <GDIPlus.au3> #Include <ScreenCapture.au3> #include <string.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #EndRegion _GDIPlus_Startup() Dim $BitmapFilename Dim $BMPData="", $BMPWidth=0, $BMPHeight=0, $BMPLineWidth=0, $imgBytes=2 dim $binaryLine, $startColumn ;~ for each picture file for $i=1 to 4 $BitmapFilename = @TempDir & "\" & "pic" & string($i) & ".png" $BMPData="" $BMPWidth=0 $BMPHeight=0 $BMPLineWidth=0 $imgBytes=1 consolewrite($bitmapFileName) ; Load the bitmap to find getImage($BitmapFilename, $BMPData, $BMPWidth, $BMPHeight, $BMPLineWidth, $imgBytes) ;~ See the height and width and dump the data on screen consolewrite($BMPHeight & " ; ") consolewrite($BMPWidth &@CRLF ) consolewrite(" 0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite(" 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) For $iLine = 11 To $BMPHeight-12 ;~ From the screenshots we can ignore the first 16 bytes (remember in text its 2 characters ;~ $binaryLine=BinaryMid($bmp1Data,($i*$BMP1LineWidth)+16,$BMP1LineWidth) ;~ and we only need 4 digits which takes about 28 characters and 1 character separator = $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16,60) ;~ $binaryLine=$bmpData ;~ Lets make it readable $binaryLine=StringReplace($binaryLine,"0",".") consolewrite($iLine & " : " & $binaryLine & @CRLF) next ;~ lets recognise for $iNumber=1 to 4 consolewrite(@crlf) consolewrite("0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) ;~ Its hard to determine the column for each digit in a formula if $iNumber=1 then $startColumn=16 if $iNumber=2 then $startColumn=30 if $iNumber=3 then $startColumn=45 if $iNumber=4 then $startColumn=59 ;~ Only a few lines in the png are of interest For $iLine = 11 To $BMPHeight-12 ;~ $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16+(($iNumber-1)*14),15) $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+$startColumn,15) $binaryLine=StringReplace($binaryLine,"0"," ") consolewrite($iLine & " : " & $binaryLine & @CRLF) next ;~ if on line 11 at position 28 I have a B it can be a 4 ;~ It seems to be easier to revert back to a string when we have the data local $lineData11=stringstripws(StringRegExpReplace(binaryMid($bmpData,(11*$BMPLineWidth)+$startColumn,15),"[x0]"," "),3) local $lineData27=stringstripws(StringRegExpReplace(binaryMid($bmpData,(27*$BMPLineWidth)+$startColumn,15),"[x0]"," "),3) local $lineData41=stringstripws(StringRegExpReplace(binaryMid($bmpData,(41*$BMPLineWidth)+$startColumn,15),"[x0]"," "),3) consolewrite(string($lineData11) & " - ") consolewrite(string($lineData27) & " - ") consolewrite(string($lineData41) & @crlf) ;~ And here determine the magic lines if (($lineData11="BBB") and ($lineData27="B222B B222B")) then consolewrite("Ita a 4" & @CRLF) if (($lineData11="BBB BBB") and ($lineData27="B222BB222BB222BB222B")) then consolewrite("Ita a 6" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222BB222BB222B")) then consolewrite("Ita a 9" & @CRLF) if (($lineData11="BBB") and ($lineData27="B222B")) then consolewrite("Ita a 1" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222BB222B")) then consolewrite("Ita a 8" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222B B222B B222B")) then consolewrite("Ita a 0" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222B") and ($lineData41="BBB BBB BBB")) then consolewrite("Ita a 3" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222B") and ($lineData41="BBB BBB BBB BBB BBB")) then consolewrite("Ita a 2" & @CRLF) if (($lineData11="BBB BBB BBB BBB BBB") and ($lineData27="B222B") and ($lineData41="BBB")) then consolewrite("Ita a 7" & @CRLF) if (($lineData11="BBB BBB BBB BBB BBB") and ($lineData27="B222B") and ($lineData41="BBB BBB BBB")) then consolewrite("Ita a 5" & @CRLF) Next Next _GDIPlus_Shutdown() Func GetImage($BMPFile, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $imgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle, $bitMapdata, $pixelFormat ; Load the bitmap to search in If $BMPFile="SCREEN" Then $hbScreen=_ScreenCapture_Capture("",0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap Else ;try to get a handle $handle = WinGetHandle($BMPFile) If @error Then ;Assume its an unknown handle so correct filename should be given $pBitmap = _GDIPlus_BitmapCreateFromFile($BMPFile) ;~ $hBitmap = _GDIPlus_ImageLoadFromFile($BMPFile) Else $hbScreen=_ScreenCapture_CaptureWnd("",$handle,0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap EndIf EndIf ;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 if ($imgBytes=1) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF04INDEXED) Endif if ($imgBytes=2) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) EndIf if ($imgBytes=3) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) endIf 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-1) & "]", $Scan0) $BMPDataStart = $BMPDataStart & DllStructGetData($pixeldata,"lData") _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose ($pBitmap) _WinAPI_DeleteObject ($pBitmap) EndFunc;==>GetImage ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) 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_DrawRect #EndRegion3 points
-
@Schnuffellets continue this discussion in PM to keep it clean and consise so we are able to tackle 1 part of you steps at a time starting with your x64 option for a3x so you fully understand how things work. Please PM me with an simple answer whether you have understood what I've explained on that topic!1 point
-
RustDesk UDF
argumentum reacted to BinaryBrother for a topic
Update: 1/23/25 - Overhauled some portions of the code with redundancy and timers. I figured out most of the issues. It's been re-tested on Win10 and Win11 via VM and @Trong helped with some testing as well. Seems like she's gonna float, for now.1 point -
Installer for auto execute a3x files
argumentum reacted to SOLVE-SMART for a topic
By the way @argumentum: Thanks for talking part on the discussion here and also in the german forum. For those who are not reading the conversation here, it's helpful to complete it also in the german one, like you did (and I also do) đź‘Ť . Best regards Sven1 point -
Installer for auto execute a3x files
SOLVE-SMART reacted to Schnuffel for a topic
I'm afraid I was a little misunderstood. Basically, I want to have an AutoIt installation that only provides a3x support on the target computer. Example: I write a script that I want to distribute to X users. So that the script (I hope) can be distributed as an a3x file and started by the user, the user needs an AutoIt3.exe and ideally also a shortcut for a3x files so that the AutoIt3.exe can start them directly on double-click. And that's all. Since the “Minimal” installation of AutoIt was still too extensive for me, I thought of an EndUser “Tiny” installation. I could have just asked @Jon if he would be willing to extend his setup so that there is a “Tiny” / a3x option in his installation routine. That's it. ^^ Playing around with this topic, I just noticed in passing that a3x files are always associated with the x86 version of AutoIt3 in the registry. But this was only mentioned in passing and neither the main goal of this thread nor a significant circumstance. I hope I have been able to clear up the confusion surrounding this topic. @Jos I really confused you. ^^ I didn't really realize there was a Jos and a Jon But the issue also affects you, as there is no option in Scite to create a3x files for AutoIt3_x64.exe. You cannot do this on your own as long as there is no support for a3x(64) files in the registry and AutoIt3_x64 is called for this. But for this Jon would have to extend his setup and integrate this file type. Then you could also support the x86 / x64 option when compiling a3x files using this independent file type. Regarding the “black hat” issue: The problem with script kiddies or other “bad” guys is not that there is a scripting language that doesn't attract attention through virus scanners, but the fact that all these people need an admin token to do damage. Nothing of the sort happens with a3x support. If I want, I can do exactly the same damage with cmd, vbs, ps1 and co. as with a3x. @argumentum PS: if we humans didn't invent all the things that a bad person can abuse for fear of it, we would probably still be sitting in the forest without a campfire, scraping the bark off the tree with our fingernails 🙂 I don't mean that in a bad way, just the way I see things.1 point -
Maybe this helps a little in understanding. Its just manipulation of pixels in a certan layout (PNG). Look at the output and zoom in/out, you can see almost the numbers yourself #Region includes Opt('MustDeclareVars', 1) ;#include <GUIConstants.au3> #include <GDIPlus.au3> #Include <ScreenCapture.au3> #include <string.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #EndRegion _GDIPlus_Startup() Dim $BitmapFilename Dim $BMPData="", $BMPWidth=0, $BMPHeight=0, $BMPLineWidth=0, $imgBytes=1 dim $binaryLine for $i=1 to 4 $BitmapFilename = @TempDir & "\" & "pic" & string($i) & ".png" $BMPData="" $BMPWidth=0 $BMPHeight=0 $BMPLineWidth=0 $imgBytes=1 consolewrite($bitmapFileName) ; Load the bitmap to find getImage($BitmapFilename, $BMPData, $BMPWidth, $BMPHeight, $BMPLineWidth, $imgBytes) ;~ See the height and width and dump the data on screen consolewrite($BMPHeight & " ; ") consolewrite($BMPWidth &@CRLF ) consolewrite("0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) For $iLine = 11 To $BMPHeight-12 ;~ From the screenshots we can ignore the first 16 bytes (remember in text its 2 characters ;~ $binaryLine=BinaryMid($bmp1Data,($i*$BMP1LineWidth)+16,$BMP1LineWidth) ;~ and we only need 4 digits which takes about 28 characters and 1 character separator = $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16,60) ;~ Lets make it readable $binaryLine=StringReplace($binaryLine,"0",".") consolewrite($iLine & " : " & $binaryLine & @CRLF) next ;~ lets recognise for $iNumber=1 to 4 consolewrite(@crlf) consolewrite("0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) For $iLine = 11 To $BMPHeight-12 $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16+(($iNumber-1)*15),14) $binaryLine=StringReplace($binaryLine,"0",".") consolewrite($iLine & " : " & $binaryLine & @CRLF) next Next Next _GDIPlus_Shutdown() Func GetImage($BMPFile, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $imgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle, $bitMapdata, $pixelFormat ; Load the bitmap to search in If $BMPFile="SCREEN" Then $hbScreen=_ScreenCapture_Capture("",0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap Else ;try to get a handle $handle = WinGetHandle($BMPFile) If @error Then ;Assume its an unknown handle so correct filename should be given $pBitmap = _GDIPlus_BitmapCreateFromFile($BMPFile) ;~ $hBitmap = _GDIPlus_ImageLoadFromFile($BMPFile) Else $hbScreen=_ScreenCapture_CaptureWnd("",$handle,0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap EndIf EndIf ;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 if ($imgBytes=1) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF04INDEXED) Endif if ($imgBytes=2) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) EndIf if ($imgBytes=3) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) endIf 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-1) & "]", $Scan0) $BMPDataStart = $BMPDataStart & DllStructGetData($pixeldata,"lData") _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose ($pBitmap) _WinAPI_DeleteObject ($pBitmap) EndFunc;==>GetImage ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) 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_DrawRect #EndRegion I assume you refer to1 point
-
; https://www.autoitscript.com/forum/topic/211986-creates-a-rectangle-frame/ ;---------------------------------------------------------------------------------------- ; Title...........: _GuiFrame.au3 ; Description.....: Creates a rectangle frame ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <WindowsConstants.au3> #include <WinAPIGdi.au3> ;Example: Global $aCoord, $hPoint, $hFrame = _GuiFrame("", 100, 100, 200, 200, 5, 0xFFFFFF, 255) ;********************************** Do $aCoord = PixelSearch(100, 100, 200, 200, 0xFFFFFF, 0, 1, 0) ;0xFFFFFF White If Not @error Then ConsoleWrite("found White at X,Y: " & $aCoord[0] & "," & $aCoord[1] & @CRLF) $hPoint = _GuiFrame("", $aCoord[0], $aCoord[1], $aCoord[0] + 1, $aCoord[1] + 1, 3, 0xFF0000) Sleep(4000) GUIDelete($hPoint) EndIf Sleep(10) Until GUIGetMsg() = -3 ; GUI_EVENT_CLOSE ;********************************** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _GuiFrame ; Description....: Creates a rectangle frame ; Syntax.........: _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom [, $iThickness = 2 [, $iColor = 0xFF0000 [, $iTransparency = 150 [, $hWndParent = 0]]]]) ; Parameters.....: $sTitle - The title of frame. ; $iLeft - The left coordinate of frame. ; $iTop - The top coordinate of frame. ; $iRight - The right coordinate of frame. ; $iBottom - The bottom coordinate of frame. ; $iThickness - [optional] The thickness of frame (default = 1). ; $iColor - [optional] The color of frame (default = 0xFF0000). ; $iTransparency - [optional] The transparency of frame, in the range 1 - 255 (default = 150). ; $hWndParent - [optional] The parent window handle (default = 0). ; Return values..: The handle of the created frame. ; Author ........: ioa747 ; Notes .........: Note that coordinate, are the internal frame dimensions. ; Dependencies...: #include <WinAPIGdi.au3>, #include <WindowsConstants.au3> ;-------------------------------------------------------------------------------------------------------------------------------- Func _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom, $iThickness = 1, $iColor = 0xFF0000, $iTransparency = 150, $hWndParent = 0) If $iThickness < 1 Or $iThickness = Default Then $iThickness = 1 If $iColor = -1 Or $iColor = Default Then $iColor = 0xFF0000 If $iTransparency < 1 Or $iTransparency = Default Or $iTransparency > 255 Then $iTransparency = 150 Local $iWidth = $iRight - $iLeft + (2 * $iThickness) + 1 Local $iHeight = $iBottom - $iTop + (2 * $iThickness) + 1 Local $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft - $iThickness, $iTop - $iThickness, _ $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE), $hWndParent) GUISetBkColor($iColor, $hGUI) WinSetTrans($hGUI, "", $iTransparency) ;255 = Solid, 0 = Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hGUI) Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $iWidth, $iHeight) $hInner_rgn = _WinAPI_CreateRectRgn($iThickness, $iThickness, $iWidth - $iThickness, $iHeight - $iThickness) $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($hInner_rgn) _WinAPI_SetWindowRgn($hGUI, $hCombined_rgn) Return $hGUI EndFunc ;==>_GuiFrame ;-------------------------------------------------------------------------------------------------------------------------------- Another example #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISys.au3> _Example1() Func _Example1() Local $iGuiFrame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) Local $iThickness = 10 Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi! Move this window around'')"') Local $hWnd = WinWaitActive('Hello World!', '', 3) Local $aPos = WinGetPos($hWnd) Local $iLeft = $aPos[0] + $iGuiFrame Local $iTop = $aPos[1] Local $iRight = $aPos[0] + $aPos[2] - $iGuiFrame Local $iBottom = $aPos[1] + $aPos[3] - $iGuiFrame Local $hFrame = _GuiFrame("", $iLeft, $iTop, $iRight, $iBottom, $iThickness, 0xFF0000, 150, $hWnd) ConsoleWrite("$hFrame=" & $hFrame & @CRLF) Local $sStrPos While WinExists($hWnd) $aPos = WinGetPos($hWnd) If $sStrPos <> $aPos[0] & ";" & $aPos[1] Then WinMove($hFrame, '', $aPos[0] - $iThickness + $iGuiFrame, $aPos[1] - $iThickness) $sStrPos = $aPos[0] & ";" & $aPos[1] EndIf Sleep(10) WEnd EndFunc ;==>_Example1 ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _GuiFrame ; Description....: Creates a rectangle frame ; Syntax.........: _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom [, $iThickness = 2 [, $iColor = 0xFF0000 [, $iTransparency = 150 [, $hWndParent = 0]]]]) ; Parameters.....: $sTitle - The title of frame. ; $iLeft - The left coordinate of frame. ; $iTop - The top coordinate of frame. ; $iRight - The right coordinate of frame. ; $iBottom - The bottom coordinate of frame. ; $iThickness - [optional] The thickness of frame (default = 1). ; $iColor - [optional] The color of frame (default = 0xFF0000). ; $iTransparency - [optional] The transparency of frame, in the range 1 - 255 (default = 150). ; $hWndParent - [optional] The parent window handle (default = 0). ; Return values..: The handle of the created frame. ; Author ........: ioa747 ; Notes .........: Note that coordinate, are the internal frame dimensions. ; Dependencies...: #include <WinAPIGdi.au3>, #include <WindowsConstants.au3> ;-------------------------------------------------------------------------------------------------------------------------------- Func _GuiFrame($sTitle, $iLeft, $iTop, $iRight, $iBottom, $iThickness = 1, $iColor = 0xFF0000, $iTransparency = 150, $hWndParent = 0) If $iThickness < 1 Or $iThickness = Default Then $iThickness = 1 If $iColor = -1 Or $iColor = Default Then $iColor = 0xFF0000 If $iTransparency < 1 Or $iTransparency = Default Or $iTransparency > 255 Then $iTransparency = 150 Local $iWidth = $iRight - $iLeft + (2 * $iThickness) + 1 Local $iHeight = $iBottom - $iTop + (2 * $iThickness) + 1 Local $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft - $iThickness, $iTop - $iThickness, _ $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_NOACTIVATE), $hWndParent) GUISetBkColor($iColor, $hGUI) WinSetTrans($hGUI, "", $iTransparency) ;255 = Solid, 0 = Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hGUI) Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $iWidth, $iHeight) $hInner_rgn = _WinAPI_CreateRectRgn($iThickness, $iThickness, $iWidth - $iThickness, $iHeight - $iThickness) $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($hInner_rgn) _WinAPI_SetWindowRgn($hGUI, $hCombined_rgn) Return $hGUI EndFunc ;==>_GuiFrame ;-------------------------------------------------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much1 point
-
Belated, promised example script. ; Declare our variables Dim $ourApp, $ourOutput, $ourCmdline, $ourTest, $ourResult ; Randomly pick either the TIME or DATE command ; (so that we can have contrived, variable output for our example.) If Random() < 0.5 Then $ourCmdline = @ComSpec & " /c TIME" Else $ourCmdline = @ComSpec & " /c DATE" EndIf ; Tell the user what command line we're using MsgBox(64, "Debug -- " & @ScriptName, "Using command line: " & $ourCmdline) ; Run the command line, with AutoIt managing the STDIN and STDOUT connections $ourApp = Run($ourCmdline, @SystemDir, @SW_HIDE, 3) ; Test the child process's STDOUT for expected output using the _StdoutExpect ; function (defined below). The first parameter is the PID of the process ; we wish to read from, the second parameter is a group of substrings, ; seperated by |, that we would expect to see as possible output. ; In this example the substrings are the last few characters of the output ; of the DATE or TIME commands (in US English)). $ourTest = _StdoutExpect($ourApp, "yy)|me:") ; Act according to the result of _StdoutExpect If $ourTest = 0 Then $ourResult = "_StdoutExpect timed out waiting for output..." ElseIf $ourTest = 1 Then $ourResult = "We saw output corresponding to the DATE command, acting accordingly..." ; Simply send ENTER and close the STDIN connection (for our example). StdinWrite($ourApp, @CRLF) StdinWrite($ourApp) ElseIf $ourTest = 2 Then $ourResult = "We saw output corresponding to the TIME command, acting accordingly..." ; Simply send ENTER and close the STDIN connection (for our example). StdinWrite($ourApp, @CRLF) StdinWrite($ourApp) EndIf ; Inform the user of our test result MsgBox(64, "Debug -- " & @ScriptName, $ourResult) ; _StdoutExpect =============================================================== ; ; Description: Tests STDOUT of a child process for specific output within a timeout period ; Parameter(s): $hOurProcess - ID of child process to read from. ; $sOurExpected - String of the possible expected output substrings, seperated ; by the | character (by default). ; $iOurTimeout - Time to wait for one of the substrings before giving up. ; Defaults to 100. ; $sOurSeparator - Alternate seperator character, e.g. if your substrings have ; the | character in them. ; Requirement(s): None ; Return Value(s): On Success - Position in $sOurExpected of the substring that was found ; (starting with 1). ; On Failure - 0 and set @error to 1 if timeout period passed. ; ; Author(s): DaveF ; ; Notes: Intended for use with AutoIt3 v3.2.12.0 and later ; Default timeout of 100ms is probably too short for most apps ; Only intended and appropriate for console apps that produce ; regular, predictable output and then pause for input. ;=============================================================================== Func _StdoutExpect($hOurProcess, $sOurExpected, $iOurTimeout = 100, $sOurSeparator = "|") Local $iOurTimer, $sOurOutput, $asOurExpected ; Explode the expected substrings into a StringSplit array $asOurExpected = StringSplit($sOurExpected, $sOurSeparator) ; Record the time to test vs our tiumeout. $iOurTimer = TimerInit() ; Loop While 1 ; Return empty-handed of the timeout has elapsed If TimerDiff($iOurTimer) > $iOurTimeout Then SetError(1) Return 0 EndIf ; Read and save available output from STDOUT $sOurOutput &= StdoutRead($hOurProcess) ; Step through provided substrings and test vs output For $incr = 1 To $asOurExpected[0] If StringInStr($sOurOutput, $asOurExpected[$incr]) Then ; Found this substring, so return its index Return $incr EndIf Next WEnd EndFunc I've wrestled for a long time with the idea of creating a UDF for purposes like this, with the argument against being that using and learning such a UDF would be only marginally less complicated than writing a custom script for every need that arises.1 point