如何发送“ENTER”按键到另一个应用程序? [英] How to send an "ENTER" key press to another application?

查看:244
本文介绍了如何发送“ENTER”按键到另一个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有代码启动外部应用程序并自动填写密码提示。



我想自动按下ENTER键,以便用户不需要单击确定。



如何将ENTER键发送到外部应用程序?



以下是我现在的代码。



将密码发送到应用程序的第一行工作正常。



发送ENTER键的第二行根本没有效果。



我正在使用Delphi 2010。

  //现在我们有控制句柄,发送密码给
SendMessage(AppHandle,WM_SETTEXT,0,Integer(PChar(pwd))) ;

//现在按ENTER键
SendMessage(AppHandle,WM_KEYDOWN,0,Integer(PChar(#13)));


解决方案

尝试这个

  PostMessage(AppHandle,WM_KEYDOWN,VK_RETURN,0); 

再见。


I have code that launches an external application and automatically fills in a password prompt.

I want to automate the pressing of the "ENTER" key, so that the user does not have to click "OK".

How can I send the ENTER key to an external application?

Below is my code as it stands right now.

The first line to post the password to the application works fine.

The second line to send an ENTER key press has no effect at all.

I am using Delphi 2010.

    //now that we have the control handle, send the password to it
    SendMessage(AppHandle,WM_SETTEXT,0,Integer(PChar(pwd)));

    //and now push ENTER
    SendMessage(AppHandle,WM_KEYDOWN,0,Integer(PChar(#13)));

解决方案

Try this

PostMessage(AppHandle, WM_KEYDOWN, VK_RETURN, 0);

Bye.

这篇关于如何发送“ENTER”按键到另一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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