Fork of https://github.com/BasselTech/usb-barcode-scanner-lib.git
The USB Barcode Scanner Library is a .NET framework library originally developed by BasselTech and this fork by TownSuite in C#. It allows capturing the barcodes scanned by USB barcode scanners in both C# and VB .NET applications.
- Capture barcodes scanned by USB barcode scanners, even when the application window is out of focus.
- Easily integrate barcode scanning functionality into C# and VB .NET applications.
To build the USB Barcode Scanner Library from source, follow these steps:
-
Clone the repository:
git clone https://github.com/TownSuite/TownSuite.BarcodeScanner.git
-
Navigate to the project directory:
cd usb-barcode-scanner-lib
-
Build the project using Visual Studio or the .NET CLI:
-
Using Visual Studio:
- Open the solution file
usb-barcode-scanner-lib.sln
in Visual Studio. - Build the solution (Ctrl+Shift+B).
- Open the solution file
-
Using .NET CLI:
dotnet build
-
-
Once built successfully, the library files will be available in the
bin
directory.
using TownSuite.BarcodeScanner;
// Initialize USB barcode scanner
var scanner = new UsbBarcodeScanner();
// Subscribe to BarcodeScanned event
scanner.BarcodeScanned += (sender, args) =>
{
Console.WriteLine($"Scanned barcode: {args.Barcode}");
};
// Start capturing barcode scans
scanner.Start();
Imports TownSuite.BarcodeScanner
' Initialize USB barcode scanner
Dim scanner As New UsbBarcodeScanner()
' Subscribe to BarcodeScanned event
AddHandler scanner.BarcodeScanned, Sub(sender, args)
Console.WriteLine($"Scanned barcode: {args.Barcode}")
End Sub
' Start capturing barcode scans
scanner.Start()
Use the UsbBarcodeScannerRawInput scanner when input from a particular device and only that device is desired.
using TownSuite.BarcodeScanner;
// Initialize USB barcode scanner
var scanner = new UsbBarcodeScannerRawInput(formInstance, "#", "HID#VID_05E0&PID_1200");
// Subscribe to BarcodeScanned event
scanner.BarcodeScanned += (sender, args) =>
{
Console.WriteLine($"Scanned barcode: {args.Barcode}");
};
// Start capturing barcode scans
scanner.Start();
####Example usage in VB .NET:
Imports TownSuite.BarcodeScanner
' Initialize USB barcode scanner
Dim scanner As New UsbBarcodeScannerRawInput(formInstance, "#", "HID#VID_05E0&PID_1200");
' Subscribe to BarcodeScanned event
AddHandler scanner.BarcodeScanned, Sub(sender, args)
Console.WriteLine($"Scanned barcode: {args.Barcode}")
End Sub
' Start capturing barcode scans
scanner.Start()
We welcome contributions from the community! If you'd like to contribute to the USB Barcode Scanner Library, please follow these guidelines:
- Fork the repository.
- Create a new branch:
git checkout -b feature/new-feature
. - Make your changes and commit them:
git commit -am 'Add new feature'
. - Push to the branch:
git push origin feature/new-feature
. - Submit a pull request.
If you encounter any bugs or issues with the USB Barcode Scanner Library, please open an issue on the repository. Include a detailed description of the problem and any relevant information for reproducing it.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.