mike2003 Posted September 17, 2021 Share Posted September 17, 2021 When the mouse moves, a trail is left behind, which disappears over time. Does anyone know if this can be done? Link to comment Share on other sites More sharing options...
Leendert-Jan Posted September 17, 2021 Share Posted September 17, 2021 You can use the _GDIPlus_GraphicsDrawLine function to make it draw a line at your cursor. https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_GraphicsDrawLine.htm There is also this post that might help. Link to comment Share on other sites More sharing options...
mike2003 Posted September 17, 2021 Author Share Posted September 17, 2021 But I need to control the lines, hide, change the transparency. But as far as I understood, it does not allow to do so. Link to comment Share on other sites More sharing options...
Leendert-Jan Posted September 17, 2021 Share Posted September 17, 2021 (edited) I made a test script that gets the mouse's position and draws a little dot in it's place. Snippet: While 1 $aPos = MouseGetPos() _GDIPlus_GraphicsDrawLine($hGraphic, $aPos[0], $aPos[1], $aPos[0] + 2.5, $aPos[1] + 2.5, $hPen) WEnd There is no Sleep function called in the while loop, so it should execute as frequent as possible. I am afraid AutoIt isn't the right tool to make what you are trying to do. Here is the result: Edited September 17, 2021 by Leendert-Jan Link to comment Share on other sites More sharing options...
mike2003 Posted September 17, 2021 Author Share Posted September 17, 2021 The tail should disappear ) This is not a drawing. In theory, for example, you need to draw 10 elements as a line from the coordinates of the mouse and then change their transparency. Link to comment Share on other sites More sharing options...
Leendert-Jan Posted September 17, 2021 Share Posted September 17, 2021 (edited) My point was that it is not going to work with AutoIt. There might be a way to make the line more transparent over time, creating the effect that you want, but if drawing a line in the first place does not work, why bother trying to make the line transparent? First we need a working script that follows the mouse and draws a SOLID line, after that we can start worrying about making the effects possible. But as shown in my post, simply drawing a line isn't possible in the first place. Edited September 17, 2021 by Leendert-Jan Spelling Link to comment Share on other sites More sharing options...
Danp2 Posted September 17, 2021 Share Posted September 17, 2021 @Leendert-JanTry saving the prior mouse position and using that set of coordinates along with the current mouse position. @mike2003I know that Windows offers the "Display pointer trails" feature. I'm guessing that there are other existing tools for doing what you want. Why is it necessary to do this with AutoIt? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Werty Posted September 17, 2021 Share Posted September 17, 2021 (edited) #include <WinAPISys.au3> #include <WinAPIsysinfoConstants.au3> _WinAPI_SystemParametersInfo($SPI_SETMOUSETRAILS, 15, 0, NULL) Change the "15" to 1 or 0 to turn it off Though this is globally, but i'm sure UEZ could come up with a solution in gdiplus. Edited September 17, 2021 by Werty Danp2 and Gianni 2 Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Nine Posted September 18, 2021 Share Posted September 18, 2021 (edited) Maybe this : expandcollapse popup#include <GDIPlus.au3> #include <GUIConstants.au3> Global Const $SIZE = 600 Example() Func Example() Local $hGUI = GUICreate("", $SIZE, $SIZE, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) _GDIPlus_Startup() Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($SIZE, $SIZE, $hGraphic) Global $hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfxCtxt, 2) GUISetState(@SW_SHOW) Local $Xprev = MouseGetPos(0), $Yprev = MouseGetPos(1), $X, $Y, $iPointer = 0 Global $aDraw[400][3] = [[$Xprev, $Yprev, 0xFF]] AdlibRegister(_Fade, 70) While True If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop $X = MouseGetPos(0) $Y = MouseGetPos(1) If $X = $Xprev And $Yprev = $Y Then ContinueLoop $iPointer += 1 If $iPointer = UBound($aDraw) Then $iPointer = 0 $aDraw[$iPointer][0] = $X $aDraw[$iPointer][1] = $Y $aDraw[$iPointer][2] = 0xFF $Xprev = $X $Yprev = $Y WEnd _GDIPlus_GraphicsDispose($hGfxCtxt) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example Func _Fade() Local $hPen _GDIPlus_GraphicsClear($hGfxCtxt, 0xFFFFFFFF) For $i = 0 to UBound($aDraw) - 1 If $aDraw[$i][2] And $aDraw[Mod($i+1,UBound($aDraw))][2] Then $aDraw[$i][2] -= 51 $hPen = _GDIPlus_PenCreate(Dec(Hex($aDraw[$i][2], 2) & "FF0000", $NUMBER_32BIT), 2) _GDIPlus_GraphicsDrawLine($hGfxCtxt, $aDraw[$i][0], $aDraw[$i][1], $aDraw[Mod($i+1,UBound($aDraw))][0], $aDraw[Mod($i+1,UBound($aDraw))][1], $hPen) _GDIPlus_PenDispose($hPen) EndIf Next _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $SIZE, $SIZE) EndFunc Edited September 18, 2021 by Nine Gianni and Werty 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Gianni Posted September 18, 2021 Share Posted September 18, 2021 Nice script @nine ... allow me just little modification on your listing: expandcollapse popup#include <GDIPlus.au3> #include <GUIConstants.au3> #include <WINAPI.au3> Global Const $SIZEx = @DesktopWidth, $SIZEy = @DesktopHeight, $AlphaKey = 0xFFFFFFFF Global $hGraphic, $hBitmap, $hGfxCtxt, $aDraw[400][3] Example() Func Example() ; Local $hGUI = GUICreate("", $SIZE, $SIZE, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) Local $hBackground = GUICreate("", $SIZEx, $SIZEy, 0, 0, $WS_POPUPWINDOW, $WS_EX_LAYERED + $WS_EX_TOPMOST) GUISetBkColor($AlphaKey, $hBackground) _WinAPI_SetLayeredWindowAttributes($hBackground, $AlphaKey, 0, $LWA_COLORKEY) GUISetState(@SW_SHOW, $hBackground) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hBackground) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($SIZEx, $SIZEy, $hGraphic) $hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfxCtxt, 2) Local $Xprev = MouseGetPos(0), $Yprev = MouseGetPos(1), $X, $Y, $iPointer = 0 ; $aDraw[400][3] = [[$Xprev, $Yprev, 0xFF]] $aDraw[0][0] = $Xprev $aDraw[0][1] = $Yprev $aDraw[0][2] = 0xFF AdlibRegister(_Fade, 70) While True If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop $X = MouseGetPos(0) $Y = MouseGetPos(1) If $X = $Xprev And $Yprev = $Y Then ContinueLoop $iPointer += 1 If $iPointer = UBound($aDraw) Then $iPointer = 0 $aDraw[$iPointer][0] = $X $aDraw[$iPointer][1] = $Y $aDraw[$iPointer][2] = 0xFF $Xprev = $X $Yprev = $Y WEnd _GDIPlus_GraphicsDispose($hGfxCtxt) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example Func _Fade() Local $hPen _GDIPlus_GraphicsClear($hGfxCtxt, 0xFFFFFFFF) For $i = 1 To UBound($aDraw) - 1 If $aDraw[$i][2] And $aDraw[Mod($i + 1, UBound($aDraw))][2] Then $aDraw[$i][2] -= 51 $hPen = _GDIPlus_PenCreate(Dec(Hex($aDraw[$i][2], 2) & "FF0000", $NUMBER_32BIT), 2) _GDIPlus_GraphicsDrawLine($hGfxCtxt, $aDraw[$i][0], $aDraw[$i][1], $aDraw[Mod($i + 1, UBound($aDraw))][0], $aDraw[Mod($i + 1, UBound($aDraw))][1], $hPen) _GDIPlus_PenDispose($hPen) EndIf Next _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $SIZEx, $SIZEy) EndFunc ;==>_Fade Werty 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Nine Posted September 18, 2021 Share Posted September 18, 2021 @Chimp Thanks for your suggestions. I just found a small bug (it would sometimes shortly draw a line from nowhere). So I needed to change the _Fade function to this : Func _Fade() Local Static $iFirst Local $hPen, $n _GDIPlus_GraphicsClear($hGfxCtxt, 0xFFFFFFFF) For $i = 0 to UBound($aDraw) - 1 If $aDraw[$iFirst][2] Then ExitLoop $iFirst = Mod($iFirst + 1, UBound($aDraw)) Next $n = $iFirst For $i = 0 To UBound($aDraw) - 1 If Not $aDraw[Mod($n+1,UBound($aDraw))][2] Then ExitLoop $aDraw[$n][2] -= 51 $hPen = _GDIPlus_PenCreate(Dec(Hex($aDraw[$n][2], 2) & "FF0000", $NUMBER_32BIT), 2) _GDIPlus_GraphicsDrawLine($hGfxCtxt, $aDraw[$n][0], $aDraw[$n][1], $aDraw[Mod($n+1,UBound($aDraw))][0], $aDraw[Mod($n+1,UBound($aDraw))][1], $hPen) _GDIPlus_PenDispose($hPen) $n = Mod($n+1, UBound($aDraw)) Next _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $SIZE, $SIZE) EndFunc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now