Close a Windows Dialog Box Programmatically from LabVIEW

Updated Dec 29, 2017

Reported In

Programming Language

  • LabVIEW G

Issue Details

My application causes a Windows dialog box or user prompt to appear, for example to prompt the user for a file path. However, since I don't need to insert any parameter but simply have to confirm and close the dialog box by pressing the proper button (i.e., OK or Save buttons), I would like the window to be automatically closed confirming the existing settings, not having to press the OK button every time.
How can I obtain this desired behavior?

Solution

If the button that you need to press in the dialog box has focus, you can also close the window by pressing the Enter key. Thus, if you simulate the pressing of the Enter key, the dialog box will be automatically closed. It is possible to generate a key stroke programmatically by using the Windows keybd_event function in the user32.dll. You can find examples in Community Example: Programmatically Simulate Key Strokes in LabVIEW.

However, common Windows dialog boxes or user prompts (like most LabVIEW dialog boxes) are modal, thus they will halt execution of the current application while waiting for user input. To be able to simulate the pressing of the Enter key while the dialog box is opened, you have to make LabVIEW application window to always be on top. To achieve this follow the instructions on the How Do I Configure My LabVIEW Application Window to Always Be on Top? page.

WAS THIS ARTICLE HELPFUL?

Not Helpful