1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
|
相关推荐
1个回答
|
|
找一个家里闲置的遥控器。
上某宝买一块“红外解码模块”。 再买一个带线的“USB转TTL USB转串口下载线CH340G模块”。 像我这样,把线接到一起。 找个好看的塑料外壳。 把这些都装里面,PC电脑遥控器的接收设备就做好了。 把这个设备插上电脑,安装USB串口线的驱动, 可以看到我的电脑识别出串口 com 6 。 打开串口测试软件,像我这样设置。 按下遥控器上的按钮,就可以直接看到接收到的遥控器数据了。 然后用你熟悉的PC桌面版本的编程语言,写一个串口接收程序来控制电脑就可以了。 我用的是Qt,串口接收到的数据,对应上你要模拟的遥控器上的按键就可以了。 模拟键盘上键,模拟键盘下键, 模拟音量大小按键。 根据自己的遥控器按键编码,修改如下程序即可。 if(receive_data)//向上Key_Up 00ff96 { //on_key_Up(); keybd_event(38,0,0,0); keybd_event(38,0,KEYEVENTF_KEYUP,0); } if(receive_data)//向下 00ff92 { keybd_event(40,0,0,0); keybd_event(40,0,KEYEVENTF_KEYUP,0); } if(receive_data)//向左 00ff97 { keybd_event(37,0,0,0); keybd_event(37,0,KEYEVENTF_KEYUP,0); } if(receive_data)//向右 00ff8c { keybd_event(39,0,0,0); keybd_event(39,0,KEYEVENTF_KEYUP,0); } if(receive_data)//ok { keybd_event(32,0,0,0);//空格 keybd_event(32,0,KEYEVENTF_KEYUP,0); } if(receive_data)//全屏 ctrl+回车 { keybd_event(17,0,0,0); keybd_event(13,0,0,0);//回车 keybd_event(13,0,KEYEVENTF_KEYUP,0); keybd_event(17,0,KEYEVENTF_KEYUP,0); } if(receive_data)//开始 { keybd_event(13,0,0,0); keybd_event(13,0,KEYEVENTF_KEYUP,0); } if(receive_data)//ESC { keybd_event(27,0,0,0); keybd_event(27,0,KEYEVENTF_KEYUP,0); } if(receive_data)//关机 { system("shutdown -s -t 00"); } if(receive_data)//win + D { keybd_event(91,0,0,0); keybd_event(68,0,0,0); keybd_event(68,0,KEYEVENTF_KEYUP,0); keybd_event(91,0,KEYEVENTF_KEYUP,0); } if(receive_data)//菜单 { keybd_event(164,0,0,0); keybd_event(164,0,KEYEVENTF_KEYUP,0); } if(receive_data)//鼠标左键 { mouse_event (MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); } if(receive_data)//鼠标右键 { mouse_event (MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 ); } if(receive_data)//w { keybd_event(87,0,0,0); keybd_event(87,0,KEYEVENTF_KEYUP,0); } if(receive_data)//e { keybd_event(69,0,0,0); keybd_event(69,0,KEYEVENTF_KEYUP,0); } if(receive_data)//q { keybd_event(81,0,0,0); keybd_event(81,0,KEYEVENTF_KEYUP,0); } if(receive_data)//音量静音键 { keybd_event(173,0,0,0); keybd_event(173,0,KEYEVENTF_KEYUP,0); } if(receive_data)//音量增加键 { keybd_event(175,0,0,0); keybd_event(175,0,KEYEVENTF_KEYUP,0); } if(receive_data)//音量降低键 { keybd_event(174,0,0,0); keybd_event(174,0,KEYEVENTF_KEYUP,0); } if(receive_data)//停止媒体键 { keybd_event(178,0,0,0); keybd_event(178,0,KEYEVENTF_KEYUP,0); } if(receive_data)//媒体暂停键 { keybd_event(179,0,0,0); keybd_event(179,0,KEYEVENTF_KEYUP,0); } if(receive_data)//媒体上一曲键 { keybd_event(177,0,0,0); keybd_event(177,0,KEYEVENTF_KEYUP,0); } if(receive_data)//媒体下一曲键 { keybd_event(176,0,0,0); keybd_event(176,0,KEYEVENTF_KEYUP,0); } if(receive_data)//recall 退格按键 { keybd_event(8,0,0,0); keybd_event(8,0,KEYEVENTF_KEYUP,0); } if(receive_data)//Tab { keybd_event(9,0,0,0); keybd_event(9,0,KEYEVENTF_KEYUP,0); } if(receive_data)//窗口切换 alt+tab { keybd_event(18,0,0,0); keybd_event(9,0,0,0); keybd_event(9,0,KEYEVENTF_KEYUP,0); keybd_event(18,0,KEYEVENTF_KEYUP,0); } if(receive_data)//alt+F4 { keybd_event(18,0,0,0); keybd_event(115,0,0,0); keybd_event(115,0,KEYEVENTF_KEYUP,0); keybd_event(18,0,KEYEVENTF_KEYUP,0); } if(receive_data)//声道切换 alt+a { keybd_event(18,0,0,0); keybd_event(65,0,0,0); keybd_event(65,0,KEYEVENTF_KEYUP,0); keybd_event(18,0,KEYEVENTF_KEYUP,0); } if(receive_data)//字幕切换 alt+L { keybd_event(18,0,0,0); keybd_event(76,0,0,0); keybd_event(76,0,KEYEVENTF_KEYUP,0); keybd_event(18,0,KEYEVENTF_KEYUP,0); } |
|
|
|
只有小组成员才能发言,加入小组>>
3310 浏览 9 评论
2991 浏览 16 评论
3492 浏览 1 评论
9055 浏览 16 评论
4086 浏览 18 评论
1175浏览 3评论
603浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
596浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2333浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1894浏览 2评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 02:12 , Processed in 1.257760 second(s), Total 78, Slave 59 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号