LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect what file or folder was selected in Windows File Dialog

Hi, We have an Vibration Crontroller application that has is no DLL and no ActiveX support. I want to detect when that or any Windows application opnes a Windows "Open File Dialog" box. I'd then like to detect what file or folder was selected. Is that possible with LabVIEW? Thanks.

0 Kudos
Message 1 of 20
(3,137 Views)

If any other application opens a Windows "Open File Dialog" then your LabVIEW application that is running will not have a reference for that.  That kind of operation might also attract the attention of a anti-virus software.  I'm not sure if it is entirely impossible, but seems improbable to me.

 

Could you give more details as to what it is your are trying to accomplish?  For instance, if Microsfot Word opens a file dialog and the user selects a file or files in that dialog, what bennefit is that to you and your LabVIEW application?  If the LabVIEW application requires files to be pointed to, can this be done with a standard file browser control from within LabVIEW?

 

To take my example in Microsoft Word a step further, a lot of applications (like Word) have VBA or some other scripting support.  If there is a particular application you have in mind that you are interested in the output of its file dialog box, then there may be a way to get the application to send the file name and path data to your LabVIEW application.  Setting up your LabVIEW application to listen and watch what all other applications are doing seems like a security issue to me.

0 Kudos
Message 2 of 20
(3,115 Views)

I'm with Nickerbocker on this - not sure if impossible, but seems improbable.  The only thing I could find is this handy API to help determine the names of all the currently open windows by calling into the Windows API.  However, I tried to see if it could detect the Open File Dialog with Microsoft Word, but it can't and the dialog was essentially "invisible" to this API.  Maybe other programs are different, but that's highly unlikely.  

 

Windows API Function Utilities (32-bit) for LabVIEW

http://sine.ni.com/devzone/cda/epd/p/id/4935

 

If I find anything else I'll post back, but hopefully this helps in some roundabout way.

Message 3 of 20
(3,097 Views)

Event driven:

For one target, you have to create a dll, inject into the target process.  Just like a virus.

For all targets, replace the Windows function (OpenFileDialog), with yours.  Google for hook Windows API.

You will have to use C/C++ to do this.

 

Poll:

use Windows API FindWindow.  Use Call Library Function node in LabVIEW.

From the window handle, you can get its process id.  So you can determind if the window belong to the target.

 

George Zou
0 Kudos
Message 4 of 20
(3,083 Views)

Alternatively, disable the open function from the application.

Build a LabVIEW GUI, force user to open from your GUI instead.

Then send the message to the application.

 

 

 

George Zou
0 Kudos
Message 5 of 20
(3,076 Views)

You can find the last file using the following method, the constitution of MRUListEx in registry is not documented (not that I could find anyway) so you will need to use discretion. Also you will need to figure out a way to detect the change event.

find.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 6 of 20
(3,066 Views)

Thanks aCe,

 

I think I'll try that. Can you further explain the "shell32.dll:SHGetPathFromIDList"? The Numeric Array and the String? I'm not sure how to configure those parameters.

 

Thank You

0 Kudos
Message 7 of 20
(3,058 Views)

That routine decodes the binary data from registry to file path.

http://msdn.microsoft.com/en-gb/library/windows/desktop/bb762194(v=vs.85).aspx

 

Basically, the first byte of MRUListEx listing in registry is the index of last accessed file in the file list in the sub key. If you open up your registry and navigate to the key, you will figure it out.

 

Also you can drag and drop snippets on to your block diagram, if that doesnt work, save the png file to your computer and then drag and drop.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 8 of 20
(3,050 Views)

Hello again aCe,

 

I get error -603 "Specified key or value does not exist" after Open Registry Key.vi.

 

Here is what I have in the String Constant:

 

Software\Microsoft\
Windows\CurrentVersion\
Explorer\ComDlg32\
OpenSavePidlMRU\

 

For File Ext without period (*) I have "DAT". (no quotes)

The file extension in question is DAT.

0 Kudos
Message 9 of 20
(3,042 Views)

What happens if you try * or jpg in the extension field?

 

I suspect you are having trouble becuase dat extension may not be assigned to a program and hence there is no entry in the registry.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 10 of 20
(3,039 Views)