开发者

How to use Ruby to detect whether on Windows Platform, the SHIFT or ALT key is being pressed?

I wrote a script using Ruby to click on the screen automatically on Windows's apps. All is fine except there are situations where the program will keep on clicking and I have no opportunity to click on the Shell and click CTRL-C.

So some "sleep" statement need to be placed somewhere in the loop, such as "sleep 3", so that there are 3 seconds to allow the user to switch to开发者_开发百科 the Shell and press CTRL-C.

But is there a way to detect whether the SHIFT or ALT (or BOTH) is pressed on the Windows Platform while the Ruby program is running, so that when that is detected, then do a "sleep 10", so that the automatic clicking is stopped, and then there are 10 seconds to stop the Ruby program?


On Win32, how to detect whether a Left Shift or Right ALT is pressed using Perl, Python, or Ruby (or C)? has some clues...

ruby ffi might help, too

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜