Jump to content

Recommended Posts

Posted (edited)

Hi folks, new release 0.3.0 - 2026-01-20ย published ๐ŸŽ‰ .
All relevant changes can be found in the CHANGELOG.

Wish you all a pleasant day ๐Ÿ˜ , from @WildByDesign, myself, and the other contributors .

Best regards
Sven

----------------

Maybe you want to put the CHANGELOG link in your initial post #1 of the thread @WildByDesign?

Edited by SOLVE-SMART

==> AutoIt related: ๐Ÿ”—ย Organization AutoIt Community,ย ๐Ÿ”— GitHub, ๐Ÿ”— Discord Server, ๐Ÿ”—ย Cheat Sheet,ย ๐Ÿ”—ย autoit-webdriver-boilerplate

Spoiler

๐ŸŒย Au3Forums

๐ŸŽฒ AutoIt (en) Cheat Sheet

๐Ÿ“Š AutoIt limits/defaults

๐Ÿ’Ž Code Katas: [...] (comming soon)

๐ŸŽญ Collection of GitHub users with AutoIt projects

๐Ÿžย False-Positives

๐Ÿ”ฎย Me on GitHub

๐Ÿ’ฌย Opinion about new forum sub category

๐Ÿ“‘ย UDF wiki list

โœ‚ย VSCode-AutoItSnippets

๐Ÿ“‘ย WebDriver FAQs

๐Ÿ‘จโ€๐Ÿซย WebDriver Tutorial (coming soon)

Posted
1 hour ago, WildByDesign said:

I have had some success with the drag cursor. Not quite confident enough about doing a commit yet because I need to test it more.ย _WinAPI_SetSystemCursor seems to be the only way I could get it done smoothly.

There is also theย GUISetCursor(6, 1, $hGui) function.
I had the idea to use the (obsolete=>see MouseGetCursor help remarks) ICON cursor and replace that with _WinAPI_SetSystemCursor and use that with GuiSetCursor to enable that icon for the gui, if that works (untested).
GuiSetCursor with the override parameter should atleast avoid setting the SystemCursor for all cursors used in the gui (normal, hand,...).

Posted (edited)
44 minutes ago, Kanashius said:

I had the idea to use the (obsolete=>see MouseGetCursor help remarks) ICON cursor and replace that with _WinAPI_SetSystemCursor and use that with GuiSetCursor to enable that icon for the gui, if that works (untested).

That's a great idea. And many times, when MS refers to something as obsolete, they usually still leave traces behind and such obsolete feature can often still work for legacy purposes. But in this case, it doesn't seem to work. I tried it right now and it didn't work for me.

One thing that I recall from my Immersive UX (AutoIt) project is that for File Explorer and Explorer++, during a drag operation a window appears with theย SysDragImage class name. But I have no idea how that works to create from AutoIt.

Also, my attempts withย _GUICtrlTreeView_CreateDragImage all failed. The help file example didn't work and I tried all examples from the forum and none of them worked either. Maybe it just doesn't work on Win10/11, but I am not sure.

There is something that I can do, along with whatever cursor change we make. I can show a tooltip that follows the mouse movement during the drag to show the destination as it changes over top of folders before the user releases the mouse button.

EDIT: The ListView variant for creating the drag image (_GUICtrlListView_CreateDragImage) from the help file also seems to do nothing.ย 

Edited by WildByDesign
Posted

I've got the tracking tooltips working great for the drag and drop. It changes the destination folder depending on where the cursor is hovering over.

I was checking outย _GUIToolTip_SetTitleย and noticed that you can have an icon showing:

[optional] Set to one of the values below:.
    $TTI_NONE (0) - No icon [default]
    $TTI_INFO (1) - Information icon
    $TTI_WARNING (2) - Warning icon
    $TTI_ERROR (3) - Error Icon
    $TTI_INFO_LARGE (4) - Large Information Icon
    $TTI_WARNING_LARGE (5) - Large Warning Icon
    $TTI_ERROR_LARGE (6) - Large Error Icon
Quote

As of Windows XP SP2 and later, $iIcon can contain an HICON value. Any value greater than 3 is assumed to be an HICON.

Here is the code for the function from the GuiToolTip.au3 UDF:

Func _GUIToolTip_SetTitle($hTool, $sTitle, $iIcon = 0)
    Local $tBuffer = $__g_tTTBuffer
    DllStructSetData($tBuffer, "Text", $sTitle)
    Local $iRet = __GUICtrl_SendMsg($hTool, $TTM_SETTITLEW, $iIcon, $tBuffer)

    Return $iRet <> 0
EndFunc   ;==>_GUIToolTip_SetTitle

ย 

Does anyone know if this could be used to display a custom icon somehow?

For example, if we could display a specific file type icon or something related to what is being dragged.

Posted
2 minutes ago, Kanashius said:

Yes, you can use GDIPlus to create a HICON:ย _GDIPlus_HICONCreateFromBitmap ( $hBitmap )

Does the UDF have an index of icons stored? That could be very helpful.

Posted (edited)
9 hours ago, SOLVE-SMART said:

Maybe you want to put the CHANGELOG link in your initial post #1 of the thread @WildByDesign?

Great suggestion. I've added the changelog and a link that always goes to the latest release.

Edited by WildByDesign
Posted (edited)

ย Another solution for the cursor would be:ย GUISetCursor(16, 1, $hGui) together with a child-gui, moving along the cursor position.
I wrote an example here:
Just left click drag inside the window (and adjust the $sPathArrowDrag at the top).

#include <WindowsConstants.au3>
#include <WinAPIConv.au3>
#include <WinAPISysWin.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>


Global $sPathArrowDrag = "ArrowDrag.png", $iArrowSize = 30, $bDragging = False

Local $hGui = GUICreate("", 800, 600)
GUISetState(@SW_SHOW, $hGui)
GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUIRegisterMsg($WM_PAINT, "WM_PAINT")

Local $hGuiArrowDrag = GUICreate("", $iArrowSize, $iArrowSize, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_TRANSPARENT), $hGui) ; BitOR($WS_EX_MDICHILD, $WS_EX_TRANSPARENT)
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($sPathArrowDrag)
Local $hBitmap = _GDIPlus_ImageResize($hImage, $iArrowSize, $iArrowSize, 7)
_GDIPlus_ImageDispose($hImage)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGuiArrowDrag)
GUISetState(@SW_HIDE, $hGuiArrowDrag)


While 1
    If GUIGetMsg()=-3 Then
        _GDIPlus_BitmapDispose($hBitmap)
        _GDIPlus_Shutdown()
        Exit
    EndIf
WEnd

Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam)
    If $hWnd=$hGui Then
        If BitAND($wParam, 0x0001) Then
            If Not $bDragging Then
                $bDragging = True
                GUISetState(@SW_SHOW, $hGuiArrowDrag)
                GUISetCursor(16, 1, $hGui)
            EndIf
            Local $x = _WinAPI_LoWord($lParam), $y = _WinAPI_HiWord($lParam)
            Local $arPos = WinGetPos($hGui)
            Local $iDiff = $arPos[3] - _WinAPI_GetClientHeight($hGui)
            WinMove($hGuiArrowDrag, "", $arPos[0]+$x+2, $arPos[1]+$y+$iDiff-2)
        Else
            If $bDragging Then
                $bDragging = False
                GUISetState(@SW_HIDE, $hGuiArrowDrag)
                GUISetCursor(2, 0, $hGui)
            EndIf
        EndIf
    EndIf
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
    If $hWnd<>$hGui Then Return -1 ; HTTRANSPARENT
EndFunc

Func WM_PAINT($hWnd, $msg, $wParam, $lParam)
    If $hWnd=$hGuiArrowDrag Then
        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
        _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)
        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
    EndIf
EndFunc

Maybe this help :)
This could also be extended to include the destination (the tooltip you mentioned).
But the cursor should be remade in the target resolution to avoid blur through scaling (grey instead of black lines).

Edited by Kanashius

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...