Jdop Posted July 13, 2007 Share Posted July 13, 2007 (edited) Title pretty much says it. I want to drag the text from a listview , and paste it onto an external app. What would be the basic mechanism for this, I've seen some fairly dense code that does many things and only want this basic functionality. Edited July 13, 2007 by Jdop Link to comment Share on other sites More sharing options...
martin Posted July 14, 2007 Share Posted July 14, 2007 (edited) Title pretty much says it. I want to drag the text from a listview , and paste it onto an external app. What would be the basic mechanism for this, I've seen some fairly dense code that does many things and only want this basic functionality. Here is an example of one way to do it. expandcollapse popup#include <GUIConstants.au3> #include <guilistview.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Choices Dialog", 353, 256, 303, 219) GUISetIcon("D:07.ico") $Edit1 = GUICtrlCreateEdit("", 160, 32, 185, 89) GUICtrlSetData(-1, "Edit1") $LV = GUICtrlCreateListView("title", 8, 24, 130, 150) GUICtrlSendMsg(-1, 0x101E, 0, 100) $ListView1_0 = GUICtrlCreateListViewItem("aaaaaaaaaa", $LV) $ListView1_1 = GUICtrlCreateListViewItem("bbbbbbbbbbbb", $LV) $ListView1_2 = GUICtrlCreateListViewItem("cccccccccccc", $LV) $ListView1_3 = GUICtrlCreateListViewItem("dddddddddd", $LV) $ListView1_4 = GUICtrlCreateListViewItem("eeeeeeeeeeeeee", $LV) $ListView1_5 = GUICtrlCreateListViewItem("ffffffffffffff", $LV) $ListView1_6 = GUICtrlCreateListViewItem("gggggggggggggg", $LV) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $text = "" $Dragging = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN ;get info on control the mouse is over $Info = GUIGetCursorInfo (WinGetHandle($Form1)) If $Info[4] = $LV Then ;if over the Listview gettext() ;get the text of the selected item $dragging = True ;and assume we are dragging Else ;not over the listview $Dragging = False $text = '' EndIf Case $GUI_EVENT_PRIMARYUP If $dragging And $text <> "" Then $Info = GUIGetCursorInfo (WinGetHandle($Form1)) If $Info[4] <> $LV Then MouseClick("LEFT") Send($text & "{ENTER}") EndIf EndIf $dragging = False $text = '' EndSwitch WEnd Func gettext() Local $itemIndex = _GUICtrlListViewGetCurSel ($LV) $text = _GUICtrlListViewGetItemText($LV, $itemIndex,0) EndFunc Edited July 14, 2007 by martin 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 More sharing options...
MrCreatoR Posted July 14, 2007 Share Posted July 14, 2007 Wow, nice solution martin ...This is how it would be much faster and safer (if the text is contain not latinic symbols):expandcollapse popup#include <GUIConstants.au3> #include <guilistview.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Choices Dialog", 353, 256, 303, 219) GUISetIcon("D:07.ico") $Edit1 = GUICtrlCreateEdit("", 160, 32, 185, 89) GUICtrlSetData(-1, "Edit1") $LV = GUICtrlCreateListView("title", 8, 24, 130, 150) GUICtrlSendMsg(-1, 0x101E, 0, 100) $ListView1_0 = GUICtrlCreateListViewItem("текст кириллицы", $LV) $ListView1_1 = GUICtrlCreateListViewItem("bbbbbbbbbbbb", $LV) $ListView1_2 = GUICtrlCreateListViewItem("тест", $LV) $ListView1_3 = GUICtrlCreateListViewItem("dddddddddd", $LV) $ListView1_4 = GUICtrlCreateListViewItem("eeeeeeeeeeeeee", $LV) $ListView1_5 = GUICtrlCreateListViewItem("ffffffffffffff", $LV) $ListView1_6 = GUICtrlCreateListViewItem("gggggggggggggg", $LV) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $text = "" $Dragging = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN ;get info on control the mouse is over $Info = GUIGetCursorInfo (WinGetHandle($Form1)) If $Info[4] = $LV Then ;if over the Listview gettext() ;get the text of the selected item $dragging = True ;and assume we are dragging Else ;not over the listview $Dragging = False $text = '' EndIf Case $GUI_EVENT_PRIMARYUP If $dragging And $text <> "" Then $Info = GUIGetCursorInfo (WinGetHandle($Form1)) If $Info[4] <> $LV Then MouseClick("LEFT") $OldClip = ClipGet() ClipPut($text) Send("+{Insert}") ClipPut($OldClip) EndIf EndIf $dragging = False $text = '' EndSwitch WEnd Func gettext() Local $itemIndex = _GUICtrlListViewGetCurSel ($LV) $text = _GUICtrlListViewGetItemText($LV, $itemIndex,0) EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: 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 ProgramUDFs: 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 Examples: 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 ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
martin Posted July 14, 2007 Share Posted July 14, 2007 Wow, nice solution martin This is how it would be much faster and safer (if the text is contain not latinic symbols):Thanks MsCreator.Good improvement, I've made a copy for my reference. Interesting you've used Shift Insert. I always use Ctrl V in Windows and I have always used Shift Insert for DOS programs, so I wondered if that's how you came to use it. But I see from your profile that it is unlikely. 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 More sharing options...
Jdop Posted July 15, 2007 Author Share Posted July 15, 2007 Looks good! A few mods for my app and seems to be working as intended. Thanks! Link to comment Share on other sites More sharing options...
MrCreatoR Posted July 29, 2007 Share Posted July 29, 2007 (edited) Here is mutch more easyer way:expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> $Form1 = GUICreate("Choices Dialog", 353, 256, 303, 219) $Edit1 = GUICtrlCreateEdit("", 160, 32, 185, 89) GUICtrlSetData(-1, "Edit1") $LV = GUICtrlCreateListView("Column", 8, 24, 130, 150, $LVS_SHOWSELALWAYS) $ListView1_0 = GUICtrlCreateListViewItem("текст кириллицы", $LV) $ListView1_1 = GUICtrlCreateListViewItem("bbbbbbbbbbbb", $LV) $ListView1_2 = GUICtrlCreateListViewItem("тест", $LV) $ListView1_3 = GUICtrlCreateListViewItem("dddddddddd", $LV) $ListView1_4 = GUICtrlCreateListViewItem("eeeeeeeeeeeeee", $LV) $ListView1_5 = GUICtrlCreateListViewItem("ffffffffffffff", $LV) $ListView1_6 = GUICtrlCreateListViewItem("gggggggggggggg", $LV) GUICtrlSendMsg($LV, $LVM_SETCOLUMNWIDTH, 0, -1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN Local $CurInfo = GUIGetCursorInfo($Form1) If IsArray($CurInfo) And $CurInfo[4] = $LV Then Local $SelText = GetSelectedText($LV) While IsArray($CurInfo) And $CurInfo[2] = 1 $CurInfo = GUIGetCursorInfo($Form1) Sleep(10) WEnd If $SelText <> "" And IsArray($CurInfo) And $CurInfo[4] <> $LV Then MouseClick("LEFT") $OldClip = ClipGet() ClipPut($SelText) Send("+{Insert}") ClipPut($OldClip) EndIf EndIf EndSwitch WEnd Func GetSelectedText($ListView) Local $ItemIndexArr = _GUICtrlListViewGetSelectedIndices($ListView, 1) If Not IsArray($ItemIndexArr) Then Return SetError(1, 0, -1) Local $SelText = "", $Ubound = UBound($ItemIndexArr)-1, $CRLF = @CRLF For $i = 1 To $Ubound If $i = $Ubound Then $CRLF = "" $SelText &= _GUICtrlListViewGetItemText($ListView, $ItemIndexArr[$i], 0) & $CRLF Next Return $SelText EndFuncEDIT: Now possible to drag & drop more then one item Edited July 29, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: 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 ProgramUDFs: 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 Examples: 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 ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
MrCreatoR Posted July 29, 2007 Share Posted July 29, 2007 Edited my post, now it's possible to drag & drop more then one item. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: 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 ProgramUDFs: 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 Examples: 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 ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
martin Posted July 29, 2007 Share Posted July 29, 2007 Edited my post, now it's possible to drag & drop more then one item. 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 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