资源简介
USB条码枪可以应用于任何程序,而串口就必须得为其单独开发,这个软件实现了对串口条码枪结果的转发,模拟按键实现。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace Scanner2Keyborad
{
public partial class Form1 : Form
{
SerialPort sp;
NotifyIcon notifyicon = new NotifyIcon();
ContextMenu notifyContextMenu = new ContextMenu();
MenuItem miShow = new MenuItem(“显示“);
MenuItem miExit = new MenuItem(“退出“);
public Form1()
{
InitializeComponent();
InitUI();
}
private void InitUI()
{
sp = new SerialPort();
//sp.ReceivedBytesThreshold = 1;
notifyicon.Icon = Scanner2Keyborad.Properties.Resources.bitbug_favicon;
notifyicon.DoubleClick += notifyicon_DoubleClick;
miShow.Click += miShow_Click;
miExit.Click += miExit_Click;
notifyContextMenu.MenuItems.Add(miShow);
notifyContextMenu.MenuItems.Add(miExit);
notifyicon.ContextMenu = notifyContextMenu;
cmbPort.Items.AddRange(SerialPort.GetPortNames());
cmbParity.Items.AddRange(Enum.GetNames(typeof(System.IO.Ports.Parity)));
cmbStopBits.Items.AddRange(Enum.GetNames(typeof(System.IO.Ports.StopBits)));
}
void miExit_Click(object sender EventArgs e)
{
this.Close();
}
void miShow_Click(object sender EventArgs e)
{
ShowForm();
}
void notifyicon_DoubleClick(object sender EventArgs e)
{
ShowForm();
}
void ShowForm()
{
if (WindowState == FormWindowState.Minimized)
{
//还原窗体显示
WindowState = FormWindowState.Normal;
//激活窗体并给予它焦点
this.Activate();
//任务栏区显示图标
this.ShowInTaskbar = true;
//托盘区图标隐藏
notifyicon.Visible = false;
}
}
void sp_DataReceived(object sender SerialDataReceivedEventArgs e)
{
byte[] buff=new byte[1024];
int length = sp.BytesToRead;
sp.Read(buff 0 length);
byte[] data = new byte[length];
Array.Copy(buff 0 data 0 length);
Send(data);
}
void Send(byte[] data)
{
for (int i = 0; i < data.Length; i++)
{
if (data[i] == 13)
{
System.Windows.Forms.SendKeys.SendWait(“{ENTER}“);
}
else if (data[i] >= 32 && data[i] <= 126)
{
System.Windows.Forms.SendKeys.SendWait(ASCIIEncoding.ASCII.GetString(new byte[] { data[i] }));
}
}
if (cbIsEnte
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 31232 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\bin\Debug\Scanner2Keyborad.exe
文件 36352 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\bin\Debug\Scanner2Keyborad.pdb
文件 21464 2013-10-12 13:22 Scanner2Keyborad\Scanner2Keyborad\bin\Debug\Scanner2Keyborad.vshost.exe
文件 340 2013-10-12 13:18 Scanner2Keyborad\Scanner2Keyborad\bin\Debug\system.cfg
文件 6662 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\Form1.cs
文件 10832 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\Form1.Designer.cs
文件 12549 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\Form1.resx
文件 789 2013-10-12 09:00 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6340 2013-10-12 12:47 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 954 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\Scanner2Keyborad.csproj.FileListAbsolute.txt
文件 895 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\Scanner2Keyborad.csproj.GenerateResource.Cache
文件 1339 2013-10-12 09:05 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\Scanner2Keyborad.csprojResolveAssemblyReference.cache
文件 31232 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\Scanner2Keyborad.exe
文件 4852 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\Scanner2Keyborad.Form1.resources
文件 36352 2013-10-12 13:29 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\Scanner2Keyborad.pdb
文件 4860 2013-10-12 12:47 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\Scanner2Keyborad.Properties.Resources.resources
文件 4608 2013-10-12 12:45 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 477 2013-10-12 09:00 Scanner2Keyborad\Scanner2Keyborad\Program.cs
文件 1370 2013-10-12 09:00 Scanner2Keyborad\Scanner2Keyborad\Properties\AssemblyInfo.cs
文件 3272 2013-10-12 12:45 Scanner2Keyborad\Scanner2Keyborad\Properties\Resources.Designer.cs
文件 6213 2013-10-12 12:45 Scanner2Keyborad\Scanner2Keyborad\Properties\Resources.resx
文件 1103 2013-10-12 09:00 Scanner2Keyborad\Scanner2Keyborad\Properties\Settings.Designer.cs
文件 249 2013-10-12 08:59 Scanner2Keyborad\Scanner2Keyborad\Properties\Settings.settings
文件 4286 2013-10-12 12:44 Scanner2Keyborad\Scanner2Keyborad\Resources\bitbug_favicon.ico
文件 4286 2013-10-12 12:43 Scanner2Keyborad\Scanner2Keyborad\scanner.ico
文件 3871 2013-10-12 12:47 Scanner2Keyborad\Scanner2Keyborad\Scanner2Keyborad.csproj
文件 2274 2013-10-12 09:46 Scanner2Keyborad\Scanner2Keyborad\SerializableHelper.cs
文件 938 2013-10-12 09:00 Scanner2Keyborad\Scanner2Keyborad.sln
..A..H. 32768 2013-10-12 11:05 Scanner2Keyborad\Scanner2Keyborad.v11.suo
目录 0 2013-10-12 12:45 Scanner2Keyborad\Scanner2Keyborad\obj\Debug\TempPE
............此处省略12个文件信息
- 上一篇:华为网管交换机模拟器
- 下一篇:二维模型粘弹性人工边界在ansys中的应用
相关资源
- Modbus协议官方文档中、英文全
- 易语言OTG串口通信
- delphi 串口通讯
- STM32蓝牙和串口程序
- LCD显示温度+串口接收温度.rar
- WPF USB 网络 串口 通信软件
- DELPHI与西门子200PLC的串口通信实例
- Verilog FPGA UART串口控制器
- USB转串口驱动,FT232R驱动程序,最新
- PC -- 单片机的串口数据传输系统设计
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- PC 串口调试软件
- 51单片机读取温度数据存储到SD卡中并
- 单片机与PC机串口通讯仿真
- 串口调试助手V5.0
- 双串口调试助手 V4.0 _ 可同时调试两个
- 读取串口数据并画实时曲线的VC 程序
- 网络(UDP)转串口程序
- 串口绘制曲线 将收到的数据进行曲线
- 基于ARM蓝牙传输源程序
- JS操作本地网页串口源码
- AT89S ISP下载编程软件(串口)
- 串口操作类(justinio)
- 《Visual Basic 串口通信与测控应用技术
- 耀华XK3190-A9地磅串口代码
- ch452串口键盘驱动程序
- 托利多电子秤ind245协议读取串口数据
- 通过串口s19文件源代码
- 友善串口调试助手V3.7.3,带注册码
评论
共有 条评论