Jump to content

Draggable input control


Recommended Posts

  • Replies 72
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

How can I add a second menu item to the context menu?

I did like this an it gives me an error saying it expected and equal sign but there is one:

$item_delete[$nw] = GUICtrlCreateMenuItem("&Delete", $context_menu[$nw])
$item_test[$nw] = GUICtrlCreateMenuItem("Test", $context_menu[$nw])
Link to comment
Share on other sites

How can I add a second menu item to the context menu?

I did like this an it gives me an error saying it expected and equal sign but there is one:

$item_delete[$nw] = GUICtrlCreateMenuItem("&Delete", $context_menu[$nw])
$item_test[$nw] = GUICtrlCreateMenuItem("Test", $context_menu[$nw])
Have you declared $item_test[50] somewhere?
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.
Link to comment
Share on other sites

martin:

I noticed when deleting the "icons" that when delete a brownish background of the delete icon would show up.

If you want to know what I mean take this code, click on the little man and drag an icon out onto the desktop, then right click and delete. You should see what I mean.

#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)

    $context_menu[$nw] = GUICtrlCreateContextMenu($Input[$nw])
    $item_delete[$nw] = GUICtrlCreateMenuItem("&Delete", $context_menu[$nw])

    GUISetState()

    WinSetOnTop($hInput_GUI, "", 1)

EndFunc ;==>createNextdragIP

How do I solve this? muttley

Link to comment
Share on other sites

martin:

I noticed when deleting the "icons" that when delete a brownish background of the delete icon would show up.

If you want to know what I mean take this code, click on the little man and drag an icon out onto the desktop, then right click and delete. You should see what I mean.

#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)

    $context_menu[$nw] = GUICtrlCreateContextMenu($Input[$nw])
    $item_delete[$nw] = GUICtrlCreateMenuItem("&Delete", $context_menu[$nw])

    GUISetState()

    WinSetOnTop($hInput_GUI, "", 1)

EndFunc;==>createNextdragIP

How do I solve this? muttley

After the line

GUICtrlDelete($Input[$n])

add a new line

GUIDelete($hInput_GUI[$n])

or even use that line instead of the GuiCtrlDelete line.

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.
Link to comment
Share on other sites

How do I solve this?

Replace GUICtrlDelete($Input[$n]) with GUIDelete($hInput_GUI[$n])

Edit: Oh, and you will need to add there $lastdragIP -= 1 also.

Edit2: Oh #2, @martin, i didn't seen your post muttley

Edited by MrCreatoR

 

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

Link to comment
Share on other sites

Replace GUICtrlDelete($Input[$n]) with GUIDelete($hInput_GUI[$n])

Edit: Oh, and you will need to add there $lastdragIP -= 1 also.

Edit2: Oh #2, @martin, i didn't seen your post muttley

The $lastDragIP shouldn't be decremented unless the control deleted was the last one created, otherwise once you delete a control which was not the last one created you won't be able to delete the one which was the last one created.
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.
Link to comment
Share on other sites

The $lastDragIP shouldn't be decremented unless the control deleted was the last one created, otherwise once you delete a control which was not the last one created you won't be able to delete the one which was the last one created.

You are right, but without it when you delete control, next one created will crash if you try to move it... i think to make all these stuff to work there is need to reorganize the whole concept from the begining.

 

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

Link to comment
Share on other sites

i think to make all these stuff to work there is need to reorganize the whole concept from the begining

Like this:

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

Global $ahInput[2][4]

$GUI = GUICreate("Dragable Controls", 300, 300)

$Create_DIP_Button = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 32, 58, 26, 26)

GUISetState()

While 1
    $nMsg = GUIGetMsg(1)
    
    Switch $nMsg[0]
        Case $GUI_Event_Close
            Exit
        Case $Create_DIP_Button
            CreateDragIP()
        Case $ahInput[1][1] To $ahInput[$ahInput[0][0]][1] ;$GUI_EVENT_PRIMARYDOWN
            If $nMsg[0] = 0 Then ContinueLoop
            
            Local $aMouse_Pos = MouseGetPos()
            Local $aCursorInfo = GUIGetCursorInfo($nMsg[1]), $aCurrent_Mouse_Pos, $aInputGUI_Pos
            
            $aInputGUI_Pos = WinGetPos($nMsg[1])
            If Not IsArray($aInputGUI_Pos) Then ContinueLoop
            
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo($nMsg[1])
                $aCurrent_Mouse_Pos = MouseGetPos()
                
                WinMove($nMsg[1], "", _
                    $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                    $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
                
                Sleep(10)
            WEnd
    EndSwitch
    
    For $i = 1 To $ahInput[0][0]
        If $nMsg[0] = $ahInput[$i][3] Then
            DeleteDragIP($nMsg[0])
            ExitLoop
        EndIf
    Next
WEnd

Func CreateDragIP()
    Local $aMainGUI_Pos = WinGetPos($GUI)
    
    $ahInput[0][0] += 1
    ReDim $ahInput[$ahInput[0][0]+1][4]
    
    $ahInput[$ahInput[0][0]][0] = GUICreate("", 26, 26, $aMainGUI_Pos[0] + 65, $aMainGUI_Pos[1] + 60 + 25, _
        $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
    
    $ahInput[$ahInput[0][0]][1] = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 26, 26, -1)
    
    $ahInput[$ahInput[0][0]][2] = GUICtrlCreateContextMenu($ahInput[$ahInput[0][0]][1])
    $ahInput[$ahInput[0][0]][3] = GUICtrlCreateMenuItem("&Delete", $ahInput[$ahInput[0][0]][2])
    
    GUISetState(@SW_SHOW, $ahInput[$ahInput[0][0]][0])
    
    WinSetOnTop($ahInput[$ahInput[0][0]][0], "", 1)
EndFunc

Func DeleteDragIP($iCtrlID)
    Local $aTmpArr[2][4]
    
    For $i = 1 To $ahInput[0][0]
        If $ahInput[$i][3] = $iCtrlID Then
            GUIDelete($ahInput[$i][0])
        Else
            $aTmpArr[0][0] += 1
            ReDim $aTmpArr[$aTmpArr[0][0]+1][4]
            
            $aTmpArr[$aTmpArr[0][0]][0] = $ahInput[$i][0]
            $aTmpArr[$aTmpArr[0][0]][1] = $ahInput[$i][1]
            $aTmpArr[$aTmpArr[0][0]][2] = $ahInput[$i][2]
            $aTmpArr[$aTmpArr[0][0]][3] = $ahInput[$i][3]
        EndIf
    Next
    
    $ahInput = $aTmpArr
EndFunc

 

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

Link to comment
Share on other sites

Like this:

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

Global $ahInput[2][4]

$GUI = GUICreate("Dragable Controls", 300, 300)

$Create_DIP_Button = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 32, 58, 26, 26)

GUISetState()

While 1
    $nMsg = GUIGetMsg(1)
    
    Switch $nMsg[0]
        Case $GUI_Event_Close
            Exit
        Case $Create_DIP_Button
            CreateDragIP()
        Case $ahInput[1][1] To $ahInput[$ahInput[0][0]][1] ;$GUI_EVENT_PRIMARYDOWN
            If $nMsg[0] = 0 Then ContinueLoop
            
            Local $aMouse_Pos = MouseGetPos()
            Local $aCursorInfo = GUIGetCursorInfo($nMsg[1]), $aCurrent_Mouse_Pos, $aInputGUI_Pos
            
            $aInputGUI_Pos = WinGetPos($nMsg[1])
            If Not IsArray($aInputGUI_Pos) Then ContinueLoop
            
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo($nMsg[1])
                $aCurrent_Mouse_Pos = MouseGetPos()
                
                WinMove($nMsg[1], "", _
                    $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                    $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
                
                Sleep(10)
            WEnd
    EndSwitch
    
    For $i = 1 To $ahInput[0][0]
        If $nMsg[0] = $ahInput[$i][3] Then
            DeleteDragIP($nMsg[0])
            ExitLoop
        EndIf
    Next
WEnd

Func CreateDragIP()
    Local $aMainGUI_Pos = WinGetPos($GUI)
    
    $ahInput[0][0] += 1
    ReDim $ahInput[$ahInput[0][0]+1][4]
    
    $ahInput[$ahInput[0][0]][0] = GUICreate("", 26, 26, $aMainGUI_Pos[0] + 65, $aMainGUI_Pos[1] + 60 + 25, _
        $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
    
    $ahInput[$ahInput[0][0]][1] = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 26, 26, -1)
    
    $ahInput[$ahInput[0][0]][2] = GUICtrlCreateContextMenu($ahInput[$ahInput[0][0]][1])
    $ahInput[$ahInput[0][0]][3] = GUICtrlCreateMenuItem("&Delete", $ahInput[$ahInput[0][0]][2])
    
    GUISetState(@SW_SHOW, $ahInput[$ahInput[0][0]][0])
    
    WinSetOnTop($ahInput[$ahInput[0][0]][0], "", 1)
EndFunc

Func DeleteDragIP($iCtrlID)
    Local $aTmpArr[2][4]
    
    For $i = 1 To $ahInput[0][0]
        If $ahInput[$i][3] = $iCtrlID Then
            GUIDelete($ahInput[$i][0])
        Else
            $aTmpArr[0][0] += 1
            ReDim $aTmpArr[$aTmpArr[0][0]+1][4]
            
            $aTmpArr[$aTmpArr[0][0]][0] = $ahInput[$i][0]
            $aTmpArr[$aTmpArr[0][0]][1] = $ahInput[$i][1]
            $aTmpArr[$aTmpArr[0][0]][2] = $ahInput[$i][2]
            $aTmpArr[$aTmpArr[0][0]][3] = $ahInput[$i][3]
        EndIf
    Next
    
    $ahInput = $aTmpArr
EndFunc
That looks good. You could also do

Func DeleteDragIP($iCtrlID)
   
    For $i = 1 To $ahInput[0][0] 
        If $ahInput[$i][3] = $iCtrlID Then
            $ahInput[$i][0] = $ahInput[$ahInput[0][0]][0]
            $ahInput[$i][1] = $ahInput[$ahInput[0][0]][1]
            $ahInput[$i][2] = $ahInput[$ahInput[0][0]][2]
            $ahInput[$i][3] = $ahInput[$ahInput[0][0]][3]
          
            ReDim $ahInput[$ahInput[0][0]-1][4]
            $ahInput[0][0] -= 1
            ExitLoop
        EndIf
    Next
EndFunc
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.
Link to comment
Share on other sites

You could also do

Nice, but that way the array elements order is not preserved, not that we need it here, but i like the idea of making things orderly/accurate muttley.

 

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

Link to comment
Share on other sites

Thanks this works really great.

Btw, I noticed in martins example there was some sort of "counting" variable. It was $nw and I would like to know what the counting variable is in MsCreators version because I want to use it to count how many icons are open.

Link to comment
Share on other sites

I'm getting an error on this line:

Case $msg[0] = $ahInput[1][1] To $ahInput[$ahInput[0][0]][1]

says "illegal text at the end of statement (one statement per line). i think its pointing to the word 'To'

Edit: MrCreator: Your way is very complicated and much more complex than martins. I don't even know how to add secondary menu items now. Could you please explain how?

Edited by nowagain
Link to comment
Share on other sites

Case $msg[0] = $ahInput[1][1] To $ahInput[$ahInput[0][0]][1]

Get rid of "$msg[0] ="

Case $ahInput[1][1] To $ahInput[$ahInput[0][0]][1]

It's trying to figure out why you're comparing a variable to a range and borking muttley

Link to comment
Share on other sites

@nowagain

what the counting variable is in MsCreators version

Use $ahInput[0][0] :)

Your way is very complicated and much more complex than martins

But it's more practic and stable.

how to add secondary menu items

Very simple:

What for? what the item will do? You will have to add an element to the second dimention in the array, and asign new item to it... something like this:

....
$ahInput[0][0] += 1
ReDim $ahInput[$ahInput[0][0]+1][5]

....
$ahInput[$ahInput[0][0]][2] = GUICtrlCreateContextMenu($ahInput[$ahInput[0][0]][1])
$ahInput[$ahInput[0][0]][3] = GUICtrlCreateMenuItem("&Delete", $ahInput[$ahInput[0][0]][2])
$ahInput[$ahInput[0][0]][4] = GUICtrlCreateMenuItem("&Exit", $ahInput[$ahInput[0][0]][2])
....

And when you delete items, or check the events, take in a count this new added element.

@JFee

Don't think you can use To in a Case statement....

You don't have to think, check the help file muttley

 

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

Link to comment
Share on other sites

I am using Select, not Switch

In my example you will have to use Switch... and why you are using Select?

 

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

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...