读取键盘缓冲区并执行系统文件(TURBOC ++或VISUALC ++) [英] Read Keyboard Buffer and Execute System Files (TURBOC++ OR VISUALC++)

查看:115
本文介绍了读取键盘缓冲区并执行系统文件(TURBOC ++或VISUALC ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的项目的作用:

语言:C ++



一旦系统成功登录,这个软件就是我正在制作或直接在启动时运行,如果用户偶然按下任何预定义的键,则以下功能运行

w===> MS Word文件

b===>默认浏览器

更像是关机,重启和打开MSPAINT,explorer,Calc等等! ...



附加功能:

使程序执行BIOS哔声,使用户对发生的事情感到困惑。

类似的CHIME RAM BEEP也可以尝试实现。

Cursor的随机移动(防止鼠标被操作)



我需要帮助(建议如何去做):

1.如果我的程序最小化,如何阅读键盘缓冲区?

2.如何使用CLI运行系统文件??

3.如何BIOS BEEP和CHIME BEEP?

Here is what my project does:
Language: C++

Once the system has successfully logged-in, and this software that I am making is made to run or directly at start-up, if the user incidentally presses any of the pre-defined keys, the following function runs
"w" ===> MS Word Document
"b" ===> Default Browser
and more like shutdown, restart and opening MSPAINT, explorer, Calc and all ! ...

Addition Features:
Make the program perform a BIOS Beep that makes the user confused on what is happening.
A similar CHIME RAM BEEP can also be tried to implement.
Random movement of Cursor (to prevent the mouse from being operated)

I need help (advise on how to go about) in :
1. HOW TO READ THE KEYBOARD BUFFER EVEN WHEN MY PROGRAM IS MINIMIZED??
2. How to run System Files using the CLI ??
3. How to BIOS BEEP AND CHIME BEEP ?

推荐答案

For #1 - 即使程序没有输入焦点,也要读取键盘缓冲区。使用GetAsyncKeyState函数。您必须在循环中对其进行编码并搜索所有扫描代码。在每次调用GetAsyncKeyState之间,请务必在Sleep之间包含几毫秒的调用,以防止占用CPU。



http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293%28v = vs.85%29.aspx [ ^ ]



上述技巧将告诉您在任何给定时刻哪些键被按下。从中可以推断出关键事件。您还必须将关键扫描代码映射到实际的ASCII字符。示例:VK_A是字母'A'。上述技术也仅限于当前的工作站。如果有人切换到另一个工作站,则不会捕获另一个会话中的击键。



对于#2 - 如何从CLI运行系统文件。那有点模糊。你想以编程方式启动另一个程序吗?如果是这样,请使用CreateProcess或ShellExecute。如果要从命令窗口启动某些内容,请键入带有完整路径的程序名称,或键入start,然后键入程序名称(最好带有完整路径)。



http://msdn.microsoft.com /en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx [ ^ ]



# 3 - BIOS Beep。使用MessageBeep函数。



http://msdn.microsoft.com/en-us/library/windows/desktop/ms680356%28v=vs.85%29.aspx [ ^ ]



对于一个铃声,请使用较旧(但已弃用)的Beep功能。以不同的音高和持续时间拨打几个电话。



http://msdn.microsoft.com/en-us/library/windows/desktop/ms679277%28v=vs.85%29.aspx [ ^ ]
For #1 - reading the keyboard buffer even when the program does not have the input focus. Use the GetAsyncKeyState function. You will have to code it in a loop and search all scan codes. Be sure to include a call to Sleep for a few milliseconds between each call to GetAsyncKeyState to prevent hogging the CPU.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293%28v=vs.85%29.aspx[^]

The above technique will tell you which keys are de-pressed at any given moment. From that you can infer key events. You will also have to map key scan codes to actual ASCII characters. Example: VK_A is the letter 'A'. The above technique is also limited to the current workstation. If someone switches to a different workstation, key strokes in the other session won't be captured.

For #2 - how to run system files from the CLI. That's a bit vague. Do you want to programmatically start another program? If so, use CreateProcess or ShellExecute. If you want to start something from a command window, type the program name with full path, or type "start" followed by the program name (preferably with the full path).

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx[^]

For #3 - BIOS Beep. Use the MessageBeep function.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms680356%28v=vs.85%29.aspx[^]

For a chime, use the older (but deprecated) Beep function. Make several calls with different pitch and duration.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms679277%28v=vs.85%29.aspx[^]


这篇关于读取键盘缓冲区并执行系统文件(TURBOC ++或VISUALC ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆