09-21-2009 08:44 AM
Hello, I've been using the call library function node to paste text to and from the clipboard, and works nicely. Now I'm trying to figure out how to paste a file from the windows file explorer. So if I highlight a file in the Windows file explorer, and hit Ctrl-C, how would I use the library function node spit out a file path? It would be even better if I could highlight a bunch of files, and then paste out an array of file paths, but that can wait. Also, I'm using an MC Listbox, so I can't use the event trigger from drag-drop to a file path control.
Also, I'm using WinXP and LV 7.1.
Thanks,
Pat
Solved! Go to Solution.
09-21-2009 10:46 AM
pwalsh2 wrote:Hello, I've been using the call library function node to paste text to and from the clipboard, and works nicely.
If you were using LV 8.x that would not be necessary - you could use the Application.Clipboard methods.
pwalsh2 wrote:Now I'm trying to figure out how to paste a file from the windows file explorer. So if I highlight a file in the Windows file explorer, and hit Ctrl-C, how would I use the library function node spit out a file path? It would be even better if I could highlight a bunch of files, and then paste out an array of file paths, but that can wait. Also, I'm using an MC Listbox, so I can't use the event trigger from drag-drop to a file path control.
I don't understand why you're trying to use a Windows SDK function for what seems to be a simple Copy operation.
09-21-2009 02:08 PM
Hi, Thanks for the info. Sounds like I should make the switch to a later version of LV.
I will use the copy function for this, but first I have to retrieve info from the clipboard. I want the user to open a windows file explorer, highlight a file, hit Ctrl-C, and then come over to my program, and use a right click menu to paste the file into a MC listbox. So I have to retrieve the clipboard info.
I've been reviewing the msdn stuff here
http://msdn.microsoft.com/en-us/library/ms649039(VS.85).aspx
In experimenting, I've found that wiring a 15 to the input of the user32.dll-GetClipboardData, I get the handle to the clipboard object. Now I just don't know how to convert that to a file path.
Thanks,
Pat
09-21-2009 02:39 PM
09-21-2009 06:18 PM
I can do that too. This is a special case, where the file navigation is difficult, and often times the file explorer window is already open. So the copy-paste would work great. Thanks.
Pat
09-22-2009 01:26 PM
Unfortunately, without delving into the Windows API documentation I don't have a direct answer for you.
You may want to consider an alternative, and that is to do drag and drop for your VI. I know examples of doing this have been posted on this forum.
09-22-2009 03:19 PM - edited 09-22-2009 03:20 PM
UPDATE
I had some time to play around with this, and really out of sheer curiosity on my part I whipped up a simple example to do drag and drop from Explorer into LabVIEW. I wrote the code in 7.1, but I only have 7.1 on a virtual machine, and the DragQueryFiles was not working. I don't know if it was due to the fact that I was running in a virtual machine. I did, however, run the code in 8.2 and it works correctly. In 8.2 I was able to drag a set of files onto the VI's front panel, and the array of string populates with the filenames. I'm including it to see if it might work for you. You will need to get the Windows Message Queue Library. Just place the library into the same folder where you uncompress the attached file.
09-22-2009 04:00 PM
This looks like a great start. Thanks. I just downloaded everything, and I can't get it to work in 7.1, but I see what you're doing. Either I'll be able to make it work, or I'll use this as the reason to upgrade LV. Thanks again.