如何以编程方式(在 C/C++ 中)模拟 DOS 中的击键?
首先,我谈论的是 DOS,而不是 Windows 的命令行应用程序。
我希望编写一个程序,将击键发送到当前正在运行的进程。 我的目标是在 ISR(中断处理程序)中使用此过程。
换句话说,这就是我想要发生的事情:
- DOS 启动。
- 我运行一个 TSR,它将我的程序注册为某个中断的 ISR(不是键盘中断,但现在我们假设它是)。
- 我运行另一个程序,该程序成为当前正在运行的进程。
- 发生上述中断。
- 我的程序跳入并模拟击键,事实上,这从未真正发生过。
- 当前运行的进程接收此击键,就像实际按下了模拟键一样。
我找到了几个具有不同示例的来源,但我无法真正找到任何适合我的东西。
我不知道它是否有任何相关性,但我现在用来测试所有这些的包括在 VirtualBox 机器上运行的 FreeDOS,以及用于编译和运行代码的 DJGPP(我相信它使用 GNU 编译器) 。
任何和所有的帮助将非常感激。
First off, I'm talking about DOS, and not Windows's command-line application.
I wish to write a procedure that would send a keystroke to the currently running process.
My goal is to use this procedure in an ISR (interrupt handler).
In other words, this is what I want to happen:
- DOS boots up.
- I run a TSR which registers my procedure as an ISR for some interrupt (not the keyboard interrupt, but for now let's assume that it is).
- I run another program, which becomes the currently running process.
- The aforementioned interrupt occurs.
- My procedure jumps in and emulates a keystroke, which, in fact, never really happened.
- The currently running process receives this keystroke as though the emulated key was actually pressed.
I found several sources with different examples, but I couldn't really get anything to work for me.
I don't know if it's of any relevance, but what I'm using at the moment to test all this includes FreeDOS running on a VirtualBox machine, and DJGPP for compiling and running the code (it uses the GNU compiler, I believe).
Any and all assistance would be very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IIRC 你必须使用 BIOS 调用 INT 16h, FUNC 05H ...?或者直接写到 0040:001E(或者是 001C)...谷歌搜索会出现一些关于该主题的线程...
http://www.rhinocerus.net/forum/lang-asm-x86/254441-re-how-write -char-keyboard-buffer.html
IIRC you have to use a BIOS call INT 16h, FUNC 05H ...? or write directly to 0040:001E (or was it 001C)... a google search turns up a couple threads about the topic...
http://www.rhinocerus.net/forum/lang-asm-x86/254441-re-how-write-char-keyboard-buffer.html