Sign in to follow this  
Followers 0
AustrianOak

Draggable input control

73 posts in this topic

#1 ·  Posted (edited)

How do i make a draggable input control. where i can click anywhere on it to drag it?

would it be best to put a transparent label over it?

Edited by IWantIt

Share this post


Link to post
Share on other sites



How do i make a draggable input control. where i can click anywhere on it to drag it?

would it be best to put a transparent label over it?

Like this perhaps

#include <GuiConstants.au3>
#include <misc.au3>

$gui = GUICreate("drag input")
$ip = GUICtrlCreateInput("drag me", 20, 20, 120, 22)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $nc = GUIGetCursorInfo()
            If $nc[4] = $ip Then
                $mp = MouseGetPos()
                $cp = ControlGetPos("drag input", "", $ip)
                While _IsPressed(1)
                    $nm = MouseGetPos()
                    ControlMove("drag input", "", $ip, $cp[0] - $mp[0] + $nm[0], $cp[1] - $mp[1] + $nm[1])
                WEnd
                
            EndIf
    EndSwitch
    
    
WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

This way, you can't move it out of the window:

#include <GuiConstants.au3>
#include <misc.au3>

$gui = GUICreate("drag input")
$ip = GUICtrlCreateInput("drag me", 20, 20, 120, 22)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $nc = GUIGetCursorInfo()
            If $nc[4] = $ip Then
                $mp = MouseGetPos()
                $cp = ControlGetPos("drag input", "", $ip)
                $max = WinGetClientSize($gui)
                While _IsPressed(1)
                    $nm = MouseGetPos()
                    $x = $cp[0] - $mp[0] + $nm[0]
                    $y = $cp[1] - $mp[1] + $nm[1]
                    Select
                        Case $y < 0
                            $y = 0
                        Case $y > $max[1]-$cp[3]
                            $y = $max[1]-$cp[3]
                    EndSelect
                    Select
                        Case $x < 0
                            $x = 0
                        Case $x > $max[0]-$cp[2]
                            $x = $max[0]-$cp[2]
                    EndSelect
                    ControlMove("drag input", "", $ip, $x,$y)
                    Sleep(10)
                WEnd
                
            EndIf
    EndSwitch
    
    
WEnd

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

This way, you can't move it out of the window:

#include <GuiConstants.au3>
#include <misc.au3>

$gui = GUICreate("drag input")
$ip = GUICtrlCreateInput("drag me", 20, 20, 120, 22)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $nc = GUIGetCursorInfo()
            If $nc[4] = $ip Then
                $mp = MouseGetPos()
                $cp = ControlGetPos("drag input", "", $ip)
                $max = WinGetClientSize($gui)
                While _IsPressed(1)
                    $nm = MouseGetPos()
                    $x = $cp[0] - $mp[0] + $nm[0]
                    $y = $cp[1] - $mp[1] + $nm[1]
                    Select
                        Case $y < 0
                            $y = 0
                        Case $y > $max[1]-$cp[3]
                            $y = $max[1]-$cp[3]
                    EndSelect
                    Select
                        Case $x < 0
                            $x = 0
                        Case $x > $max[0]-$cp[2]
                            $x = $max[0]-$cp[2]
                    EndSelect
                    ControlMove("drag input", "", $ip, $x,$y)
                    Sleep(10)
                WEnd
                
            EndIf
    EndSwitch
    
    
WEnd
Yes, that's better.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thank you both of you for the examples.

Is there someway I can drag it "out" of the window wherever I want and place it on my desktop?

Share this post


Link to post
Share on other sites

Thank you both of you for the examples.

Is there someway I can drag it "out" of the window wherever I want and place it on my desktop?

That would require some work.

Share this post


Link to post
Share on other sites

Really? I'm not asking someone to do it for me, I'm asking for some guidance...a starting point, advice..

Share this post


Link to post
Share on other sites

Really? I'm not asking someone to do it for me, I'm asking for some guidance...a starting point, advice..

Yes I know that, but I'm not even sure how to do it. You might have to make a transparent gui, and then the original gui, and then drag it that way.

Share this post


Link to post
Share on other sites

I'll take that into consideration.

Right now I'm having some trouble with some logic and I need help.

Look at the code below:

#include <guiconstants.au3>
#include <misc.au3>

$gui = GUICreate("", 300, 300)
GUICtrlCreateInput("", 20, 20, 120, 22)
$button = GUICtrlCreateButton("", 200, 20, 40, 40)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit 0
        Case $msg = $button
            $movinginput = GUICtrlCreateInput("", 40, 280, 100, 30)
        Case $GUI_EVENT_PRIMARYDOWN
            $CursorInfo = GUIGetCursorInfo()
            If $CursorInfo[4] = $movinginput Then
                $mousepos = MouseGetPos()
                $cp = ControlGetPos($Gui, "", $movinginput)
                While _IsPressed(1)
                    $nm = MouseGetPos()
                    ControlMove($Gui, "", $movinginput, $cp[0] - $mousepos[0] + $nm[0], $cp[1] - $mousepos[1] + $nm[1])
                WEnd
                
            EndIf
    EndSelect
WEnd

What if on a button press I want to create the draggable input to drag. It would give me an error on the last Case statement saying $movinginput is undeclared. How can I solve this?

I want to type whatever into the first input and it will make another input to drag around.

Share this post


Link to post
Share on other sites

Is there another way I should place the data?

Share this post


Link to post
Share on other sites

Is there another way I should place the data?

Here is an example of a way to move the input anywhere. It needs more logic to make the input move with the main window if that's needed, which I would do with GuiRegisterMsg($WM_MOVE,"My_WM_MOVE")

#include <guiconstants.au3>
#include <misc.au3>
#include <windowsconstants.au3>

$gui = GUICreate("", 300, 300, 400, 400)

$button = GUICtrlCreateButton("", 200, 20, 40, 40)
GUISetState()
$Gc = GUICreate("move anywhere", 120, 22, 420, 460, $WS_POPUP)
$movinginput = GUICtrlCreateInput("", 0, 0, 120, 22)
GUISetState()
WinSetOnTop($Gc, "", 1)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit 0
        Case $GUI_EVENT_PRIMARYDOWN
            $CursorInfo = GUIGetCursorInfo()
            If IsArray($CursorInfo) Then
                If $CursorInfo[4] = $movinginput Then
                    $mousepos = MouseGetPos()
                    $cp = WinGetPos($Gc);ControlGetPos($Gui, "", $movinginput)
                    While _IsPressed(1)
                        $nm = MouseGetPos()
                        WinMove($Gc, "", $cp[0] - $mousepos[0] + $nm[0], $cp[1] - $mousepos[1] + $nm[1])
                    WEnd
                EndIf
            EndIf
    EndSelect
WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thank you martin!

As far as my previous question I no longer need an answer. Your example has given me and explained to me everything I need.

Much thanks.

Share this post


Link to post
Share on other sites

Very nice solution martin!

Here is the same without using _IsPressed()...

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Move Input Anywhere Example", 300, 300)

GUISetState()

$hInput_GUI = GUICreate("", 120, 22, 380, 260, $WS_POPUP)
$Input = GUICtrlCreateInput("Move me :)", 0, 0, 120, 22)
GUISetState()

WinSetOnTop($hInput_GUI, "", 1)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $aCursorInfo = GUIGetCursorInfo()
            $aMouse_Pos = MouseGetPos()
            $aInputGUI_Pos = WinGetPos($hInput_GUI)
            
            If Not IsArray($aCursorInfo) Or $aCursorInfo[4] <> $Input Then ContinueLoop
            
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo()
                $aCurrent_Mouse_Pos = MouseGetPos()
                
                WinMove($hInput_GUI, "", _
                    $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                    $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
            WEnd
    EndSwitch
WEnd

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Very nice solution martin!

Here is the same without using _IsPressed()...

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Move Input Anywhere Example", 300, 300)

GUISetState()

$hInput_GUI = GUICreate("", 120, 22, 380, 260, $WS_POPUP)
$Input = GUICtrlCreateInput("Move me :)", 0, 0, 120, 22)
GUISetState()

WinSetOnTop($hInput_GUI, "", 1)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $aCursorInfo = GUIGetCursorInfo()
            $aMouse_Pos = MouseGetPos()
            $aInputGUI_Pos = WinGetPos($hInput_GUI)
            
            If Not IsArray($aCursorInfo) Or $aCursorInfo[4] <> $Input Then ContinueLoop
            
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo()
                $aCurrent_Mouse_Pos = MouseGetPos()
                
                WinMove($hInput_GUI, "", _
                    $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                    $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
            WEnd
    EndSwitch
WEnd
Yes MrCreatoR, you're right. Better to use the information that is already in the array rather than another function and another include. Thanks.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

@martin:

I understand your logic and how you got the input to be draggable outside the window but I have been working on creating the draggable input from pressing a button for a while and have had no success.

Can someone help me with the logic?

Share this post


Link to post
Share on other sites

Is it possible to create this draggable input from pressing a button first?

Should I Dim the variables that aren't yet created.

I need some help...

Share this post


Link to post
Share on other sites

@martin:

I understand your logic and how you got the input to be draggable outside the window but I have been working on creating the draggable input from pressing a button for a while and have had no success.

Can someone help me with the logic?

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Move Input Anywhere Example", 300, 300)
$btn = GUICtrlCreateButton("make draggable input", 10, 10, 150, 22)
Dim $hInput_GUI[10], $Input[10];need extra logic if more than 10 created
GUISetState()

Global $lastdragIP = -1

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            If $lastdragIP < 9 Then
                $lastdragIP += 1
                createNextdragIP($lastdragIP)
            EndIf
            
        Case $GUI_EVENT_PRIMARYDOWN
            
            $aMouse_Pos = MouseGetPos()
            $sel = -1
            For $n = 0 To $lastdragIP
                GUISwitch($hInput_GUI[$n])
                $aCursorInfo = GUIGetCursorInfo()
                
                If Not IsArray($aCursorInfo) Then ContinueLoop
                If $aCursorInfo[4] = $Input[$n] Then
                    $sel = $n
                    ExitLoop
                EndIf
                
            Next
            If $sel = -1 Then ContinueLoop
            $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel])
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo()
                $aCurrent_Mouse_Pos = MouseGetPos()

                WinMove($hInput_GUI[$sel], "", _
                        $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                        $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
            WEnd
    EndSwitch
WEnd



Func createNextdragIP($nw)
    $start = WinGetPos($hGUI)
    $hInput_GUI[$nw] = GUICreate("", 120, 22, $start[0] + 50, $start[1] + 60 + 25 * $nw, $WS_POPUP)
    $Input[$nw] = GUICtrlCreateInput("Move No. " & $nw + 1, 0, 0, 120, 22)
    GUICtrlSetBkColor(-1,0xffff00)
    GUISetState()

    WinSetOnTop($hInput_GUI, "", 1)
    
EndFunc  ;==>createNextdragIP

You could make a nice PostIt script with this, or maybe that's what you are doing.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

You could make a nice PostIt script with this, or maybe that's what you are doing.

:) muttley Edited by nowagain

Share this post


Link to post
Share on other sites

@martin:

I am having trouble deleting an item using the code below, as you will see, when i will right click on the icon and click delete on the context menu, nothing happens.. Can you help me solve this because I've been working on this for a long time with no success....

muttley

#Include <GUIConstantsEx.au3>
#Include <WindowsConstants.au3>

Dim $hInput_GUI[50], $Input[50]

$Gui = GUICreate("", 300, 300)
$btn = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 32, 58, 26, 26)
GUISetState()

Global $lastdragIP = -1

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_Event_Close
            Exit
        Case $msg = $btn
            If $lastdragIP < 49 Then
                $lastdragIP += 1
                createNextdragIP($lastdragIP)
            EndIf
        Case $GUI_EVENT_PRIMARYDOWN
            
            $aMouse_Pos = MouseGetPos()
            $sel = -1
            For $n = 0 To $lastdragIP
                GUISwitch($hInput_GUI[$n])
                $aCursorInfo = GUIGetCursorInfo()
                
                If Not IsArray($aCursorInfo) Then ContinueLoop
                If $aCursorInfo[4] = $Input[$n] Then
                    $sel = $n
                    ExitLoop
                EndIf
                
            Next
            If $sel = -1 Then ContinueLoop
            $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel])
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo()
                $aCurrent_Mouse_Pos = MouseGetPos()

                WinMove($hInput_GUI[$sel], "", _
                $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
            WEnd
        Case $msg = $item_delete
            GUICtrlDelete($Input[$nw])
    EndSelect
WEnd

Func createNextdragIP($nw)
    $start = WinGetPos($GUI)
    $hInput_GUI[$nw] = GUICreate("", 26, 26, $start[0] + 65, $start[1] + 60 + 25, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW,$WS_EX_LAYERED))
    $Input[$nw] = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 26, 26, -1)
    GUICtrlSetBkColor(-1,0xffff00)
    $context_menu = GUICtrlCreateContextMenu($Input[$nw])
    $item_delete = GUICtrlCreateMenuItem("Delete...", $context_menu)
    GUISetState()

    WinSetOnTop($hInput_GUI, "", 1)
    
EndFunc ;==>createNextdragIP

Share this post


Link to post
Share on other sites

@martin:

I am having trouble deleting an item using the code below, as you will see, when i will right click on the icon and click delete on the context menu, nothing happens.. Can you help me solve this because I've been working on this for a long time with no success....

muttley

#Include <GUIConstantsEx.au3>
#Include <WindowsConstants.au3>

Dim $hInput_GUI[50], $Input[50]

$Gui = GUICreate("", 300, 300)
$btn = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 32, 58, 26, 26)
GUISetState()

Global $lastdragIP = -1

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_Event_Close
            Exit
        Case $msg = $btn
            If $lastdragIP < 49 Then
                $lastdragIP += 1
                createNextdragIP($lastdragIP)
            EndIf
        Case $GUI_EVENT_PRIMARYDOWN
            
            $aMouse_Pos = MouseGetPos()
            $sel = -1
            For $n = 0 To $lastdragIP
                GUISwitch($hInput_GUI[$n])
                $aCursorInfo = GUIGetCursorInfo()
                
                If Not IsArray($aCursorInfo) Then ContinueLoop
                If $aCursorInfo[4] = $Input[$n] Then
                    $sel = $n
                    ExitLoop
                EndIf
                
            Next
            If $sel = -1 Then ContinueLoop
            $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel])
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo()
                $aCurrent_Mouse_Pos = MouseGetPos()

                WinMove($hInput_GUI[$sel], "", _
                $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
            WEnd
        Case $msg = $item_delete
            GUICtrlDelete($Input[$nw])
    EndSelect
WEnd

Func createNextdragIP($nw)
    $start = WinGetPos($GUI)
    $hInput_GUI[$nw] = GUICreate("", 26, 26, $start[0] + 65, $start[1] + 60 + 25, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW,$WS_EX_LAYERED))
    $Input[$nw] = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 26, 26, -1)
    GUICtrlSetBkColor(-1,0xffff00)
    $context_menu = GUICtrlCreateContextMenu($Input[$nw])
    $item_delete = GUICtrlCreateMenuItem("Delete...", $context_menu)
    GUISetState()

    WinSetOnTop($hInput_GUI, "", 1)
    
EndFunc;==>createNextdragIP
Something like this might do it.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Dim $hInput_GUI[50], $Input[50], $context_menu[50], $item_delete[50]

$Gui = GUICreate("", 300, 300)
$btn = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 32, 58, 26, 26)
GUISetState()

Global $lastdragIP = -1

While 1
    $msg = GUIGetMsg(1)

    Select
        Case $msg[0] = $GUI_Event_Close
            Exit
        Case $msg[0] = $btn
            If $lastdragIP < 49 Then
                $lastdragIP += 1
                createNextdragIP($lastdragIP)
            EndIf
        Case $msg[0] = $GUI_EVENT_PRIMARYDOWN

            $aMouse_Pos = MouseGetPos()
            $sel = -1
            For $n = 0 To $lastdragIP
                GUISwitch($hInput_GUI[$n])
                $aCursorInfo = GUIGetCursorInfo()

                If Not IsArray($aCursorInfo) Then ContinueLoop
                If $aCursorInfo[4] = $Input[$n] Then
                    $sel = $n
                    ExitLoop
                EndIf

            Next
            If $sel = -1 Then ContinueLoop
            $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel])
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo()
                $aCurrent_Mouse_Pos = MouseGetPos()

                WinMove($hInput_GUI[$sel], "", _
                        $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                        $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
            WEnd
    EndSelect
    If $lastdragIP >= 0 Then
        Select
            Case $msg[0] >= $item_delete[0] And $msg[0] <= $item_delete[$lastdragIP]
                For $n = 0 To $lastdragIP
                    If $msg[0] = $item_delete[$n] Then
                        GUICtrlDelete($Input[$n])
                    EndIf
                Next
        EndSelect
    EndIf

    
WEnd

Func createNextdragIP($nw)
    $start = WinGetPos($Gui)
    $hInput_GUI[$nw] = GUICreate("", 26, 26, $start[0] + 65, $start[1] + 60 + 25, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
    $Input[$nw] = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 26, 26, -1)
    GUICtrlSetBkColor(-1, 0xffff00)
    $context_menu[$nw] = GUICtrlCreateContextMenu($Input[$nw])
    $item_delete[$nw] = GUICtrlCreateMenuItem("Delete...", $context_menu[$nw])
    ConsoleWrite("nw = " & $nw & @CRLF)
    GUISetState()

    WinSetOnTop($hInput_GUI, "", 1)

EndFunc  ;==>createNextdragIP

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
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
Sign in to follow this  
Followers 0