通过另一个程序将输入提供给GUI应用程序 [英] Giving input to a GUI application through another program

查看:55
本文介绍了通过另一个程序将输入提供给GUI应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道的是如何为封闭源且没有任何公共API的GUI应用程序提供输入.

What i want to know is how can you give input to a GUI app that is closed source and does not have any public API.

为简明起见,假设您打开单人纸牌游戏并希望通过一个程序来玩它.或者,要了解基础知识,您可以使用带有按钮的GUI应用程序,并想通过其他程序单击它.

To be more concise, let's say you open solitaire and want through a program to play it. Or, to go even to the basics, you have an GUI app with a button and you want to click it through another program.

我知道这个问题有点含糊,但这是我能说的最好的话.请帮助我进行一些编辑或评论,以使其更具体.

I know the question is a little vague, but that's the best I can phrase it. Please help me with some edits or some comments to make it more specific.

推荐答案

调查

Investigate SendInput(). It can be used to simulate mouse movements and key presses.

要使用其GUI查找Windows应用程序,可以使用

To locate a Windows application using its GUI you can use EnumWindows() to locate a Window with a particular title. This will provide a Window handle. To give that window focus, you could:

  • obtain the window handle via EnumWindows()
  • use GetWindowRect() to get the co-ordinates of the window rectangle
  • move the mouse to within the bounds of the window using SendInput() and simulate a mouse click using SendInput()

我曾经做过一次,而且很难做到正确.一旦启动程序,坐上手:请勿触摸鼠标或键盘.

I have done this once, and it is infuriatingly difficult to get right. Once you start your program sit on your hands: don't touch the mouse or the keyboard.

(我不知道如何在Linux上做类似的事情)

这篇关于通过另一个程序将输入提供给GUI应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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