简体   繁体   English

我如何才能让我的C ++程序自行“按下键”?

[英]How do i get my c++ program to “press keys” on its own?

Im writing a little C++ progam but got to a point from which on i could not go on: I want my program to control an external program using a certain combination of keys. 我正在编写一些C ++程序,但是到了无法继续的地步:我希望我的程序使用某种键组合来控制外部程序。 Yes, this sounds like a horribly unclean workaround, but thats what i want to do ;) 是的,这听起来像是一种非常不干净的解决方法,但这就是我想要做的;)

To be more specific: I want my little C++ program to control the already running program elinks (a text based internet browser) by pressing the "esc" then "v" and then "h" -keys (this is used to toggle between html and plain text output in elinks). 更具体地说:我希望我的C ++小程序通过按“ esc”,“ v”和“ h”-键来控制已经运行的程序elink(基于文本的Internet浏览器)(用于在html和html之间切换以及elink中的纯文本输出)。

But unfortunately, I do not know how to get a C++ program to type a certain combination of keys (...if this is possible at all). 但是不幸的是,我不知道如何获得一个C ++程序来键入键的特定组合(...如果可能的话)。 I already tried the search function but wasnt able to find a solution. 我已经尝试过搜索功能,但无法找到解决方案。 It would be very kind of you, if someone could give me a hint on what to do here. 如果有人可以给我提示在这里做什么,那将非常感谢您。

Thanks, Spoekenkieker 谢谢,Spoekenkieker

PS: Im running Linux PS:我正在运行Linux

If you have control over how to start the elinks browser, you can start it under the GNU screen terminal multiplexer and use its stuff command to send key inputs: 如果可以控制如何启动elinks浏览器,则可以在GNU screen终端多路复用器下启动它,并使用其stuff命令发送关键输入:

This way you're not required to learn the complications of X Windows programming. 这样,您无需学习X Windows编程的复杂性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM