Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/17/2020 in all areas

  1. It's chinese ? $gui = GuiCreate("test", 500, 100) $label = GUICtrlCreateLabel("", 10, 10, 490, 20) GUICtrlSetFont(-1, 9, 0, 0, "Arial Unicode MS") GuiSetState() Local $string = '\u4e3a\u4e86\u9632\u6b62\u5723\u7269\u91d1\u5777\u5783\u843d\u5165\u4fb5\u7565\u8005\u7684\u624b\u4e2d\uff0c\u5723\u5730\u4e9a\u6208\u5927\u9646\u4e0a\u7684\u6218\u58eb\u4eec\u7eb7\u7eb7\u633a\u8eab\u800c\u51fa\u3002' $string = Execute('"' & StringRegExpReplace($string, '\\u([[:xdigit:]]{4})', '" & ChrW(0x$1) & "') & '"') GuiCtrlSetData($label, $string) While GuiGetMsg()<>-3 Wend
    4 points
  2. Gianni

    ✂️ Quick crop tool

    2020/08/16 New Version CropTool.au3 I've made some changes and fixes to this function: I added the possibility to vary both the thickness of the selector and its color. to customize the appearance and behavior of the tool, you can change the values of some variables in the function listing. See comments on lines 140-170 You can also vary the look of the border by setting a custom dash/space length pattern. Thanks to @UEZ for that. See here for reference. Hope it is free of bugs. (i don't know how to test it to see if it is also DPI aware??) Suggestions for improvements and bug reports are welcome. How to use this demo of use: hit Ctrl+PrintScreen to activate the tool LeftClick and drag on the borders of the tool to resize the area you can also Leftclick and drag within the area to move it around RightClick within the area to shot a screenshot of only the delimited area to the clipboard. in short "how to use the function" outside this demo in your programs: including the following 4 standard udf #include <Windowsconstants.au3> #include <WinAPISys.au3> #include <Misc.au3> #include <GDIPlus.au3> and pasting the _Crop function in your listing is all what you need, then: call the _Crop() function; the 'selector' appears around the mouse hovering the mouse over any side or corner the cursor should change accordingly; LeftClick on the edges and drag to redim the area, also LeftClick within the area and drag to move the selection around. When you are done with the selection, RightClick within the area or also hit the ESC key, the 4 element 1D array is returned to the caller and the 'selector' disappears from the screen Thank you ... below original post ... A function that allows you to freely and visually select an area of the screen Yes I know, there are already some in the forum, however here is yet another cropping tool. I collected some snippets from the forum and merged in a simple and quick cropping tool implemented as a single standalone function. The _Crop() function simply returns a 4-element 1D array with the x-y coordinates of the upper left and the width and height of the selected area, respectively in the elements [0] [1] [2] [3]. So it's up to you to make good use of these parameters An example of use: Since Windows already has both a screenprint functionkey to copy the whole screen to the clipboard and the Alt-printscreen shortkut to copy only the active window to the clipboard, I'm goinmg to bind this _crop() function combined with the Control-printscreen hotkey to create a "partial" screenshot of the delimited area of the screen. The captured screenshot of that area is copied to the clipboard, so you can paste it wherever you want. How to use it: after running the script, use the Control+Printscreen keys to activate the crop tool that appears around the mouse position; then use the mouse to visually resize and move the area and when you have delimited the desired area click with the right mouse button inside the area to copy it to the clipboard. Suggestions, improvements and finally error reports are welcome Happy cropping #AutoIt3Wrapper_Res_HiDpi=y #include <Windowsconstants.au3> #include <WinAPISys.au3> #include <Misc.au3> #include <GDIPlus.au3> #include <Clipboard.au3> ; ---------------------- ; -- Demo start -------- ; ---------------------- #include <ScreenCapture.au3> ; needed only For this demo Global $user32 = DllOpen("user32.dll") While 1 ; hit Control+Printscreen to call the _Crop Function If _IsPressed("11", $user32) And _IsPressed("2C", $user32) Then _example() ; 11 CTRL key + 2C PRINTSCREEN key ; hit Control + c to exit this script (can be castomized with other keys) If _IsPressed("11", $user32) And _IsPressed("43", $user32) Then ExitLoop ; 11 CTRL key + 43 C key Sleep(150) WEnd DllClose($user32) TrayTip("Crop demo", "End of the 'TSR' crop demo", 3, 1) ; (1) = Info icon Sleep(3000) Exit Func _example() $aRect = _Crop() ; mark the area If Not @extended Then ; if the ESC key was pressed within the _Crop function the @extended is set to 1 _GDIPlus_Startup() Local $hGui = GUICreate("", $aRect[2], $aRect[3], $aRect[0] - 1, $aRect[1] - 1, $WS_POPUPWINDOW) Local $idPic = GUICtrlCreatePic('', 0, 0, $aRect[2], $aRect[3]) Local $hTimer = TimerInit() Local $hBmp = _ScreenCapture_Capture('', $aRect[0], $aRect[1], $aRect[0] + $aRect[2] - 1, $aRect[1] + $aRect[3] - 1, False) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) Local $iMidX = $aRect[0] + $aRect[2] / 2 Local $iMidY = $aRect[1] + $aRect[3] / 2 ; snippet by UEZ ; https://www.autoitscript.com/forum/topic/129333-screen-capture-to-clipboard/?do=findComment&comment=898287 Local $bResult = _ClipBoard_Open(0) + _ClipBoard_Empty() + Not _ClipBoard_SetDataEx($hBmp, $CF_BITMAP) _ClipBoard_Close() If $bResult = 2 Then ToolTip("the area was copied to the clipboard", $iMidX, $iMidY, 'Info', 1, 6) Else ToolTip("Something went wrong", $iMidX, $iMidY, 'Error', 3, 6) EndIf ; snippet by Malkey ; https://www.autoitscript.com/forum/topic/191425-capturing-image-without-saving/?do=findComment&comment=1373088 Local $STM_SETIMAGE = 0x0172 GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp) _WinAPI_DeleteObject($hBmp) GUISetState() DllCall("User32.dll", "int", "AnimateWindow", "hwnd", $hGui, "int", 750, "long", "0x00050002") ; Right-Left GUIDelete($hGui) Sleep(250) ToolTip('') ; #ce ; GUIDelete($hGui) _WinAPI_DeleteObject($hBmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() EndIf EndFunc ;==>_example ; ---------------------- ; -- Demo end ---------- ; ---------------------- ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crop ; Description ...: A function that allows you to freely and visually select an area of the screen ; Syntax ........: _Crop([$i_X = Default[, $i_Y = Default[, $i_W = Default[, $i_H = Default[, $iMinW = -1[, $iMaxW = -1[, ; $iMinH = -1[, $iMaxH = -1]]]]]]]]) ; ; - To resize the area click the left mouse button and drag on any of the moving colored edges of the tool. ; You can also LeftClick within the selected area and drag to move the whole selection. ; ; - To terminate the selection operation RightClick within the selected area. ; ; You can alse terminate the selection operation by hitting the ESC key; ; in that case the @extended macro will be setted to true ; ; Parameters ....: All parameters are optional: ; $i_X - [optional] an integer value. Default is MouseGetPos(0) - 50. ; The upper left X coordinate where you want the cropping tool to appear ; ; $i_Y - [optional] an integer value. Default is MouseGetPos(1) - 50. ; The upper left Y coordinate where you want the cropping tool to appear ; ; $i_W - [optional] an integer value. Default is 100. ; The initial width of the selection area ; ; $i_H - [optional] an integer value. Default is 100. ; The initial height of the selection area ; ; $iMinW - [optional] an integer value. Default is 1 (minimum allowed is 1). ; The minimum selectable width ; ; $iMaxW - [optional] an integer value. Default is -1 (no limit). ; The maximum selectable width ; ; $iMinH - [optional] an integer value. Default is 1 (minimum allowed is 1). ; The minimum selectable height ; ; $iMaxH - [optional] an integer value. Default is -1 (no limit). ; The maximum selectable height ; ; Return values .: - A 4 element 1D array where: ; element [0] the upperLeft X coordinate of the selected area ; element [1] the upperLeft Y coordinate of the selected area ; element [2] the width of the selected area ; element [3] the height of the selected area ; ; @extended is set to True if you exit from the _crop() function by pressing the ESC key ; ; Author ........: Chimp (Gianni Addiego) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== ; Func _Crop($i_X = MouseGetPos(0) - 50, $i_Y = MouseGetPos(1) - 50, $i_W = 100, $i_H = 100, $iMinW = -1, $iMaxW = -1, $iMinH = -1, $iMaxH = -1) Func _Crop($i_X = Default, $i_Y = Default, $i_W = Default, $i_H = Default, $iMinW = 1, $iMaxW = -1, $iMinH = 1, $iMaxH = -1) _GDIPlus_Startup() If ($i_X = '') Or ($i_X = Default) Then $i_X = MouseGetPos(0) - 50 If ($i_Y = '') Or ($i_Y = Default) Then $i_Y = MouseGetPos(1) - 50 If ($i_W = '') Or ($i_W = Default) Then $i_W = 100 If ($i_H = '') Or ($i_H = Default) Then $i_H = 100 If ($iMinW < 1) Or ($iMinW = Default) Then $iMinW = 1 If ($iMaxW < 1) Or ($iMaxW = Default) Then $iMaxW = 65535 If ($iMinH < 1) Or ($iMinH = Default) Then $iMinH = 1 If ($iMaxH < 1) Or ($iMaxH = Default) Then $iMaxH = 65535 ; used local variables Local $hGUI2, $hGUI3, $aWinPos2, $aPrevPos2[4], $aClientSize Local $iX, $iY, $iW, $iH Local Enum $x, $y Local $iOuterTolerance, $iBorder, $iInnerTolerance Local $hGraphic, $hPen, $AlphaKey = 0xFF000000, $RectColor, $RectBgColor Local $hDLL = DllOpen("user32.dll") Local $fOffset, $iDelay, $iTimerID = TimerInit() Local $iCursorID, $iBorderID, $aMousePointer, $iSide, $iTopBot, $iInner, $iRightEdge, $iBottomEdge, $iMouseOffsetX, $iMouseOffsetY Local $bEscape ; ================================================================================== ; Set the appearance and behaviour of the tool ; ================================================================================== $iBorder = 2 ; the width of the colored border (minimum 1) ; since with a very thin border it is difficult to click on it to drag it ; it is possible to set an external courtesy area authorized to click on the border ; even if the mouse is not exactly on it (it can also be set to 0 to disable it) $iOuterTolerance = 4 ; 'courtesy' external area allowed to click on the border ; same as above but for the inside of the edge $iInnerTolerance = 3 ; 'courtesy' internal area allowed to click on the border $RectColor = 0xFFFF0000 ; The color of the colored moving edge $RectBgColor = 0xFFFFFF00 ; The Background color of the colored moving edge $iDelay = 50 ; this value determines the rotation speed of the moving colored border. The lower it is, the faster it is ; here the pattern of the moving edge can be customized ; Thanks to @UEZ for this snippet. See Here for reference: https://www.autoitscript.com/forum/topic/185769-moving-dash-rectangle/?do=findComment&comment=1343856 Local $iCount = 4, $tArray = DllStructCreate("float;float;float;float") DllStructSetData($tArray, 1, 2) ; dash length DllStructSetData($tArray, 2, 4) ; space length DllStructSetData($tArray, 3, 2) ; dash length DllStructSetData($tArray, 4, 4) ; space length ; Important!: also set the below variable as the sum of all the above dash/space values ; ========== Local $iDotsDashesTotLen = 2 + 4 + 2 + 4 ; <--- adapt this variable to the above values ; ================================================================================== ; Create a transparent window where to draw the moving colored edge effect using the $iBorder variable ; X and Y coordinates refers to where will be placed the client crop area (not the draggable outer colored border) $hGUI2 = GUICreate('', $i_W + $iBorder * 2, $i_H + $iBorder * 2, $i_X - $iBorder, $i_Y - $iBorder, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) ; make sure $AlphaKey color is different from both $RectColor and $RectBgColor While ($AlphaKey = $RectColor) Or ($AlphaKey = $RectBgColor) $AlphaKey += 1 WEnd GUISetBkColor($AlphaKey, $hGUI2) _WinAPI_SetLayeredWindowAttributes($hGUI2, $AlphaKey, 0, $LWA_COLORKEY) ; Create a transparent window wider than the main one to allow the custom mouse cursor to be displayed even beyond the colored border (Tolerance) ; also, since this window is not "passthrough", it prevents mouse clicks from passing underneath. $hGUI3 = GUICreate('', $i_W + $iBorder * 2 + $iOuterTolerance * 2, $i_H + $iBorder * 2 + $iOuterTolerance * 2, $i_X - $iBorder - $iOuterTolerance, $i_Y - $iBorder - $iOuterTolerance, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) WinSetTrans($hGUI3, "", 1) WinSetOnTop($hGUI3, "", $WINDOWS_ONTOP) GUISetState(@SW_SHOW, $hGUI2) GUISetState(@SW_SHOW, $hGUI3) $hPen = _GDIPlus_PenCreate($RectColor, $iBorder * 2) ; why * 2 ?? _GDIPlus_PenSetColor($hPen, $RectColor) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI2) Do $iSide = 0 $iTopBot = 0 $iInner = 0 $bEscape = False $aMousePointer = GUIGetCursorInfo($hGUI2) ; zero based $aWinPos2 = WinGetPos($hGUI2) $aClientSize = WinGetClientSize($hGUI2) ; ----------------------- ; check pointer position ; -------------------------------------------------------------------------------------------------------------------------------------------------------- If _ ; Pointer is on the left border (($aMousePointer[$x] >= -$iOuterTolerance) And ($aMousePointer[$x] < ($iBorder + $iInnerTolerance))) And _ (($aMousePointer[$y] >= -$iOuterTolerance) And ($aMousePointer[$y] < ($aClientSize[1] + $iOuterTolerance))) Then $iSide = 1 If _ ; Pointer is on the right border (($aMousePointer[$x] >= ($aClientSize[0] - $iBorder - $iInnerTolerance)) And ($aMousePointer[$x] < ($aClientSize[0] + $iOuterTolerance))) And _ (($aMousePointer[$y] >= -$iOuterTolerance) And ($aMousePointer[$y] < ($aClientSize[1] + $iOuterTolerance))) Then $iSide = 2 If _ ; Pointer is on the top border (($aMousePointer[$y] >= -$iOuterTolerance) And ($aMousePointer[$y] < ($iBorder + $iInnerTolerance))) And _ (($aMousePointer[$x] >= -$iOuterTolerance) And ($aMousePointer[$x] < ($aClientSize[0] + $iOuterTolerance))) Then $iTopBot = 3 If _ ; Pointer is on the bottom border (($aMousePointer[$y] >= ($aClientSize[1] - $iBorder - $iInnerTolerance)) And ($aMousePointer[$y] < $aClientSize[1] + $iOuterTolerance)) And _ (($aMousePointer[$x] >= -$iOuterTolerance) And ($aMousePointer[$x] < ($aClientSize[0] + $iOuterTolerance))) Then $iTopBot = 6 If _ ; Pointer is within the client area (($aMousePointer[$x] >= ($iBorder + $iInnerTolerance)) And $aMousePointer[$x] < ($aClientSize[0] - $iBorder - $iInnerTolerance)) And _ (($aMousePointer[$y] >= ($iBorder + $iInnerTolerance)) And $aMousePointer[$y] < ($aClientSize[1] - $iBorder - $iInnerTolerance)) Then $iInner = 9 ; -------------------------------------------------------------------------------------------------------------------------------------------------------- $iBorderID = $iSide + $iTopBot + $iInner ; ; SetCursor ; --------- $iCursorID = 0 Switch $iBorderID Case 0 $iCursorID = 2 ; ARROW Case 1, 2 ; 1 left ; 2 right $iCursorID = 13 ; SIZEWE Case 3, 6 ; 3 top ; 6 bottom $iCursorID = 11 ; SIZENS Case 5, 7 ; 5 TopRight ; 7 BottomLeft $iCursorID = 10 ; SIZENESW Case 4, 8 ; 4 TopLeft ; 8 BottomRight $iCursorID = 12 ; SIZENWSE Case 9 ; 9 Inside $iCursorID = 0 ; HAND - or SIZEALL (9) EndSwitch GUISetCursor($iCursorID, 1) ; ------------------------------------------------------- ; If LeftClick on the tool then Drag or redimm selector ; ------------------------------------------------------- If _IsPressed("1", $hDLL) And $iBorderID And (WinActive($hGUI2) Or WinActive($hGUI3)) Then ; Left clicked $aWinPos2 = WinGetPos($hGUI2) Switch $iBorderID Case 0 Case 1 ; Pointer is on the left border $iMouseOffsetX = $aWinPos2[0] - MouseGetPos(0) $iRightEdge = $aWinPos2[0] + WinGetClientSize($hGUI2)[0] Case 2 ; Pointer is on the right border $iMouseOffsetX = $aWinPos2[0] + $aWinPos2[2] - MouseGetPos(0) Case 3 ; Pointer is on the top border $iMouseOffsetY = $aWinPos2[1] - MouseGetPos(1) $iBottomEdge = $aWinPos2[1] + $aWinPos2[3] Case 4 ; Pointer is on the top-left corner $iMouseOffsetY = $aWinPos2[1] - MouseGetPos(1) $iMouseOffsetX = $aWinPos2[0] - MouseGetPos(0) $iRightEdge = $aWinPos2[0] + WinGetClientSize($hGUI2)[0] $iBottomEdge = $aWinPos2[1] + $aWinPos2[3] Case 5 ; Pointer is on the top-right corner $iMouseOffsetX = $aWinPos2[0] + $aWinPos2[2] - MouseGetPos(0) $iMouseOffsetY = $aWinPos2[1] - MouseGetPos(1) $iBottomEdge = $aWinPos2[1] + $aWinPos2[3] Case 6 ; Pointer is on the bottom border $iMouseOffsetY = $aWinPos2[1] + $aWinPos2[3] - MouseGetPos(1) Case 7 ; Pointer is on the bottom-left $iMouseOffsetY = $aWinPos2[1] + $aWinPos2[3] - MouseGetPos(1) $iMouseOffsetX = $aWinPos2[0] - MouseGetPos(0) $iRightEdge = $aWinPos2[0] + WinGetClientSize($hGUI2)[0] Case 8 ; Pointer is on the bottom-right $iMouseOffsetY = $aWinPos2[1] + $aWinPos2[3] - MouseGetPos(1) $iMouseOffsetX = $aWinPos2[0] + $aWinPos2[2] - MouseGetPos(0) Case 9 $iMouseOffsetY = $aWinPos2[1] - MouseGetPos(1) $iMouseOffsetX = $aWinPos2[0] - MouseGetPos(0) EndSwitch Do $iX = Default $iY = Default $iW = Default $iH = Default Switch $iBorderID Case 1 ; Pointer is on the left border $iX = MouseGetPos(0) + $iMouseOffsetX $iW = $iRightEdge - MouseGetPos(0) + -$iMouseOffsetX Case 2 ; Pointer is on the right border $iW = (MouseGetPos(0) - $aWinPos2[0]) + $iMouseOffsetX Case 3 ; Pointer is on the top border $iY = MouseGetPos(1) + $iMouseOffsetY $iH = $iBottomEdge - MouseGetPos(1) + -$iMouseOffsetY Case 4 ; Pointer is on the top-left corner $iX = MouseGetPos(0) + $iMouseOffsetX $iY = MouseGetPos(1) + $iMouseOffsetY $iW = $iRightEdge - MouseGetPos(0) + -$iMouseOffsetX $iH = $iBottomEdge - MouseGetPos(1) + -$iMouseOffsetY Case 5 ; Pointer is on the top-right corner $iY = MouseGetPos(1) + $iMouseOffsetY $iW = (MouseGetPos(0) - $aWinPos2[0]) + $iMouseOffsetX $iH = $iBottomEdge - MouseGetPos(1) + -$iMouseOffsetY Case 6 ; Pointer is on the bottom border $iH = (MouseGetPos(1) - $aWinPos2[1]) + $iMouseOffsetY Case 7 ; Pointer is on the bottom-left corner $iX = MouseGetPos(0) + $iMouseOffsetX $iW = $iRightEdge - MouseGetPos(0) + -$iMouseOffsetX $iH = (MouseGetPos(1) - $aWinPos2[1]) + $iMouseOffsetY Case 8 ; Pointer is on the bottom-right corner $iW = (MouseGetPos(0) - $aWinPos2[0]) + $iMouseOffsetX $iH = (MouseGetPos(1) - $aWinPos2[1]) + $iMouseOffsetY Case 9 ; Pointer is inside the client area $iX = MouseGetPos(0) + $iMouseOffsetX $iY = MouseGetPos(1) + $iMouseOffsetY EndSwitch If $iW > ($iMaxW + $iBorder * 2) Then $iW = $iMaxW + $iBorder * 2 $iX = Default EndIf If $iW < ($iMinW + $iBorder * 2) Then $iW = $iMinW + $iBorder * 2 $iX = Default EndIf If $iH > ($iMaxH + $iBorder * 2) Then $iH = $iMaxH + $iBorder * 2 $iY = Default EndIf If $iH < ($iMinH + $iBorder * 2) Then $iH = $iMinH + $iBorder * 2 $iY = Default EndIf WinMove($hGUI2, '', $iX, $iY, $iW, $iH) GUISetCursor($iCursorID, 1) $aWinPos2 = WinGetPos($hGUI2) $aClientSize = WinGetClientSize($hGUI2) ; If GUI2 moved or resized then redraw the colored border and reposition also GUI3 If $aPrevPos2[0] <> $aWinPos2[0] Or $aPrevPos2[1] <> $aWinPos2[1] Or $aPrevPos2[2] <> $aWinPos2[2] Or $aPrevPos2[3] <> $aWinPos2[3] Then ; store new position/size $aPrevPos2[0] = $aWinPos2[0] $aPrevPos2[1] = $aWinPos2[1] $aPrevPos2[2] = $aWinPos2[2] $aPrevPos2[3] = $aWinPos2[3] _GDIPlus_GraphicsDispose($hGraphic) WinMove($hGUI3, '', $aWinPos2[0] - $iOuterTolerance, $aWinPos2[1] - $iOuterTolerance, $aWinPos2[2] + $iOuterTolerance * 2, $aWinPos2[3] + $iOuterTolerance * 2) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI2) _GDIPlus_GraphicsClear($hGraphic, $AlphaKey) ; erase rect _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLESOLID) _GDIPlus_PenSetColor($hPen, $RectBgColor) _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $aWinPos2[2], $aWinPos2[3], $hPen) ; _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDOT) DllCall($__g_hGDIPDll, "int", "GdipSetPenDashArray", "handle", $hPen, "struct*", $tArray, "long", $iCount) _GDIPlus_PenSetColor($hPen, $RectColor) _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $aWinPos2[2], $aWinPos2[3], $hPen) ; draw again rect EndIf If TimerDiff($iTimerID) > $iDelay Then $fOffset = Mod($fOffset + .5, $iDotsDashesTotLen) ; this is the key for the animated dotted line ;-) by UEZ ; https://www.autoitscript.com/forum/topic/185769-moving-dash-rectangle/?do=findComment&comment=1343851 DllCall($__g_hGDIPDll, "int", "GdipSetPenDashOffset", "handle", $hPen, "float", $fOffset) _GDIPlus_GraphicsClear($hGraphic, $AlphaKey) ; erase rect _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLESOLID) _GDIPlus_PenSetColor($hPen, $RectBgColor) _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $aWinPos2[2], $aWinPos2[3], $hPen) ; _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDOT) DllCall($__g_hGDIPDll, "int", "GdipSetPenDashArray", "handle", $hPen, "struct*", $tArray, "long", $iCount) _GDIPlus_PenSetColor($hPen, $RectColor) _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $aWinPos2[2], $aWinPos2[3], $hPen) ; draw again rect $iTimerID = TimerInit() EndIf Until Not _IsPressed("1", $hDLL) ; Right click released EndIf If TimerDiff($iTimerID) > $iDelay Then $fOffset = Mod($fOffset + .5, $iDotsDashesTotLen) DllCall($__g_hGDIPDll, "int", "GdipSetPenDashOffset", "handle", $hPen, "float", $fOffset) ; this is the key for the animated dotted line ;-) by UEZ _GDIPlus_GraphicsClear($hGraphic, $AlphaKey) ; erase rect _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLESOLID) _GDIPlus_PenSetColor($hPen, $RectBgColor) _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $aWinPos2[2], $aWinPos2[3], $hPen) ; _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDOT) DllCall($__g_hGDIPDll, "int", "GdipSetPenDashArray", "handle", $hPen, "struct*", $tArray, "long", $iCount) _GDIPlus_PenSetColor($hPen, $RectColor) _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $aWinPos2[2], $aWinPos2[3], $hPen) ; draw again rect $iTimerID = TimerInit() EndIf If _IsPressed('1B', $hDLL) Then $bEscape = True ; 1B ESC key Until ((_IsPressed('2', $hDLL) Or $bEscape) And (WinActive($hGUI2) Or WinActive($hGUI3))) ; RightClick means I'm done with selection Do ; neutralize the RightClick persistency Until Not _IsPressed('2', $hDLL) Local $aGotRect[4] = [ _ $aWinPos2[0] + $iBorder, _ ; ....... UpperLeft X of window's client area $aWinPos2[1] + $iBorder, _ ; ....... UpperLeft Y of window's client area $aWinPos2[2] - $iBorder * 2, _ ; ... Width of window's client area $aWinPos2[3] - $iBorder * 2 _ ; .... Height of window's client area ] _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() DllClose($hDLL) $tArray = 0 GUIDelete($hGUI3) GUIDelete($hGUI2) Return SetError(0, $bEscape, $aGotRect) EndFunc ;==>_Crop CropTool.au3
    1 point
  3. Melba23

    Click on 2nd Monitor

    oooo35980, A pity you do not seek to set a better example to your students. If you are required to watch the videos then watch them you should. We will not help you with this. M23
    1 point
  4. UEZ

    ✂️ Quick crop tool

    @Chimp if you add #AutoIt3Wrapper_Res_HiDpi=y it will work, too, when DPI is <> 100% but only if compiled.
    1 point
  5. ;$sText = "\u4e3a\u4e86\u9632\u6b62\u5723\u7269\u91d1\u5777\u5783\u843d\u5165\u4fb5\u7565\u8005\u7684\u624b\u4e2d\uff0c\u5723\u5730\u4e9a\u6208\u5927\u9646\u4e0a\u7684\u6218\u58eb\u4eec\u7eb7\u7eb7\u633a\u8eab\u800c\u51fa\u3002" $sText = "F1\u00ae 2020 allows you to create your F1\u00ae team &amp; whatever" $sDecoded = _Encoding_JavaUnicodeDecode($sText) $sDecoded = _HTMLEntities_Decode($sDecoded) MsgBox(64, @ScriptName, $sDecoded) Func _Encoding_JavaUnicodeDecode($sString) Local $sRet = '' Local $aString = StringRegExp($sString, "(\\\\|\\'|\\u[[:xdigit:]]{4}|[[:ascii:]])", 3) If @error Then Return SetError(1, 0, '') EndIf For $i = 0 To UBound($aString) - 1 Switch StringLen($aString[$i]) Case 1 $sRet &= $aString[$i] Case 2 $sRet &= StringRight($aString[$i], 1) Case 6 $sRet &= ChrW(Dec(StringRight($aString[$i], 4))) EndSwitch Next Return $sRet EndFunc Func _HTMLEntities_Decode($sTxt) Local $aTxt, $iAsc, $sChr Local Const $aisEntities[246][2] = [[34, 'quot'], [38, 'amp'], [39, 'apos'], [60, 'lt'], [62, 'gt'], [160, 'nbsp'], [161, 'iexcl'], [162, 'cent'], [163, 'pound'], [164, 'curren'], [165, 'yen'], [166, 'brvbar'], [167, 'sect'], [168, 'uml'], [169, 'copy'], [170, 'ordf'], [171, 'laquo'], [172, 'not'], [173, 'shy'], [174, 'reg'], [175, 'macr'], [176, 'deg'], [177, 'plusmn'], [180, 'acute'], [181, 'micro'], [182, 'para'], [183, 'middot'], [184, 'cedil'], [186, 'ordm'], [187, 'raquo'], [191, 'iquest'], [192, 'Agrave'], [193, 'Aacute'], [194, 'Acirc'], [195, 'Atilde'], [196, 'Auml'], [197, 'Aring'], [198, 'AElig'], [199, 'Ccedil'], [200, 'Egrave'], [201, 'Eacute'], [202, 'Ecirc'], [203, 'Euml'], [204, 'Igrave'], [205, 'Iacute'], [206, 'Icirc'], [207, 'Iuml'], [208, 'ETH'], [209, 'Ntilde'], [210, 'Ograve'], [211, 'Oacute'], [212, 'Ocirc'], [213, 'Otilde'], [214, 'Ouml'], [215, 'times'], [216, 'Oslash'], [217, 'Ugrave'], [218, 'Uacute'], [219, 'Ucirc'], [220, 'Uuml'], [221, 'Yacute'], [222, 'THORN'], [223, 'szlig'], [224, 'agrave'], [225, 'aacute'], [226, 'acirc'], [227, 'atilde'], [228, 'auml'], [229, 'aring'], [230, 'aelig'], [231, 'ccedil'], [232, 'egrave'], [233, 'eacute'], [234, 'ecirc'], [235, 'euml'], [236, 'igrave'], [237, 'iacute'], [238, 'icirc'], [239, 'iuml'], [240, 'eth'], [241, 'ntilde'], [242, 'ograve'], [243, 'oacute'], [244, 'ocirc'], [245, 'otilde'], [246, 'ouml'], [247, 'divide'], [248, 'oslash'], [249, 'ugrave'], [250, 'uacute'], [251, 'ucirc'], [252, 'uuml'], [253, 'yacute'], [254, 'thorn'], [255, 'yuml'], [338, 'OElig'], [339, 'oelig'], [352, 'Scaron'], [353, 'scaron'], [376, 'Yuml'], [402, 'fnof'], [710, 'circ'], [732, 'tilde'], [913, 'Alpha'], [914, 'Beta'], [915, 'Gamma'], [916, 'Delta'], [917, 'Epsilon'], [918, 'Zeta'], [919, 'Eta'], [920, 'Theta'], [921, 'Iota'], [922, 'Kappa'], [923, 'Lambda'], [924, 'Mu'], [925, 'Nu'], [926, 'Xi'], [927, 'Omicron'], [928, 'Pi'], [929, 'Rho'], [931, 'Sigma'], [932, 'Tau'], [933, 'Upsilon'], [934, 'Phi'], [935, 'Chi'], [936, 'Psi'], [937, 'Omega'], [945, 'alpha'], [946, 'beta'], [947, 'gamma'], [948, 'delta'], [949, 'epsilon'], [950, 'zeta'], [951, 'eta'], [952, 'theta'], [953, 'iota'], [954, 'kappa'], [955, 'lambda'], [956, 'mu'], [957, 'nu'], [958, 'xi'], [959, 'omicron'], [960, 'pi'], [961, 'rho'], [962, 'sigmaf'], [963, 'sigma'], [964, 'tau'], [965, 'upsilon'], [966, 'phi'], [967, 'chi'], [968, 'psi'], [969, 'omega'], [977, 'thetasym'], [978, 'upsih'], [982, 'piv'], [8194, 'ensp'], [8195, 'emsp'], [8201, 'thinsp'], [8204, 'zwnj'], [8205, 'zwj'], [8206, 'lrm'], [8207, 'rlm'], [8211, 'ndash'], [8212, 'mdash'], [8216, 'lsquo'], [8217, 'rsquo'], [8218, 'sbquo'], [8220, 'ldquo'], [8221, 'rdquo'], [8222, 'bdquo'], [8224, 'dagger'], [8225, 'Dagger'], [8226, 'bull'], [8230, 'hellip'], [8240, 'permil'], [8242, 'prime'], [8243, 'Prime'], [8249, 'lsaquo'], [8250, 'rsaquo'], [8254, 'oline'], [8260, 'frasl'], [8364, 'euro'], [8465, 'image'], [8472, 'weierp'], [8476, 'real'], [8482, 'trade'], [8501, 'alefsym'], [8592, 'larr'], [8593, 'uarr'], [8594, 'rarr'], [8595, 'darr'], [8596, 'harr'], [8629, 'crarr'], [8656, 'lArr'], [8657, 'uArr'], [8658, 'rArr'], [8659, 'dArr'], [8660, 'hArr'], [8704, 'forall'], [8706, 'part'], [8707, 'exist'], [8709, 'empty'], [8711, 'nabla'], [8712, 'isin'], [8713, 'notin'], [8715, 'ni'], [8719, 'prod'], [8721, 'sum'], [8722, 'minus'], [8727, 'lowast'], [8730, 'radic'], [8733, 'prop'], [8734, 'infin'], [8736, 'ang'], [8743, 'and'], [8744, 'or'], [8745, 'cap'], [8746, 'cup'], [8747, 'int'], [8764, 'sim'], [8773, 'cong'], [8776, 'asymp'], [8800, 'ne'], [8801, 'equiv'], [8804, 'le'], [8805, 'ge'], [8834, 'sub'], [8835, 'sup'], [8836, 'nsub'], [8838, 'sube'], [8839, 'supe'], [8853, 'oplus'], [8855, 'otimes'], [8869, 'perp'], [8901, 'sdot'], [8968, 'lceil'], [8969, 'rceil'], [8970, 'lfloor'], [8971, 'rfloor'], [9001, 'lang'], [9002, 'rang'], [9674, 'loz'], [9824, 'spades'], [9827, 'clubs'], [9829, 'hearts'], [9830, 'diams']] For $i = 0 To 245 $sTxt = StringReplace($sTxt, '&' & $aisEntities[$i][1] & ';', ChrW($aisEntities[$i][0]), 0, 1) Next $aTxt = StringRegExp($sTxt, '(&#\d+;)', 3) For $i = 0 To UBound($aTxt)-1 $iAsc = StringRegExpReplace($aTxt[$i], '\D+', '') If $iAsc > 255 Then $sChr = ChrW($iAsc) Else $sChr = Chr($iAsc) EndIf $sTxt = StringReplace($sTxt, $aTxt[$i], $sChr) Next Return $sTxt EndFunc
    1 point
  6. Musashi

    ✂️ Quick crop tool

    Works without problems (Win7-64 SP1 and AutoIt 3.3.14.0) 👍
    1 point
  7. Let's take another viewpoint: beside the fact that you delete a sentence once a similar one is found instead of exchanging them, the basic algoritm is similar to a recursion of buble sorts, of global complexity O(n!), which grows very rapidly in n. This, added to the basic property of the Damerau-Levenshtein distance which is essentially in O(nm) with n = number of entries and m their average length, makes the whole algorithm inherently slow. I don't believe there exist a magic silver bullet to kill this bird, but actual run times highly depend on sentence complexity (length, among other considerations) and how you consider two sentences similar or not. I means typos is one possible source of difference; synonyms, addition of extra words or omission of words is another one; "Yoda talk" (phrase rearrangement) is yet a completely different one. How would you compare and classify these sentences? In Spain, the rain falls mainly on the plains. In Spain, the rain mostly falls on the plains. The rain in Spain falls mainly on the vast plains. The rain in Spain predominantly falls on the plains. Most of the autumn rain falls on the plains in Spain. I think it would be very helpful if you could provide a real-world sufficiently large sample, along with a few examples of which sentences (line numbers) you'd regard as similar and a few which you'd consider "not similar enough, but close to". Be sure to include both typical and pathological cases. The samples you have included in the zip file are most probably too far from real-world. It might reveal beneficial to adopt a completely different approach and most probably a mix/compound of several techniques. Depending on the language used, reducing phrases to their soundex (EN) or the equivalent for your language can be one good idea. Limiting compares between phrases having "similar enough" length can also be a great help. Counting words (or whitespaces) can also be a good clue. Comparing the distribution of letters (think StringToAsciiArray) can be a good criterion. I believe a clever mix of these techniques can be globally faster than a brute force distance comparison, but that highly depends on real-world data, your degree of acceptance of false positives and false negatives, and more. Any useable criterion allowing to reasonably split the source in several distinct "candidate similar" buckets of sentences, each to be processed separately later, is worth the pain when the source gets large enough. This comes from the overall exponential complexity of comparisons and algorithm of managing compares.
    1 point
  8. Been struggling with this one for a while. when I do a _screencapture_capture call on a high resolution monitor (like my surface book) it gives me an image that has 2 problems: 1. its in the wrong location on the screen and 2. it gives me a picture that is larger than the area of the screen I selected, though it only has the content of what I selected. --------------------------- I was able to easily fix problem #1 by manually adjusting the x y coordinates to compensate for the amount of DPI scale I have. for instance if I'm 200% zoomed in the code looks like this: Local $bmp = _ScreenCapture_Capture("", $iX1*2, $iY1*2, $iX2*2, $iY2*2, false) it's problem #2 that is the big problem. I'd like to attach a screen shot of what I'm talking about (see capture.png) --------------------------- Now I basically understand why this is happening. ScreenCapture grabs each pixel of the screen. This screen, being a high resolution, when its zoomed in adds up several pixels to make one on the screen. This is a problem for me because I'm taking images of the screen and later looking for those exact images on the screen. if everything is blown up by an indeterminate amount (in my case 2x) then those images can't be found later on. Does anyone know what I can do? I tried resizing the images back down to no avail. _GDIPlus_ImageResize and _GDIPlus_ImageScale don't work because they don't compress the pixels correctly. quality is lost. and the exact image isn't preserved, so I can't search for it later. (see capture1.png) Anyway, I'm about to give up, been on this problem for too long! does anyone know what I can do? Seems to me that the ideal solution would be to eventually have autoit add an argument to _screencapture_capture that lets you specify a DPI scale amount or something. that can be pulled from the registry at HKEY_CURRENT_USER\control panel\desktop\windowmetrics\appliedDPI. But in the meantime, does anyone have any suggestions for how I can make my program compatible with 4k resolution monitors? I either need to take the screen capture like normal, then scale it down appropriately without losing quality, or I need to capture the screen in the first place like the human sees it. But I don't know how to do that either. I'll post my relevant code here: (in my project I call ScreenCapture_DPI_Aware) #include <Security.au3> Func _GetAppliedDPI()   Local $aArrayOfData = _Security__LookupAccountName(@UserName)   If IsArray($aArrayOfData) Then   ;msgbox(64, "SID String = ", $aArrayOfData[0] & @CRLF)   ;msgbox(64, "Domain name = ", $aArrayOfData[1] & @CRLF)   ;msgbox(64, "SID type = ", _Security__SidTypeStr($aArrayOfData[2]) & @CRLF)     ;Local $AppliedDPI = RegRead("HKEY_USERS\" & $aArrayOfData[0] & "\Control Panel\Desktop\WindowMetrics", "AppliedDPI") Local $AppliedDPI = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics", "AppliedDPI")     return $AppliedDPI   EndIf EndFunc Func GetScale()   $applied = _GetAppliedDPI()   if $applied == "" then     return 1   else     return $applied / 96   EndIf EndFunc Func ScreenCapture_Capture_DPI_Aware($sBMP_Path, $iX1, $iY1, $iX2, $iY2, $bool)   $R = GetScale() ;Raito   Local $bmp = _ScreenCapture_Capture($sBMP_Path, $iX1*$R, $iY1*$R, $iX2*$R, $iY2*$R, $bool) ;Scaling didn't work: ;_ScaleImage($bmp, $sBMP_Path, abs($iX2 - $iX1), abs($iY2 - $iY1), $R)   ;return _ScreenCapture_Capture($sBMP_Path, $iX1*$R, $iY1*$R, $iX2*$R, $iY2*$R, $bool) EndFunc ;Func _ScaleImage($bmp, $outimage, $w, $h, $scale) ; _GDIPlus_Startup() ;Get the encoder of to save the resized image in the format you want. ; Local $Ext = StringUpper(StringMid($outimage, StringInStr($outimage, ".", 0, -1) + 1)) ; $CLSID = _GDIPlus_EncodersGetCLSID($Ext) ; code found here : https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_ImageSaveToStream.htm ; Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("png") ;create CLSID for a JPG image file type ; Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) ;convert CLSID GUID to binary form and returns $tagGUID structure ; Local $tParams = _GDIPlus_ParamInit(1) ;initialize an encoder parameter list and return $tagGDIPENCODERPARAMS structure ; Local $tData = DllStructCreate("int Quality") ;create struct to set JPG quality setting ; DllStructSetData($tData, "Quality", 100) ;quality 0-100 (0: lowest, 100: highest) ; Local $pData = DllStructGetPtr($tData) ;get pointer from quality struct ; _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) ;add a value to an encoder parameter list ; Local $gbmp = _GDIPlus_BitmapCreateFromHBITMAP($bmp) ; _WinAPI_DeleteObject($bmp) ; Local $gsbmp = _GDIPlus_ImageResize($gbmp, $w * $scale, $h * $scale) ;Local $ext = _GDIPlus_EncodersGetCLSID("PNG") ; _GDIPlus_ImageSaveToFileEx($gsbmp, $outimage, $sImgCLSID) ; _GDIPlus_BitmapDispose($gbmp) ; _GDIPlus_BitmapDispose($gsbmp) ; _GDIPlus_Shutdown() ;EndFunc Thanks for any help you can give me!!!
    1 point
  9. Thanks RTFC! this is what I came up with to fix the prob: #include <lib\applieddpi.au3> Func Load_ScreenCapture_High_DPI_Check() $R = GetScale() if $R == 1 then ; should fix this to work with dual monitors. later. else #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_HiDpi=Y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** DllCall("User32.dll","bool","SetProcessDPIAware") ;(work around) first screencapture doesn't seem to work right, so take one and throw away. _ScreenCapture_Capture("",0,0,@DesktopWidth,@DesktopHeight) endif EndFunc Load_ScreenCapture_High_DPI_Check() ;;;;;;;AppliedDPI.au3 #include <Security.au3> Func _GetAppliedDPI() Local $AppliedDPI = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics", "AppliedDPI") return $AppliedDPI EndFunc Func GetScale() $applied = _GetAppliedDPI() if $applied == "" then return 1 else return $applied / 96 EndIf EndFunc
    1 point
  10. I know turning scaling off would change your labels not sure about the app not running with the manifest entry added though. I wonder if maybe it has something to do with this: 'SetProcessDPIAware is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, use SetProcessDpiAwareness' SetProcessDpiAwareness: https://msdn.microsoft.com/en-us/library/windows/desktop/dn302122(v=vs.85).aspx It seems to have the same caveats as SetProcessDPIAware as in placing in manifest rather than calling the function directly, it also isn't available till win 8 and later. Perhaps W10 won't work with the older function in the manifest which I find odd. If so, I think additions to the manifest or logic would be something that would have to be updated in the Autoit Res_HiDpi Pragma Maybe someone more knowledgeable with aut2Exe would be able to inform us on that. For the time being maybe you should use either your current function or maybe do something like this: If @OsType="WIN_10" Then DllCall("Shcore.dll","long","PROCESS_DPI_AWARENESS",1)  Else DllCall("User32.dll","bool","SetProcessDPIAware") EndIf ;hResult is 32bit ;PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 Not sure if I got that dll call right I'm not near a PC to test atm. Also, Not necessarily directed at you: I'm unsure how likely it is that a Dll would cache the dpi data. Would the Dll be something called by Autoit or the OS. What exact situation would result in this Race Condition and what are the consequences? Be something to look into as the MSDN page is kind of vague.
    1 point
  11. This can happen when Win10 auto-rescales (see under display settings, I think 125% is default for 1920x1080) to make them easier to read (as hi-res screens make everything that used to look about the right size look tiny now). To make your original script work in full resolution (with macros returning the correct (full) dimensions), while maintaining rescaling for regular programmes, add: DllCall("User32.dll","bool","SetProcessDPIAware") This causes the script to take advantage of the full current resolution, but at the cost of its text and graphics appearing smaller than if running rescaled.
    1 point
  12. Melba23

    $WS_EX_MDICHILD bug

    TheAutomator, Is this something like what you are looking for? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> Global Const $SC_DRAGMOVE = 0xF012 $ParentForm = GUICreate("Example", 460, 260) GUISetBkColor(0xFF0000) GUISetState(@SW_SHOW) Global $ChildForm1 = GUICreate("", 460, 260, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $ParentForm) GUISetBkColor(0x00FF00) Global $GoTo_ChildForm2 = GUICtrlCreateButton("Next form", 320, 20, 120, 40) GUISetState(@SW_SHOW) Global $ChildForm2 = GUICreate("", 460, 260, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $ParentForm) GUISetBkColor(0x0000FF) Global $Label = GUICtrlCreateLabel("this is form 2", 20, 80, 414, 28) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") GUISetState(@SW_HIDE) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GoTo_ChildForm2 GUISetState(@SW_HIDE, $ChildForm1) GUISetState(@SW_SHOW, $ChildForm2) Case $GUI_EVENT_PRIMARYDOWN _SendMessage(WinGetHandle("[ACTIVE]"), $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch WEnd M23
    1 point
×
×
  • Create New...