

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I am using UFT 11.53, testing a custom .NET application in a Windows 7 x64 environment but have run into what seems to be a serious problem - there seems to be no way to test a simple Drag and Drop of a file from Windows File Explorer onto my application.
I have discovered that, running as a regular (limited) user, UFT cannot recognize the objects in the WinList object component of Windows Explorer. So it is impossible to, for instance, do a .Select operation on a particular test file shown in the Explorer window.
If I run as a privileged (Administrator) user, UFT can now see the hierarchy within Windows Explorer down to the WinList object and therefore can select particular files. So far so good, I thought.
But, running as Administrator, my Software Under Test (SUT) is also started (by UFT) with privileges. However, Windows 7 does not allow Drag and Drop from a limited process onto a privileged process such as my SUT.
Unfortunately, it seems that Windows 7 also actively prevents starting Explorer.exe with privileges. It always runs as limited, even when started by a privileged user or process. So, the Explorer (opened also by UFT during the test) cannot be a source for Drag and Drop onto the SUT. Windows 7 prevents it (cursor turns into a black slash-circle over the drop target).
Attempting to run UFT with privileges (to allow file selection) while starting the SUT as limited has so far been problematic; while I can get Drag and Drop to work (with analog recording only, I might add), it causes other problems with UFT and other parts of my test break. The UFT Help suggests as much, saying that UFT and all the test objects should be started by the same user.
Has anyone successfully tested Drag and Drop from Windows File Explorer in a Windows 7 environment? How?
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I developed a solution - where there's a will, there's a way. Perhaps this will be useful to the UFT community.
To allow drag and drop for UFT in Windows 7, you have to change the message filters for the SUT process. I created a library function to do this.
Extern.Declare micInteger, "ChangeWindowMessageFilter", "user32.dll", "ChangeWindowMessageFilter", micUInteger, micDWord
Const WM_DROPFILES = &H0233
Const WM_COPYDATA = &H004A
Const MSGFLT_ADD = 1
Const MSGFLT_REMOVE = 2
'@Description enables drag and drop messages when process is started elevated
Public Function EnableDragNDrop7()
' enables drag and drop messages when process is started elevated
' per http://helgeklein.com/blog/2010/03/how-to-enable-drag-and-drop-for-an-elevated-mfc-application-on-vistawindows-7/
Dim status
status = Extern.ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD)
status = Extern.ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD)
status = Extern.ChangeWindowMessageFilter(&H0049, MSGFLT_ADD)
EnableDragNDrop7 = status
End Function
In the actual test code, it looks like this:
' enable drag-n-drop even if running elevated
If EnableDragNDrop7() Then
Reporter.ReportNote("Drag and Drop successfully enabled for testing")
Print "Drag and Drop successfully enabled for testing"
End If

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello ,
As per my knowledge , QTP/UFT doesn't support drag and drop of objects from different environments ( Like desktop and SUT ) .
Some objects support dra and drop when they are in single SUT. Drag and drop between two applications is not yet supported.
Regards ,
If you haven’t tried it yet, come and join us in our entitled forums at :
HP support Engineers will be available to answer queries.
( Posts and opinions made here are my own and do not reflect the opinions of my employer HPE in any way . )


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I developed a solution - where there's a will, there's a way. Perhaps this will be useful to the UFT community.
To allow drag and drop for UFT in Windows 7, you have to change the message filters for the SUT process. I created a library function to do this.
Extern.Declare micInteger, "ChangeWindowMessageFilter", "user32.dll", "ChangeWindowMessageFilter", micUInteger, micDWord
Const WM_DROPFILES = &H0233
Const WM_COPYDATA = &H004A
Const MSGFLT_ADD = 1
Const MSGFLT_REMOVE = 2
'@Description enables drag and drop messages when process is started elevated
Public Function EnableDragNDrop7()
' enables drag and drop messages when process is started elevated
' per http://helgeklein.com/blog/2010/03/how-to-enable-drag-and-drop-for-an-elevated-mfc-application-on-vistawindows-7/
Dim status
status = Extern.ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD)
status = Extern.ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD)
status = Extern.ChangeWindowMessageFilter(&H0049, MSGFLT_ADD)
EnableDragNDrop7 = status
End Function
In the actual test code, it looks like this:
' enable drag-n-drop even if running elevated
If EnableDragNDrop7() Then
Reporter.ReportNote("Drag and Drop successfully enabled for testing")
Print "Drag and Drop successfully enabled for testing"
End If

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
steps -
1. Ensure your application and window are open in appropriate size.
2. Record analog to select and drag (just a few pixel).
3. Use device replay to move the dragged object to your AUT.
4. Use Device replay to click and drop the object. <get abs_x and abs_y> for accuracy.
This approach is little sensitive but can be used in a controlled environment and can be made smarter to response on environment change.
Example –
Window("tests").RunAnalog "Track1" ‘’ this analog just clicks and drags the object to a few pixels or points.
wait(1)
devRep.MouseMove iXpos +10,iYpos + 10
devRep.MouseClick iXpos +10,iYpos + 10,0
Hope this helps


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thanks for the post. Your suggested techniques are basically what I am using to actually perform the Drag'n'Drop; I used analog recording. However, without changing the permissions for inter-application communication, the analog recording didn't work, because Windows 7 blocked the operation.
Stan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Here is a subroutine as a workaround for the problem.
www.aneejian.com


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thank you! very interesting how you locate the drag item in Windows Explorer. I used analog recording but that is sensitive to any changes in window size or directory contents.