Showing results for 
Search instead for 
Did you mean: 

Bringing the application to the front to receive keyboard input

Go to solution

Hi all, 

So I'm aware that similar topics have been discussed before, but my question is slightly different. 

What my application is supposed to do - Receive keyboard inputs (from a bar code reader) and take appropriate action. The PC that runs the application will not be accessible to the end user. Only the bar code will be accessible. User doesn't see the UI/PC. Therefore my application needs to stay on top of any other window that may pop-up and keep the "focus" on itself so the bar code input can be read at all times. So what I do in the main code is, every three seconds I call the case that takes care of bringing the UI to the front. 


But I'm having trouble with keeping the UI window on top of all other windows and keeping it's focus. 

I took the Windows user32.dll approach as you'd guess since this needs to be controlled via Windows itself.

I have attached a test vi taken out of my main code. Below is a snippet 




I tried few different dll calls inside the user32 but was not able to achieve what I wanted. 

Would appreciate any feedback. 







0 Kudos
Message 1 of 9

I've got some routines where BarCode readers are used to read bar and QR codes that fill string indicators.  The Bar Code is connected to a serial port and read using VISA functions, simply putting the string into the string indicator (using a wire).  Why are you emulating a keyboard instead of a VISA port?


Bob Schor

Message 2 of 9

Thanks for the reply Bob. 

Unfortunately, my bar code reader is not letting me configure it to be used in a COM port.

0 Kudos
Message 3 of 9

Most barcode readers are connected to the computer through USB anyhow nowadays. And if you didn’t get one of those super cheap noname readers they should have an option to be switched to virtual comm mode which installs them in the OS as a serial port rather than a keyboard device. If your device doesn’t have that option someone clearly didn’t do his job when specifying the application requirements and what hardware to use for that. You could buy a new scanner which costs less than 100 bucks or keep burning hours to try to solve a problem with duct tape, lots of black coffee and fallen out hairs only to see it fall apart as soon as Windows decides to phone home and install a security patch.

How to force a window on top of all other applications used to be a trivial task in Windows 95/98, got slightly trickier with Windows NT/2000 and again trickier in Windows 7 and then 10. After all you do not want an application to force itself in front of your banking software and in that way fake people into entering their credentials in the wrong place.

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
0 Kudos
Message 4 of 9

I agree with Rolfk.  You have provided no information on this "bar code reader", but if it truly "forces" itself to take over the keyboard input, forcing you to have to work at the operating system level in order to get your data into LabVIEW, unless there is a compelling Business Reason (like you have a Widget 2000X5 that uses a Bar Code Reader instead of a Keyboard and you have to use it because it is the controller of your Factory), I'd say "find a USB-compliant Bar Code Reader" and use VISA.


Just what is your Bar Code Reader, anyway?  I'm very curious about the hardware that is forcing you in this direction (it would be something to avoid ...).


Bob Schor

0 Kudos
Message 5 of 9


I agree with both of doubt. And I'm still trying to make it via VCM rather than Windows dlls.

Barcode reader I have is Newland NLS-FM30. The user manual says it supports emulated COM port, but every options they have provided has not worked so far to change it from HID to VCM. I have contacted their tech support already and awaiting an response. 


0 Kudos
Message 6 of 9

Your device seems to support VCP mode over USB according to the manual I can find online (USB COM port emulation command on page 47) but it also bas a 10 pin modular connector on which the USB and RS-232 signals are routed out seperately. So you may try to get a physical COM port on your computer and a data cable from your 10 pin RJ-50 connector to your RS-232 port.

Then use the barcodes in the manual to configure baudrate and other serial port parameters to match the settings you use when initializing the VISA resource in your program.


What device do you see in the Windows device manager after you set your device to Virtual COM port emulation and AFTERWARDS power cycle it and connect it to the computer?  

I definitly would disconnect the device to reconfigure its USB mode and then power cycle it before reconnecting it to the computer!

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
Message 7 of 9
Accepted by topic author id911

Rolf, thanks for spending time on looking into this..


Okay, so I've managed resolve my issue. Here's a breakdown - 

1. I took the COM port approach rather than trying to keep the window focus. 

2. I had few issues configuring the device due to Manufacture's information mismatch(this device isn't one of their newest products, probably that's the reason). I'll explain below the steps I took in case someone else run into the same issue as me. 


Only on the Newland North America page you will find the correct datasheet. Link below -


In this document, programming bar codes are there to configure the device to work on a VCM. 

Then download and install the UFCOM drivers from the link below -


EasySet software tool doesn't seem to work with this model.


Then you will see the device appearing on a COM port with the name "Newland NLDC....."


Once that's done you can talk to the device via VISA with no issue. 


I have attached User manual and drivers here. 

I'll leave this post open in case someone wants to comment on "window focus" issue.



Message 8 of 9

Congratulations!  I recommend you mark your last Post as the Solution to help the next Forum user who has the same problem!


Bob Schor

0 Kudos
Message 9 of 9