[VB6]
Dim WithEvents BarScanner As BarcodeScannerLib.Reader
Private Sub Command1_Click()
'Create a new instance of Barcode Scanner object
Set BarScanner = CreateObject("BarcodeScanner.Reader")
BarScanner.Visible = True
End Sub
Private Sub BarScanner_BarcodeIn(ByVal barcode As String)
Text1.Text = barcode
'MsgBox barcode
End Sub
[VB Script (Internet Explorer)]
<html>
<head>
<title>BarCode Scanner test page</title>
</head>
<body>
<object id="BarReader"
classid="clsid:A21F8BEF-B71C-469C-9A5E-64DC45F6EB1B"
type="application/x-oleobject"></object>
Barcode: <span id="barcode"></span>
<SCRIPT LANGUAGE="vbscript">
sub BarReader_BarcodeIn(barText)
Document.getElementById("barcode").innerHTML = barText
'MsgBox "BarcodeIn"
End sub
BarReader.Visible = true
</SCRIPT>
<br>
</body>
</html>
[C#]
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
BarcodeScannerLib.Reader br;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
br = new BarcodeScannerLib.Reader();
br.Visible = true;
BarcodeScannerLib._IReaderEvents_BarcodeInEventHandler bin = new
BarcodeScannerLib._IReaderEvents_BarcodeInEventHandler(OnBarcodeIn);
br.BarcodeIn += bin;
}
static void OnBarcodeIn(String Text)
{
Console.WriteLine("Barcode: {0}", Text);
}
}
}
[Python]
import win32com.client #https://sourceforge.net/projects/pywin32/
import pythoncom
import time
class EvHandler:
def OnBarcodeIn(self, _1):
print(_1);
scanner = win32com.client.DispatchWithEvents("BarcodeScanner.Reader", EvHandler)
scanner.Visible = True
while 1:
pythoncom.PumpWaitingMessages()
time.sleep(0.8) # Don't use up all our CPU checking constantly
See on YouTube