Jump to content

references to dragged and dropped objects?


Recommended Posts

Hello,

I searched the forum about this, but at the moment, without sucess.

I would like to drag an image (or a generic gui object) picked from an autoit gui and then I would drop it on another one of the same gui,

is there an easy way to accomplish this mechanism in autoit and get the references of both objects?

for example, if I compile this >simple script, and then I drag an image or a file from Explorer and I drop it to the executable, I get the path of the dropped file by reading the $CmdLine[1] variable

If $CmdLine[0] = 1 Then
MsgBox (0, "", "this file " & @CRLF & $CmdLine[1] & @CRLF & "was dropped to me.", 0)
EndIf

If $CmdLine[0] = 0 Then
MsgBox (0, "", "none dropped", 0)
EndIf

well, I wonder if such mechanism can be accomplished within the same script so to be able to get, maybe by an array, references to dragged object, and object receiving the dropped object

any suggestion is welcome

thanks

Edited by Pincopanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 1 year later...

Hi Chimp, this is my little toy (a part), I think it have a part what do you want...

See third tab, select one plane and drag something...

;~ http://technet.microsoft.com/en-us/library/ee176993.aspx

#include-once
#NoTrayIcon
#include <ListViewConstants.au3>
#include <GuiTab.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <String.au3>
#include <Array.au3>
#include <ComboConstants.au3>
#include <Misc.au3>
#include <GUIConstantsEx.au3>
;~ #include <C:\Dropbox\AutoIt\UDF\object_dump.au3>

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("MustDeclareVars", 1)
Opt("WinWaitDelay", 25)
Global $MODE = 0
Global $aCabides[1]
Global $oGame = ObjCreate("Scripting.Dictionary")
$oGame.CompareMode = $MODE
Global $AVIAO
$oGame.Add("arma", ObjCreate("Scripting.Dictionary"))
$oGame.Add("index_arma", ObjCreate("Scripting.Dictionary"))
$oGame.Add("aviao", ObjCreate("Scripting.Dictionary"))
$oGame.Add("index_aviao", ObjCreate("Scripting.Dictionary"))

Armas_Add("quadrado", 50) ; 0
Armas_Add("círculo", 60) ; 1
Armas_Add("triangulo", 70) ; 2
Armas_Add("losango", 80) ; 3
Armas_Add("estrela", 90) ; 4
Armas_Add("teclado", 100) ; 5
Armas_Add("caneca", 110) ; 6
Armas_Add("violão", 120) ; 7

Local $trux = Aviao_Add('trux', 2) ; 0
Municiar_Add($trux, 1, '1')
;~ Municiar_Add($trux, 2, 2)

Local $miux = Aviao_Add('miux', 3) ; 1
Municiar_Add($miux, 1, '4')
Municiar_Add($miux, 2, '3')
Municiar_Add($miux, 3, '2')
Local $kasp = Aviao_Add('kasp', 4) ; 2
Municiar_Add($kasp, 1, '4')
Municiar_Add($kasp, 2, '3')
Municiar_Add($kasp, 3, '2')
Municiar_Add($kasp, 4, '1')

Func Municiar_Add($iAviao, $iCabide, $iArma)
    If Not $oGame.Item("aviao").Exists($iAviao) Then Return SetError(1, 0, 1)
    If $iCabide < 1 Or $iCabide > $oGame.Item("aviao").Item($iAviao).Item("cabide_quantidade") Then Return SetError(1, 0, 2)
    If $oGame.Item("aviao").Item($iAviao).Item("cabide_quantidade").Exists($iCabide) Then $oGame.Item("aviao").Item($iAviao).Item("cabide").Remove($iCabide)
    $oGame.Item("aviao").Item($iAviao).Item("cabide").Add($iCabide, $oGame.Item("arma").Item($iArma))
EndFunc   ;==>Municiar_Add

Func Armas_Add($sArmaNome = "", $iArmaQuantidade = 0, $sArmaImagem = "")
    Local Static $iNext = 1
    Local $oo = ObjCreate("Scripting.Dictionary")
;~  $oo.Comparemode = $MODE
    $oo.Add("nome", $sArmaNome)
    $oo.Add("quantidade", $iArmaQuantidade)
    $oo.Add("imagem", $sArmaImagem)
    Local $iNum = String($iNext)
    $iNext += 1

    $oGame.Item("arma").Add($iNum, $oo)
    $oGame.Item("index_arma").Add($sArmaNome, $iNum)
EndFunc   ;==>Armas_Add

Func Aviao_Add($sAviaoNome = "", $iAviaoCabide = 0, $sAviaoImagem = "")
    Local Static $iNext = 1
    ConsoleWrite('Aviao_Add.$AVIAO[ ' & $AVIAO & ' ]' & @LF)
    If $AVIAO And Not ($AVIAO == -1) Then
        ConsoleWrite('Aviao_Add.SAVE[ ' & $AVIAO & ' ]' & @LF)
        Local $oldNome = $oGame.Item('aviao').Item($AVIAO).Item('nome')
        ConsoleWrite('$oldNome[ ' & $oldNome & ' ]' & @LF)
        $oGame.Item("index_aviao").Remove($oldNome)
        $oGame.Item('aviao').Item($AVIAO).Item('nome') = $sAviaoNome
        $oGame.Item('aviao').Item($AVIAO).Item('cabide_quantidade') = $iAviaoCabide
        $oGame.Item('aviao').Item($AVIAO).Item('imagem') = $sAviaoImagem

        $oGame.Item("index_aviao").Add($sAviaoNome, $AVIAO)
        Return $AVIAO
    Else
        ConsoleWrite('Aviao_Add.ADD [ ' & $AVIAO & ' ]' & @LF)
        Local $oo = ObjCreate("Scripting.Dictionary")
        $oo.Add("nome", $sAviaoNome)
        $oo.Add("cabide_quantidade", $iAviaoCabide)
        Local $oTemp = ObjCreate("Scripting.Dictionary")
        $oo.Add("cabide", $oTemp)
        $oo.Add("imagem", $sAviaoImagem)
        Local $iNum = String($iNext)
        $iNext += 1
        ConsoleWrite("$iNext[ " & $iNum & " ]" & @LF)
        $oGame.Item("aviao").Add($iNum, $oo)
        $oGame.Item("index_aviao").Add($sAviaoNome, $iNum)
        Return $iNum
    EndIf

EndFunc   ;==>Aviao_Add

;~ dump($oGame)

Global $hGui[1], $aGuiSize[2] = [800, 600], $sGuiTitle = 'Título'
Global $hButton, $hList, $hTab, $hTabItem[3], $ahSalvar[3]
Global $hListView[2]
Global $hAviaoNome, $hAviaoCabide, $hAviaoImagem

$hGui[0] = GUICreate($sGuiTitle, $aGuiSize[0], $aGuiSize[1], -1, -1, Default, Default)
GUISetOnEvent($GUI_EVENT_CLOSE, '_quit')
GUISetFont(12, 400, 0, 'Courier New', $hGui[0], $CLEARTYPE_QUALITY)

$hTab = GUICtrlCreateTab(10, 90, 780, 500)
GUICtrlSetOnEvent($hTab, '__Tabs')

$hTabItem[0] = GUICtrlCreateTabItem('Avião')
$hListView[0] = GUICtrlCreateListView('#|Aviões', 20, 125, 240, 455)
ControlDisable($hGui[0], "", HWnd(_GUICtrlListView_GetHeader($hListView[0])))
GUICtrlSetOnEvent($hListView[0], '__CarregarAviao')
_GUICtrlListView_SetColumnWidth($hListView[0], 0, 60)
;~ _GUICtrlListView_SetColumnWidth($hListView[0], 1, 180)

;~ _GUICtrlListView_SetColumnWidth($hListView[0], 0, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetColumnWidth($hListView[0], 1, $LVSCW_AUTOSIZE_USEHEADER)
$hAviaoNome = GUICtrlCreateInput('', 300, 125, 160, 25)
$hAviaoCabide = GUICtrlCreateInput(0, 300, 165, 160, 25)
$hAviaoImagem = GUICtrlCreateInput('', 300, 205, 160, 25)
$ahSalvar[0] = GUICtrlCreateButton('Salvar', 700, 555, 80, 25)
GUICtrlSetOnEvent($ahSalvar[0], '__Tab_0_Salvar')
$ahSalvar[1] = GUICtrlCreateButton('Limpar', 600, 555, 80, 25)
GUICtrlSetOnEvent($ahSalvar[1], '__Tab_0_Limpar')



$hTabItem[1] = GUICtrlCreateTabItem('Arma')

$hTabItem[2] = GUICtrlCreateTabItem('Armamento')

$hList = GUICtrlCreateCombo('Escolher', 20, 125, 160, 24, $CBS_DROPDOWNLIST)

$hListView[1] = GUICtrlCreateListView('', 20, 280, 760, 240)
GUICtrlSetStyle($hListView[1], $LVS_ICON)
GUICtrlSetFont($hListView[1], 8, 200, 0, 'MS-DOS')

GUICtrlCreateTabItem('')

GUICtrlSetOnEvent($hList, '__SetCabides')
GUISetOnEvent($GUI_EVENT_DROPPED, '__Drag')
__SetAviao()
__Exibir_Armas()

GUISetState(@SW_SHOWNORMAL)

_GUICtrlTab_ActivateTab($hTab, 0)

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While Sleep(10)

WEnd

Func _quit()
    _exit()
EndFunc   ;==>_quit

Func _exit($input = 0)
    If $input Then ConsoleWrite('exit[' & $input & ']' & @LF)
    GUIDelete($hGui[0])
;~  dump($oGame)
    Exit
EndFunc   ;==>_exit

Func __SetAviao()
    Local $sAviao = ''
    For $iAviao In $oGame.Item('aviao')
        $sAviao &= '|' & $oGame.Item('aviao').Item($iAviao).Item('nome')
    Next
    $sAviao = StringTrimLeft($sAviao, 1)
    GUICtrlSetData($hList, $sAviao)
EndFunc   ;==>__SetAviao

Func __SetCabides()
    Local $read = GUICtrlRead($hList)
    $AVIAO = __Lista_Aviao($read)
    ConsoleWrite('__SetCabides[ ' & $read & ' ] [ ' & $AVIAO & ' ]' & @LF)
    __Monta_Cabides()
EndFunc   ;==>__SetCabides

Func __Lista_Aviao($sAviaoNome = '')
    If $oGame.Item('index_aviao').Exists($sAviaoNome) Then Return $oGame.Item('index_aviao').Item($sAviaoNome)
    Return -1
EndFunc   ;==>__Lista_Aviao

Func __Lista_Arma($sArmaNome = '')
    If $oGame.Item('index_arma').Exists($sArmaNome) Then Return $oGame.Item('index_arma').Item($sArmaNome)
    Return -1
EndFunc   ;==>__Lista_Arma

Func __Monta_Cabides()
    If $AVIAO == -1 Then
        For $ii = UBound($aCabides, 1) - 1 To 1 Step -1
            GUICtrlDelete($aCabides[$ii])
            _ArrayDelete($aCabides, $ii)
        Next
    Else
        If Not ($oGame.Item('aviao').Item($AVIAO).Item('cabide_quantidade') == (UBound($aCabides, 1) - 1)) Then
            If $oGame.Item('aviao').Item($AVIAO).Item('cabide_quantidade') > (UBound($aCabides, 1) - 1) Then
                For $ii = UBound($aCabides, 1) - 0 To $oGame.Item('aviao').Item($AVIAO).Item('cabide_quantidade')
                    Local $id = _ArrayAdd($aCabides, GUICtrlCreateLabel('[' & $ii & ']', 20 + (($ii - 1) * 90), 160, 80, 80, $SS_SUNKEN, $WS_EX_ACCEPTFILES))
                    GUICtrlSetState($aCabides[$ii], $GUI_DROPACCEPTED)
                Next
            Else
                For $ii = UBound($aCabides, 1) - 1 To $oGame.Item('aviao').Item($AVIAO).Item('cabide_quantidade') + 1 Step -1
                    GUICtrlDelete($aCabides[$ii])
                    _ArrayDelete($aCabides, $ii)
                Next
            EndIf
            For $ii = 1 To UBound($aCabides, 1) - 1
                Local $var = $oGame.Item('aviao').Item($AVIAO).Item('cabide').Item($ii).Item('nome')
                GUICtrlSetData($aCabides[$ii], $var)
            Next
        EndIf
    EndIf
    ConsoleWrite('aCabides[ ' & _ArrayToString($aCabides, ',', 1) & ' ]' & @LF)
EndFunc   ;==>__Monta_Cabides

Func __Drag()
;~  http://azjio.narod.ru/autoit3_docs/userfunctions/WM_DROPFILES.htm
    Local $iHotItem = _GUICtrlListView_GetHotItem($hListView[1])
    Local $item = _GUICtrlListView_GetItem($hListView[1], $iHotItem)
    ConsoleWrite('__Drag( @GUI_DragId=' & @GUI_DragId & ', @GUI_DropId=' & @GUI_DropId & ' ) <' & $item[3] & '> __Lista_Arma[ ' & __Lista_Arma($item[3]) & ' ]' & @LF)
    Local $iArma = __Lista_Arma($item[3])
    If Not ($iArma == -1) Then
        Local $sArmaNome = $oGame.Item('arma').Item($iArma).Item('nome')
        GUICtrlSetData(@GUI_DropId, $sArmaNome)
        __Atualizar_Arma(@GUI_DropId - $aCabides[1] + 1, $iArma)
    EndIf
EndFunc   ;==>__Drag

Func __Atualizar_Arma($iCabide, $iArma)
    If Not ($AVIAO == -1) Then
        Local $sAviao = $oGame.Item('aviao').Item($AVIAO).Item('nome')
        If $oGame.Item('aviao').Item($AVIAO).Item('cabide').Exists($iCabide) Then $oGame.Item('aviao').Item($AVIAO).Item('cabide').Remove($iCabide)
        $oGame.Item('aviao').Item($AVIAO).Item('cabide').Add($iCabide, $oGame.Item('arma').Item($iArma))
    EndIf
EndFunc   ;==>__Atualizar_Arma

Func __Exibir_Armas()
    For $iArma In $oGame.Item('arma')
        _GUICtrlListView_AddItem($hListView[1], $oGame.Item('arma').Item($iArma).Item('nome'))
    Next
;~  _GUICtrlListView_SetWorkAreas($hListView[1], 0, 0, 120, 160)
EndFunc   ;==>__Exibir_Armas

Func __Tabs()
    ConsoleWrite('__Tabs[ ' & GUICtrlRead($hTab) & ' ]' & @LF)
    Local $iTab = GUICtrlRead($hTab)
    If $iTab == 2 Then
        _GUICtrlListView_DeleteAllItems($hListView[1])
        __Exibir_Armas()
        For $ii = 1 To UBound($aCabides, 1) - 1
            GUICtrlSetState($aCabides[$ii], $GUI_SHOW)
        Next
    Else
        For $ii = 1 To UBound($aCabides, 1) - 1
            GUICtrlSetState($aCabides[$ii], $GUI_HIDE)
        Next
    EndIf

    If $iTab == 0 Then
        Local $iItem
        _GUICtrlListView_DeleteAllItems($hListView[0])
        For $iAviao In $oGame.Item('aviao')
            $iItem = _GUICtrlListView_AddItem($hListView[0], $iAviao)
            _GUICtrlListView_AddSubItem($hListView[0], $iItem, $oGame.Item('aviao').Item($iAviao).Item('nome'), 1)

        Next
    Else

    EndIf
EndFunc   ;==>__Tabs

Func __CarregarAviao()
    ConsoleWrite('__CarregarAviao()' & @LF)
EndFunc   ;==>__CarregarAviao

;~ #NoTrayIcon
;~ #include <GUIConstantsEx.au3>
;~ #include <WindowsConstants.au3>
;~ #include <ListViewConstants.au3>
;~ #include <GuiListView.au3>

;~ $Form1 = GUICreate("Test", 300, 200, -1, -1)
;~ $hListView[0] = GUICtrlCreateListView("A|B|C", 15, 15, 270, 118)
;~ GUICtrlCreateListViewItem("r1c1|r1c2|r1c3", $hListView[0])
;~ GUICtrlCreateListViewItem("r2c1|r2c2|r2c3", $hListView[0])
;~ _GUICtrlListView_SetColumnWidth($hListView[0], 0, $LVSCW_AUTOSIZE)
;~ GUISetState(@SW_SHOW)

;~ GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

Func OnClick($item, $subitem)
    Local $value = _GUICtrlListView_GetItemText($hListView[0], $item, $subitem)

EndFunc   ;==>OnClick

Func OnDoubleClick($item, $subitem)
    Local $value = _GUICtrlListView_GetItemText($hListView[0], $item, $subitem)
    ConsoleWrite('DoubleClick: index:' & $item & ' subitem:' & $subitem & ' value:' & $value & @CRLF)
    $AVIAO = __Lista_Aviao($value)
    GUICtrlSetData($hAviaoNome, $value)
    GUICtrlSetData($hAviaoCabide, $oGame.Item('aviao').Item($AVIAO).Item('cabide_quantidade'))
    ConsoleWrite('Click: index:' & $item & ' subitem:' & $subitem & ' value:' & $value & '##' & $AVIAO & @CRLF)
    If $AVIAO == -1 Then __Tab_0_Limpar()
EndFunc   ;==>OnDoubleClick

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam

    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    Local $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    Local $nNotifyCode = DllStructGetData($tNMHDR, "Code")
    Local $tInfo, $item, $subitem
    If $wParam = $hListView[0] Then
        If $nNotifyCode = $NM_CLICK Then
            $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
            $item = DllStructGetData($tInfo, "Index")
            $subitem = DllStructGetData($tInfo, "SubItem")
            OnClick($item, $subitem)
        EndIf

        If $nNotifyCode = $NM_DBLCLK Then
            $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
            $item = DllStructGetData($tInfo, "Index")
            $subitem = DllStructGetData($tInfo, "SubItem")
            OnDoubleClick($item, $subitem)
        EndIf
    EndIf
EndFunc   ;==>WM_Notify_Events

Func __Tab_0_Salvar()
    Local $sAviaoNomeOld = $oGame.Item('aviao').Item($AVIAO).Item('nome')
    Local $sAviaoNome = GUICtrlRead($hAviaoNome)
    Local $iAviaoCabide = GUICtrlRead($hAviaoCabide)
    Local $sAviaoImagem = GUICtrlRead($hAviaoImagem)
;~  ConsoleWrite('$sAviaoNome[ ' & $sAviaoNome & ' ]' & $sAviaoNomeOld & @LF)
;~  ConsoleWrite('$iAviaoCabide[ ' & $iAviaoCabide & ' ]' & @LF)
;~  ConsoleWrite('$sAviaoImagem[ ' & $sAviaoImagem & ' ]' & @LF)
    Aviao_Add($sAviaoNome, $iAviaoCabide, $sAviaoImagem)
    _GUICtrlListView_DeleteAllItems($hListView[0])
    Local $item
    For $iAviao In $oGame.Item('aviao')
        $item = _GUICtrlListView_AddItem($hListView[0], $iAviao)
        _GUICtrlListView_AddSubItem($hListView[0], $item, $oGame.Item('aviao').Item($iAviao).Item('nome'), 1, 1)

    Next
EndFunc   ;==>__Tab_0_Salvar

Func __Tab_0_Limpar()
    $AVIAO = -1
    GUICtrlSetData($hAviaoNome, '')
    GUICtrlSetData($hAviaoCabide, 0)
    GUICtrlSetData($hAviaoImagem, '')

EndFunc   ;==>__Tab_0_Limpar
Edited by Detefon

Visit my repository

Link to comment
Share on other sites

Hi Detefon

thanks for your example on the use of the $GUI_EVENT_DROPPED event, $GUI_DROPACCEPTED style and the @GUI_DragId and @GUI_DropId macros to manage the drag&dropping of Listview Items, I appreciate it. :)

But more specifically what I am in search of, (I think that is not clear in my question) is a way to render "graphics" objects or GUI elements "draggable" and a way to automatically (by events) get references to the dragged and to the dropped element (element on which dragged object is fallen).

(simply as an example of concept (nothing to do with AutoIt), here a link to a JavaScript library that enables to do what I'm talking about on a browser)

P.S.
also interesting to see in your listing the use of the Scripting.Dictionary.

bye and thanks again.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Chimp, 

I think I know what you want. And I'm working on exactly that for a while. It is a lonely job, has many trials and errors. But has advanced slowly. It would be something like this?

 
;#AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
;#Tidy_Parameters=/sf
#include-once
#include <Array.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;#include <FredO.au3>
;#include <object_dump.au3>

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("MustDeclareVars", 1)
Opt("WinWaitDelay", 25)

OnAutoItExitRegister("_EXIT_BEFORE")
Global Const $SD = "Scripting.Dictionary"
Global $hGui[3] = [0], $hCursor
Global $hGraphic, $hPen, $hBitmap, $hBackbuffer
Global $hLabel

Global $oDot = ObjCreate($SD)
$oDot.Add("dot", ObjCreate($SD))
$oDot.Add("config", ObjCreate($SD))

Global $aGui[5] = ["Title", 840, 600, -1, -1]
Global $aGraphic[6] = [30, 270, 780, 300]
$aGraphic[4] = $aGraphic[0] + $aGraphic[2]
$aGraphic[5] = $aGraphic[1] + $aGraphic[3]

Global $HOVER = False, $HOVER_OLD = False, $DOT = 0, $DOT_OLD = 0, $PRIMARY = 0, $SECONDARY = 0, $DX = 0, $DY = 0, $DRAG = False

Global $aTest1[4][3] = [ _
        ["id", "nome", "cor"], _
        [1, "Cascão", "amarelo"], _
        [2, "Cebolinha", "verde"], _
        [3, "Mônica", "vermelho"] _
        ]

$hGui[1] = GUICreate($aGui[0], $aGui[1], $aGui[2], $aGui[3], $aGui[4], Default, Default)

GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT")
GUISetState(@SW_SHOWNORMAL, $hGui[1])

$hGui[2] = GUICreate("", $aGraphic[2], $aGraphic[3], $aGraphic[0], $aGraphic[1], $WS_CHILD, Default, $hGui[1])
GUISetBkColor(0xFFFFFF, $hGui[2])
GUISetState(@SW_SHOWNORMAL, $hGui[2])

_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui[2])
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($aGraphic[2], $aGraphic[3], $hGraphic)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

$hPen = _GDIPlus_PenCreate()
_GDIPlus_GraphicsClear($hBackbuffer)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

_DOT_ADD(10, 10, 80, 20)
_DOT_ADD(10, 40, 80, 20)
_DOT_ADD(10, 70, 80, 20)

AdlibRegister("_GDIUpdate", 15)

While Sleep(15)
    $hCursor = GUIGetCursorInfo($hGui[2])
    $DOT = $hCursor[4]

    If $hCursor[4] And Not $HOVER Then
        $HOVER = $hCursor[4]
    ElseIf Not $hCursor[4] And $HOVER Then
        $HOVER = 0
    EndIf

    If $hCursor[2] And $hCursor[4] Then
        $DX = $hCursor[0] - $oDot.Item("dot").Item($DOT).Item("x")
        $DY = $hCursor[1] - $oDot.Item("dot").Item($DOT).Item("y")
        $DRAG = True
        Do
            $hCursor = GUIGetCursorInfo($hGui[2])
            $oDot.Item("dot").Item($DOT).Item("x") = $hCursor[0] - $DX
            $oDot.Item("dot").Item($DOT).Item("y") = $hCursor[1] - $DY
            ControlMove($hGui[2], "", $DOT, $oDot.Item("dot").Item($DOT).Item("x"), $oDot.Item("dot").Item($DOT).Item("y"))
        Until Sleep(10) And Not $hCursor[2]
        $DX = 0
        $DY = 0
        $DRAG = False
    EndIf
WEnd

Func _box($hToGraphic, $xx, $yy, $ll, $aa, $color = 0xFF000000)
    ; _box2
    Local $aBox[5][2]
    $aBox[0][0] = 4
    $aBox[1][0] = $xx
    $aBox[1][1] = $yy
    $aBox[2][0] = $xx + $ll - 1
    $aBox[2][1] = $yy
    $aBox[3][0] = $xx + $ll - 1
    $aBox[3][1] = $yy + $aa - 1
    $aBox[4][0] = $xx
    $aBox[4][1] = $yy + $aa - 1
    If $color Then
        _GDIPlus_PenSetColor($hPen, $color)
        _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox, $hPen)
    Else
        _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox)
    EndIf
EndFunc   ;==>_box

Func _DRAW_DOT()
    For $each In $oDot.Item("dot")
        _box($hBackbuffer, $oDot.Item("dot").Item($each).Item("x"), $oDot.Item("dot").Item($each).Item("y"), $oDot.Item("dot").Item($each).Item("l"), $oDot.Item("dot").Item($each).Item("a"), ($each == $DOT ? ($DRAG ? 0xFFFF0000 : 0xFF00FF00) : 0xff0000FF))
    Next
EndFunc   ;==>_DRAW_DOT

Func _EXIT()
    Exit
EndFunc   ;==>_EXIT

Func _EXIT_BEFORE($sInput = 0)
    AdlibUnRegister("_GDIUpdate")
    If IsDeclared("sInput") Then ConsoleWrite("_exit[ " & $sInput & " ]" & @LF)

    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
;   IniWrite("file.ini", "FredO", "object", code($oDot))

    GUIDelete($hGui[2])
    GUIDelete($hGui[1])
EndFunc   ;==>_EXIT_BEFORE


Func _GDIUpdate()
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF)
    _DRAW_DOT()
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $aGraphic[2], $aGraphic[3])
EndFunc   ;==>_GDIUpdate

Func _DOT_ADD($xx, $yy, $ll, $aa)
    Local $oo = ObjCreate($SD), $hLabel
    $hLabel = GUICtrlCreateLabel("", $xx, $yy, $ll, $aa)
    $oo.Add("x", $xx)
    $oo.Add("y", $yy)
    $oo.Add("l", $ll)
    $oo.Add("a", $aa)
    $oo.Add("h", $hLabel)
    $oDot.Item("dot").Add($hLabel, $oo)
    GUICtrlSetBkColor($hLabel, $GUI_BKCOLOR_TRANSPARENT)
EndFunc   ;==>_DOT_ADD
Scripting.Dictionary became something fundamental for me. I can not work anymore with AutoIt without
Array can even be faster, I'm not sure. 
 
But when I think of an array inside another array within another array ... I want to run away! I can't understand, is hard to manipulate... (at least for me).
 
One day I decided to put one S.D inside another S.D, and work! Not very well, but work!
So I put another S.DS.D inside another, inside another S.D, and to test, put more and more... 
 
I saw that he was very much like an associative PHP array or a json object.
 
It was easy to understand, change, delete, save and load (at least for me).
 
For me, it's fantastic.
 
If you want, I do a little tutorial for you?
 
Regards,
 
Detefon
Edited by Detefon

Visit my repository

Link to comment
Share on other sites

Chimp, 

I think I know what you want. And I'm working on exactly that for a while. It is a lonely job, has many trials and errors. But has advanced slowly. It would be something like this?

 

as graphics effect similar to that (dragging pictures instead of squares), ....also it would be better if simpler in the management....

 

Scripting.Dictionary became something fundamental for me. I can not work anymore with AutoIt without

.......

If you want, I do a little tutorial for you?

 

Well, why not? ...any tutorial is always welcome (not only for me I think, but also for anyone that would like to read it)

ok, go ahead with the tutorial....  :graduated:

Thanks.

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...