jerome Posted June 13, 2007 Posted June 13, 2007 Hi, I want to be able to drag some text from any other/external application to a gui/program made in autoit. I found a solution with drag & drop of files but it doesn't work with text (drop refused by gui)... Is there a solution for that? Thanks for any help JD
MrBeatnik Posted June 13, 2007 Posted June 13, 2007 I don't actually think Windows allow text to be dragged as an object? It would have to be converted to a scrap first? Not sure how to go about that; it would be a condition of the program displaying the text I think. Please correct me if I am wrong in any of my posts. I like learning from my mistakes too.
jerome Posted June 14, 2007 Author Posted June 14, 2007 I don't actually think Windows allow text to be dragged as an object?It would have to be converted to a scrap first? Not sure how to go about that; it would be a condition of the program displaying the text I think.Yes Windows allows that, you can even drag an URL from IEXPLORER address bar to another application but this kind of things are automatically refused by autoit applications even if drag & drop is activated on window...Please help, really need it... Anyone?ThanksJD
MrCreatoR Posted November 26, 2007 Posted November 26, 2007 Maybe someone came up with a solution for this one? I search the forum, but no results found (only this old topic). 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
Siao Posted November 26, 2007 Posted November 26, 2007 (edited) You have to do it with OLE drag and drop, obviously WM_DROPFILES isn't going to cut it. May look in MSDN on RegisterDragDrop, IDropTarget etc.I don't know jack about COM, so I'm not sure how to implement it, AutoIt or no AutoIt...Some smarter fellows at AutoHotkey have it figured out so you can take that as a starting point. Since now AutoIt supports DllCallback too, I assume that script would be possible to convert. Edited November 26, 2007 by Siao "be smart, drink your wine"
Richard Robertson Posted November 26, 2007 Posted November 26, 2007 There are several types of drops. It can contain a number of data types and each one has to be handled differently. Text can be dropped, along with files, and I think even bitmap data.
ValeryVal Posted November 26, 2007 Posted November 26, 2007 If you need any help...This group http://tech.groups.yahoo.com/group/autoitgroup/has topic Files/Misc and my old script CalendarRTF.au3 (Translated from Gui4Cli into AutoIt - 20 February 2005) in ACalendar_1.zipIt showes how can you use Drag&Drop action with rich text from CalendarRTF.au3 to ie WordPad The point of world view
MrCreatoR Posted November 26, 2007 Posted November 26, 2007 Thanks to all, but i think (after reading tons of stuff about the subject) that it is too hard to do this in Autoit.I found also this tutorial about the implementation of drag and drop, there also demo available (the first link to zip file), but it's for C/C++ Afaik, and i have no idea how to translate it to autoit (and i tried, realy tried), basicaly i don't understand how to manage the IDropTarget .. and maybe some more stuff...If someone can translate it, it will be great. 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
martin Posted November 26, 2007 Posted November 26, 2007 Thanks to all, but i think (after reading tons of stuff about the subject) that it is too hard to do this in Autoit. I found also this tutorial about the implementation of drag and drop, there also demo available (the first link to zip file), but it's for C/C++ Afaik, and i have no idea how to translate it to autoit (and i tried, realy tried), basicaly i don't understand how to manage the IDropTarget .. and maybe some more stuff... If someone can translate it, it will be great. I haven't looked at any of the references you gave, but I tried just detecting the mouse down and got something to work. You have to select the text to be copied by dragging over it with the mouse, then drag it into the edit. It's a start maybe. expandcollapse popup#include <GUIConstants.au3> #include <guilistview.au3> #include <misc.au3> $Title = "Drag Text to" $dragInc = 5;set when we decide dragging has started $Form1 = GUICreate($Title, 353, 256, 303, 219) $Edit1 = GUICtrlCreateEdit("", 60, 32, 250, 89) GUICtrlSetData(-1, "Edit1") Dim $np[2] = [0,0] GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $text = "" $Dragging = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch CheckDrag() WEnd Func CheckDrag() If _IsPressed("1") Then $mp = MouseGetPos() While _IsPressed("1") $np= MouseGetPos() If Abs($np[0] - $mp[0]) > $dragInc Or Abs($np[1] - $mp[1]) > $dragInc Then $dragging = True ExitLoop EndIf WEnd While _IsPressed("1") $np= MouseGetPos() Sleep(20) WEnd $wp = WinGetPos($Title) If $dragging Then If $np[0] > $wp[0] + 60 And $np[1] < ($wp[0] +60 + 250) And $np[0] > ($wp[1] + 32) And $np[1] < ($wp[1] + 32 + 89) Then WinActivate($Title) GUICtrlSetState($Edit1,$GUI_FOCUS) Send("{END}^v") EndIf EndIf $Dragging = False Send("^c") $text = ClipGet() ;ConsoleWrite("Copied this" & @LF & $text & @LF) EndIf 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.
MrCreatoR Posted November 26, 2007 Posted November 26, 2007 (edited) Thanks martin, that is really a good start for a workaround, but to be unest, i am not like the idea that Clipboard is always used, and also the cursor is displayed as restriction (dropping not allowed)... Here is a little improvments in your example (it's not really "fix" the mention issues, but it faster and i think more reliable) expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> Global $Title = "Drag Text to" Global $Dragging = False Global $DragInc = 5 ;set when we decide dragging has started Global $OldClip = ClipGet() $Form1 = GUICreate($Title, 353, 256, 303, 219) $Edit1 = GUICtrlCreateEdit("", 60, 32, 250, 89) GUICtrlSetData(-1, "Edit1") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ClipPut($OldClip) Exit EndSwitch CheckDrag() WEnd Func CheckDrag() If _IsPressed("1") And Not WinActive($Form1) Then Local $MousePos = MouseGetPos() While _IsPressed("1") $MousePosNew = MouseGetPos() If Abs($MousePosNew[0] - $MousePos[0]) > $DragInc Or Abs($MousePosNew[1] - $MousePos[1]) > $DragInc Then $Dragging = True ExitLoop EndIf WEnd While _IsPressed("1") $MousePosNew = MouseGetPos() Sleep(20) WEnd Local $WinPos = WinGetPos($Form1) Send("^{Insert}") If $Dragging Then If _ControlIDGetHovered() = $Edit1 Then MouseClick("Left") Send("+{Insert}") EndIf EndIf $Dragging = False EndIf EndFunc Func _ControlIDGetHovered() Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $iRet = DllCall("user32.dll", "int", "WindowFromPoint", _ "long", MouseGetPos(0), _ "long", MouseGetPos(1)) $iRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $iRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $iRet[0] EndFunc Edited November 26, 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
martin Posted November 26, 2007 Posted November 26, 2007 Thanks martin, that is really a good start for a workaround, but to be unest, i am not like the idea that Clipboard is always used, and also the cursor is displayed as restriction (dropping not allowed)... Here is a little improvments in your example (it's not really "fix" the mention issues, but it faster and i think more reliable) expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> Global $Title = "Drag Text to" Global $Dragging = False Global $DragInc = 5 ;set when we decide dragging has started Global $OldClip = ClipGet() $Form1 = GUICreate($Title, 353, 256, 303, 219) $Edit1 = GUICtrlCreateEdit("", 60, 32, 250, 89) GUICtrlSetData(-1, "Edit1") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ClipPut($OldClip) Exit EndSwitch CheckDrag() WEnd Func CheckDrag() If _IsPressed("1") And Not WinActive($Form1) Then Local $MousePos = MouseGetPos() While _IsPressed("1") $MousePosNew = MouseGetPos() If Abs($MousePosNew[0] - $MousePos[0]) > $DragInc Or Abs($MousePosNew[1] - $MousePos[1]) > $DragInc Then $Dragging = True ExitLoop EndIf WEnd While _IsPressed("1") $MousePosNew = MouseGetPos() Sleep(20) WEnd Local $WinPos = WinGetPos($Form1) Send("^{Insert}") If $Dragging Then If _ControlIDGetHovered() = $Edit1 Then MouseClick("Left") Send("+{Insert}") EndIf EndIf $Dragging = False EndIf EndFunc Func _ControlIDGetHovered() Local $Old_Opt_MCM = Opt("MouseCoordMode", 1) Local $iRet = DllCall("user32.dll", "int", "WindowFromPoint", _ "long", MouseGetPos(0), _ "long", MouseGetPos(1)) $iRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $iRet[0]) Opt("MouseCoordMode", $Old_Opt_MCM) Return $iRet[0] EndFunc Good improvements. But still, it's not a proper solution as you say. I had a look at the link you gave and I decided there are things I'd rather be doing, like the ironing! 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.
Triblade Posted August 7, 2008 Posted August 7, 2008 Well, hoe about creating an extra gui/edit control that hovers under you mouse button? In there is the copied text. Then when the mousebtn is release, destroy the gui and copy the text again in the new field. My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger)
BrettF Posted August 7, 2008 Posted August 7, 2008 Create a new topic if you have a question rather than bumping one more than 6 months old... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Triblade Posted August 7, 2008 Posted August 7, 2008 I don't have a new question... It is a anwser to a old question. It not bumping, just helping people wanting to do something like this and can't find an anwser. This topic is probably burried anyway at the end of the day, so why not trying to help people instead of keep creating more topics... My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger)
argumentum Posted August 11, 2008 Posted August 11, 2008 use a Richedit, it will take the dropped text, make it of an edit control size, thats it, solved =) Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
prazetto Posted April 16, 2013 Posted April 16, 2013 The greatest solution I found are here: # Button. Progressbar - Graphical AutoIt3 Control (UDF) # GTK on AutoIt3 - GTK+ Framework | Widgets cig computer instruction graphics http://code.hstn.me
BrewManNH Posted April 16, 2013 Posted April 16, 2013 Please don't post to 6 year old topics for users that haven't even been here in 2 years. I'm sure he's probably figured it out by this time. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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