资源简介
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中的应用
相关资源
- 串口数据转发工具
- gsm模块 stm32 驱动代码
- Visual Basic串口通信与测控应用技术实
- 实验1.zip arduino跑马灯led灯实验,串口
- Visual Basic串口通信工程开发导航.(配
- Visual Basic.NET自动化系统监控.(范逸之
- Visual Basic串口通信与测控应用技术实
- Visual Basic串口通信与测控应用技术实
- 控制台程序使用串口
- labview串口波形显示
- 1602液晶显示51串口接受的数据
- 虚拟串口VSPD的使用方法
- Com2Key 串口模拟键盘口输出
- windows 串口工具
- STM32+DHT11+OLED+RTC+MQ2+NRF24L01+串口12
- SAM-BA 2.9可通过USB、串口将内核直接到
- 用WinIo模拟按键
- 易语言用WinIO模拟按键源码
- 易语言winio模拟键盘源码易语言测试源
- ftdi cdm drivers v2.12.0 官方WHQL版
- FTDI usb转RS232驱动 官方版
- RS485串口调试工具
- 081_《Delphi串口通信编程》(4/4)
- STM32串口输出MPU-9250九轴传感器
- LabView虚拟仪器数据采集与串口通信测
- 测试STC15W408AS单片机串口收发
- 串口通信并快速绘图
- 串口调试助手 Qt5版源码
- STM32 GPIO和定时器 模拟串口
- HC-05嵌入式蓝牙串口通讯模块测试程序
评论
共有 条评论