Question SendKeys Crash on Barcode Scanner

kingvb

New member
Joined
Apr 29, 2012
Messages
1
Programming Experience
1-3
Hey I am coding a background service/ exe that reads the input from a com port from a barcode scanner. it reads fine and can be displayed on a textbox with ease. my goal is to have it as an alernative keyboard so to speak. its always on and "types" the input onto an active textbox with focus. as soon as the program executes the line containing sendkeys(ScanText) it crashes with a system.InvalidExecutionException.

I have to test it on another computer because my com port is not working.
I rebuilt it in x86 for my 32 bit test computer.
I downloaded .net framework 4.0 for my test computer since that is the framework it was coded in
i still do not understand why sendkeys is not working

and no i did not program it in vb6 im using visual studio 2009

any ideas on what the problem is or an alternative to sendkeys would be great thanks
 

diegobph

New member
Joined
May 1, 2012
Messages
1
Programming Experience
5-10
Hey I am coding a background service/ exe that reads the input from a com port from a barcode scanner. it reads fine and can be displayed on a textbox with ease. my goal is to have it as an alernative keyboard so to speak. its always on and "types" the input onto an active textbox with focus. as soon as the program executes the line containing sendkeys(ScanText) it crashes with a system.InvalidExecutionException.

I have to test it on another computer because my com port is not working.
I rebuilt it in x86 for my 32 bit test computer.
I downloaded .net framework 4.0 for my test computer since that is the framework it was coded in
i still do not understand why sendkeys is not working

and no i did not program it in vb6 im using visual studio 2009

any ideas on what the problem is or an alternative to sendkeys would be great thanks
I have done this using a combination of the SerialPort class and the keybd_event API.

My app loads at windows startup and minimizes to the system tray and waits for data to arrive on the serial port assigned to it.
If data is read from the serial port, an event is fired which passes the data read from the port to the main form, which then calls the keybd_event API to simulate a keypress to whatever control is in focus.
 
Top Bottom