Example Code

Find the Handle of an Open Window and Bring to Front

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview: This VI will find the handle of a specified window name and bring that specific window to the front of the screen.


Description: This VI will find the handle of a specified window name and bring that specific window to the front of the screen.


Requirements: LabVIEW 2012 (or compatible)User32.dll found in /Windows/System32/


Steps to Implement or Execute Code:

1. Launch some application (e.g. Calculator from Windows-Run)
2. Enter Window name in the corresponding control (i.e. Calculator)
2. Run this VI.
3. The Calc window will appear on the top of the display.
4. Write down the handle.


Additional Information or References: 

 

Find the Handle of an Open Window and Bring to Front FP.png

 

Find the Handle of an Open Window and Bring to Front sn.png


**This document has been updated to meet the current required format for the NI Code Exchange.**

 

National Instruments
Applications Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Pie56694
Active Participant
Active Participant
on

This was not working for me if I shifted focus to another application.  According to this KB, an application cannot force a window to the foreground while the user is working with another window.  Check this out if you're having trouble: How do you make your application window frontmost?  It contains an example of attaching the LabVIEW window to the process' thread.  So apparently you can force a window to the foreground if you trick the window into the other application's process...?

GriffinRU
Member
Member
on

NI has a pretty good collection of Windows API calls ( http://zone.ni.com/devzone/cda/epd/p/id/4935 ) for more advanced stuff, microsoft MSDN rules the world in windows

Ofinodeyev
Member
Member
on

Yes - winapi is great. But not for 64 Bit windows...

GriffinRU
Member
Member
on

Whats wrong with 64-bit?