完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我想用键盘上的箭头按钮控制我的3轴电机舞台的运动。
(类似于几乎每个小型PC游戏,例如PC赛车游戏)。 到目前为止,只有用鼠标点击切换按钮才能实现。 有没有人知道如何通过按键盘上的按钮获得(直接)输入? - 使用激活OK命令的F按钮(F1,F2,...)不是答案 - 键盘通过USB或PS / 2连接。 我找不到它作为I / O仪器(没有USB / TMC协议?)) - 我有更好的机会使用适配器(例如PS / 2到RS232)? 谢谢你的每一个提示! 以上来自于谷歌翻译 以下为原文 Hello, I want to control the movement of my 3axis motor stage with the arrow buttons of my keyboard. (similar to almost each small pc game, e.g. pc racing game). Until now it is only possible by clicking on toggle-buttons with my mouse. Does anyone know a possibility how to get a (direct) input by pressing a button on the keyboard? - the usage of F-buttons (F1,F2,...) which activate the OK-command is not the answer - Keyboard is connected via USB or PS/2. I cannot find it as an I/O Instrument (no USB/TMC-protocoll?)) - would I have better chance by using an adapter (e.g. PS/2 to RS232)? thanks for each hint! |
|
相关推荐
5个回答
|
|
我想我会尝试回复这个问题,因为它已经有一段时间没有得到答复:-(我认为这可以做到,但我还是说它需要用.NET控件来完成。
我会接近它是创建一个.NET面板,它是用户控件的基础,然后创建一个KeyPress事件。我尝试制作一个比我想象的更难的快速演示 - 做一个网络搜索似乎这个 是一个已知的问题,你需要调用Panel.Focus()(或你正在使用的任何控件 - 它可能是一个带有4向箭头的标签......)我发现我需要调用它 开始以及每次按下一个键(可能是焦点丢失到对话框中)。我确信这可以改进,但至少它说明我有可能发现一个字符键同时触发KeyPress和KeyDown 事件,而箭头键(或功能键)只被后者困住.HTH迈克 以上来自于谷歌翻译 以下为原文 I thought I'd make an attempt at a reply for this as it has been unanswered for some time :-( I think this can be done, but I would also say that it needs to be done with a .NET control. The way I would approach it is to create a .NET panel which is the basis of the user control and then create a KeyPress Event. I tried making a quick demo which was a bit more difficult than I had thought - doing a web search it seems this is a known issue and that you need to call Panel.Focus() ( or whatever control you're using - it could be a label with a 4-way arrow on it... ) I found I needed to call it at the start and also each time a key was pressed ( presumably the focus was lost to the dialog box ). I'm sure this could be improved but at least it demostrates that it is possible I also discovered that a character key triggered both KeyPress and KeyDown events, whereas an arrow key ( or a function key ) is only trapped by the latter. HTH Mike 附件
|
|
|
|
bgvywerq 发表于 2018-9-28 19:15 非常感谢您的回复。 你帮助了我很多,在你的帮助下,你可以通过keydown和keyup-event来控制事件。 不幸的是,我无法同时实现2个按钮的控制。 当容器被推到一起时,ControlContainer只接受其中一个,因此我只能将我的遥控设备向前/向后或向右/向左移动......你知道是否有可能解决这个问题 无论如何? 否则我将无法驾驶曲线:-) 以上来自于谷歌翻译 以下为原文 Thank you _very much_ for your reply. You helped me a lot and with your help it was possible to control the events with the keydown- and keyup-event. Unfortunately I haven't been able to implement the control of 2 buttons at the same time. The ControlContainer accept only one of them, when the bottons are pushed together and therefore I'm only able to move my remote-controlled device either foward/backward or right/left... Do you know if there is a possibility to solve this anyhow? Otherwise I'll not been able to drive through curves :-) |
|
|
|
hgimtk 发表于 2018-9-28 19:31 感谢您的反馈:-)它将同时处理多个按键,但当然,当您按下第二个键时,程序需要能够运行,即不等待我的示例中的对话框。 我对我制作的原始程序(附件)做了一个相当难看的mod。 您需要跟踪正在按下哪些键,并可能使用KeyUp事件来确定它们何时被释放。 毫无疑问,你也想要阻止向后+向前或向左+向右。 我会用全局变量跟踪事物。 我的例子只查找DOWN然后LEFT:它按下时设置全局Down,然后,如果按下Left时为true,它会弹出一个对话框。 此刻,按下并释放DOWN然后按下LEFT将产生相同的效果,但希望它显示原理。 我注意到,在对话框弹出之前我需要按下LEFT一段时间:我假设这与我的程序有关,但如果不是,那可能是一件令人讨厌的事情。 HTH迈克 以上来自于谷歌翻译 以下为原文 Thanks for the feedback :-) It will deal with more than one keypress at the same time but of course the program needs to be able to run when you are pressing the second key i.e. not waiting for a dialog box as in my example. I have made a rather ugly mod to the original program I made ( attached ). You'll need to track which keys are being pressed and probably use a KeyUp event to decide when they have been released. You'll no doubt also want to prevent back+forward or left+right. I would track things with a global variable. My example only looks for DOWN then LEFT: it sets the global Down when that is pressed and then, if that is true when the Left is pressed, it pops up a dialog. At the moment, pressing and releasing DOWN and then pressing LEFT would have the same effect but hopefully it shows the principle. I note that I need to press LEFT for a little while before the dialog pops up: I'm assuming that is to do with my program but if not that could be a nasty thing to fix. HTH Mike 附件 |
|
|
|
谢谢,这很好。
我会尽快为我的电机阶段实现这个代码,并告诉你这一切是怎么回事。 这将是令人兴奋的:-)最好的问候约翰内斯 以上来自于谷歌翻译 以下为原文 Thanks that's nice. I'll implement this code for my motor stage as soon as possible and will tell you how it all went. It's gonna be exciting :-) best regards Johannes |
|
|
|
嗨,我现在已经编程了我的马达阶段,它原则上是有效的。 再次感谢您的帮助。 代码已附加(没有电机级的特定命令)。 但是,如果在我的控制期间另外按下或释放任何键,则在大多数情况下不会注册输入。 你知道是否有可能排除密钥激活事件处理程序? 我试图用“处理”属性来实现它,但它根本不起作用。 最好的问候,约翰内斯 以上来自于谷歌翻译 以下为原文 Hi, I've programmed my motor stage now and it works in principle. Thank for your help again. The code is attached (without the specific commands for the motor stage). However, if any key is pushed or released in addition during my controlling, the input isn't registered in most of the case. Do you know if there is a possibility to exclude keys from activating the event handler? I've tried to implement this with the "handled"-property, however it didn't work at all. best regards, Johannes 附件
|
|
|
|
只有小组成员才能发言,加入小组>>
1229 浏览 0 评论
2350 浏览 1 评论
2160 浏览 1 评论
2026 浏览 5 评论
2908 浏览 3 评论
973浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
707浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
808浏览 0评论
1230浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 21:34 , Processed in 1.209291 second(s), Total 56, Slave 49 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号