C#SendKeys不在某些程序上工作 [英] C# SendKeys not working on certain programs

查看:261
本文介绍了C#SendKeys不在某些程序上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我今天看到有关Twitch Plays Pokemon的新闻文章,这让我很好奇,看看我是否可以写一个C#程序我可以在文本框中键入命令并控制模拟器中的字符。这是我以前从未尝试过的事情,这似乎是一个有趣的挑战。



嗯,我已经花了很长时间在它上面而且我合情合理确保我有SendKeys命令正常工作,但它拒绝使用VisualBoyAdvance。



http ://pastebin.com/wr9t339g [ ^ ]



我有一种感觉,因为正确的儿童手柄没有集中注意力。但是,在我做过的每一次测试中,它拒绝给我一个子句柄列表。好像没有。我没有Spy ++(快递版没有它)但是WinSpy确实没有儿童手柄(我可以在上面看到它)。





任何帮助都非常感谢,因为我要发疯了。





删除不必要的代码块并单击链接[/ edit]

Hi guys!

I saw the news article today about the "Twitch Plays Pokemon" and it made me curious to see if I could write a C# program where I could type commands into a text box and control a character in an emulator. It's something I've never tried to do before and it seemed like an interesting challenge.

Well, I've spent quite some time on it and I'mm reasonably sure that I have the SendKeys commands working right but it refuses to work with VisualBoyAdvance.

http://pastebin.com/wr9t339g[^]

I have a feeling it's because the correct child handle isn't being focused. However, in every test I've done it refuses to give me a list of child handles. It's as if there are none. I don't have Spy++ (express edition doesn't have it) but WinSpy does sort of confirm that there are no child handles (that I can see on it anyway).


Any help is much appreciated in this as I'm about to go crazy.


[edit]unnecessary code block removed and clickable link[/edit]

推荐答案

您可以模拟输入使用原始Windows函数 SendInput

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



不幸的是,使用它需要P / Invoke,但一切都已经为你完成了: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx [ ^ ]。



它以通用方式工作,不依赖于UI的性质,甚至非常简单。在这方面,您可以认为 SendKeys 根本不起作用。把它忘了吧。 :-)



-SA
You can simulate input using the raw Windows function SendInput:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx[^].

Unfortunately, using it would require P/Invoke, but everything is already done for you: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx[^].

It does work in a universal way not depending on the nature of the UI and is even pretty easy. In this respect, you can consider that SendKeys does not work at all. Just forget it. :-)

—SA


这篇关于C#SendKeys不在某些程序上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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