.NET sendkeys to calculator

本小妞迷上赌 提交于 2019-11-28 11:41:30

I'll tell you how you can figure out how to send keystorkes to calc.exe.

Use spy++ to monitor the messages on the calc.exe window process as you're using it. To do this go into spy++ and click on the log messages toolbar button. Drag the cursor onto the calc.exe window. The instructions I gave are for VS2008, they may differ slightly for the Spy++ included in other VS versions. But the same functionality has always been available.

You will see exactly what messages are sent as you are entering text. You need to do the same.

Use the Win32 API SendMessage, LPARAM and WPARAM to your found window handle.

I guess I got the problem. Timing is the problem here. As long as I put sleep() b/w sending command, the calc.exe get it right. It's not a good solution though.

On Windows 7, you have to do this:

IntPtr calculatorHandle = FindWindow("CalcFrame", "Calculator");
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!