通过另外一个应用程序给多个文本框赋值, 模拟单击事件

被调用的应用程序:

[delphi] view plain copy

print?

  1. unit Unit2;
  2. interface
  3. uses
  4. Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  5. Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
  6. type
  7. TForm2 = class(TForm)
  8. Button1: TButton;
  9. Label1: TLabel;
  10. Label2: TLabel;
  11. Label3: TLabel;
  12. Label4: TLabel;
  13. procedure Button1Click(Sender: TObject);
  14. private
  15. { Private declarations }
  16. public
  17. { Public declarations }
  18. end;
  19. var
  20. Form2: TForm2;
  21. implementation
  22. {$R *.dfm}
  23. procedure TForm2.Button1Click(Sender: TObject);
  24. var
  25. h_form, h_text1, h_text2, h_button: HWND;
  26. str1, str2: string;
  27. begin
  28. // 获取窗口的句柄.
  29. h_form := findWindow(‘TForm1‘, ‘Form1‘);
  30. // 获取文本框的句柄. (注意多个)
  31. h_text1 := FindWindowEx(h_form, 0, ‘TEdit‘, nil);
  32. h_text2 := FindWindowEx(h_form, h_text1, ‘TEdit‘, nil);
  33. str1 := ‘本文1!‘;
  34. str2 := ‘本文2!‘;
  35. SendMessage(h_text1, WM_SETTEXT, 0, LPARAM(str1));
  36. SendMessage(h_text2, WM_SETTEXT, 0, LPARAM(str2));
  37. // 获取按钮的句柄. (注意多个)
  38. h_button := FindWindowEx(h_form, 0, ‘TButton‘, nil);
  39. SendMessage(h_button, WM_LBUTTONDOWN, 0, 0);
  40. SendMessage(h_button, WM_LBUTTONUP, 0, 0);
  41. label1.Caption := inttohex(h_form, 2);
  42. label2.Caption := inttohex(h_text1, 2);
  43. label3.Caption := inttohex(h_text2, 2);
  44. label4.Caption := inttohex(h_button, 2);
  45. end;
  46. end.

[cpp] view plain copy

print?

  1. object Form2: TForm2
  2. Left = 0
  3. Top = 0
  4. Caption = ‘Form2‘
  5. ClientHeight = 211
  6. ClientWidth = 408
  7. Color = clBtnFace
  8. Font.Charset = DEFAULT_CHARSET
  9. Font.Color = clWindowText
  10. Font.Height = -11
  11. Font.Name = ‘Tahoma‘
  12. Font.Style = []
  13. OldCreateOrder = False
  14. PixelsPerInch = 96
  15. TextHeight = 13
  16. object Label1: TLabel
  17. Left = 144
  18. Top = 8
  19. Width = 57
  20. Height = 17
  21. Caption = ‘Label1‘
  22. end
  23. object Label2: TLabel
  24. Left = 74
  25. Top = 48
  26. Width = 57
  27. Height = 25
  28. Caption = ‘Label2‘
  29. end
  30. object Label3: TLabel
  31. Left = 208
  32. Top = 48
  33. Width = 79
  34. Height = 17
  35. Caption = ‘Label3‘
  36. end
  37. object Label4: TLabel
  38. Left = 144
  39. Top = 96
  40. Width = 79
  41. Height = 25
  42. Caption = ‘Label4‘
  43. end
  44. object Button1: TButton
  45. Left = 144
  46. Top = 160
  47. Width = 75
  48. Height = 25
  49. Caption = ‘Button1‘
  50. TabOrder = 0
  51. OnClick = Button1Click
  52. end
  53. end

调用的程序:

[delphi] view plain copy

print?

  1. unit Unit1;
  2. interface
  3. uses
  4. Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  5. Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
  6. type
  7. TForm1 = class(TForm)
  8. Edit1: TEdit;
  9. Edit2: TEdit;
  10. Label1: TLabel;
  11. Label2: TLabel;
  12. Button1: TButton;
  13. Label3: TLabel;
  14. procedure Button1Click(Sender: TObject);
  15. procedure FormCreate(Sender: TObject);
  16. private
  17. { Private declarations }
  18. public
  19. { Public declarations }
  20. end;
  21. var
  22. Form1: TForm1;
  23. implementation
  24. {$R *.dfm}
  25. procedure TForm1.Button1Click(Sender: TObject);
  26. begin
  27. // showmessage(‘登陆成功!‘);
  28. label3.Caption := ‘登陆成功!‘;
  29. end;
  30. procedure TForm1.FormCreate(Sender: TObject);
  31. begin
  32. label3.Caption := ‘‘;
  33. end;
  34. end.

[cpp] view plain copy

print?

  1. object Form1: TForm1
  2. Left = 0
  3. Top = 0
  4. Caption = ‘Form1‘
  5. ClientHeight = 360
  6. ClientWidth = 486
  7. Color = clBtnFace
  8. Font.Charset = DEFAULT_CHARSET
  9. Font.Color = clWindowText
  10. Font.Height = -11
  11. Font.Name = ‘Tahoma‘
  12. Font.Style = []
  13. OldCreateOrder = False
  14. OnCreate = FormCreate
  15. PixelsPerInch = 96
  16. TextHeight = 13
  17. object Label1: TLabel
  18. Left = 168
  19. Top = 155
  20. Width = 40
  21. Height = 13
  22. Caption = #29992#25143#21517‘:‘
  23. end
  24. object Label2: TLabel
  25. Left = 168
  26. Top = 203
  27. Width = 28
  28. Height = 13
  29. Caption = #23494#30721‘:‘
  30. end
  31. object Label3: TLabel
  32. Left = 208
  33. Top = 288
  34. Width = 193
  35. Height = 41
  36. Caption = ‘Label3‘
  37. end
  38. object Edit1: TEdit
  39. Left = 224
  40. Top = 152
  41. Width = 121
  42. Height = 21
  43. ImeName = #20013#25991‘(‘#31616#20307‘) - ‘#26497#28857#20116#31508
  44. TabOrder = 0
  45. end
  46. object Edit2: TEdit
  47. Left = 224
  48. Top = 200
  49. Width = 121
  50. Height = 21
  51. ImeName = #20013#25991‘(‘#31616#20307‘) - ‘#26497#28857#20116#31508
  52. TabOrder = 1
  53. end
  54. object Button1: TButton
  55. Left = 270
  56. Top = 248
  57. Width = 75
  58. Height = 25
  59. Caption = #30331#38470
  60. TabOrder = 2
  61. OnClick = Button1Click
  62. end
  63. end

http://blog.csdn.net/huang_xw/article/details/8644506

时间: 2024-08-05 11:17:59

通过另外一个应用程序给多个文本框赋值, 模拟单击事件的相关文章

将div变成可编辑的状态,你造么?QQ空间中的发表说说的文本框其实就是一个DIV,而非textarea文本框

<div contenteditable="true">可以编辑里面的内容</div> 如果你在BODY里面加上contenteditable="true",可以发现该属性是多么的神奇.因此我们可以给HTML标签设置contenteditable="true"属性则可以对该标签进行编辑. contenteditable属性兼容所有浏览器(IE6之前的版本是否兼容未测试) 在有些时候我们完全可以用DIV去替代input或者t

.Net程序员玩转Android开发---(13)ListView单击事件

大家都知道ListView用来显示数据列表,每一个列表都有列表项组成,如果我们单击选中一个列表,想获取列表中的详细信息或者打开一个新窗口把列表信息传递过去怎么办那?这一节我们演示一下ListView的单击事件,通过这节我们会对ListVIEW有更深入的理解,先看下效果图 下面看下演示代码 主布局文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="ht

一个友好的文本框内显示提示语 jquery 插件

插件实现文本框内默认显示提示语,当文本框获得焦点时提示语消失. 如果没有输入或输入为空则失去焦点时提示语再次出现. 同时它的使用非常舒适简单,引入插件及 jquery 后,在原有的文本框内加上样式类(class="prompt-input")以及设置值(value="Your prompt")为提示语就可以了. 像这样: 1 <input class="prompt-input" type="text" value='Y

第一个JAVA程序解析

上一篇博客中,我们编写了第一个JAVA程序并使用最原始的方式对其进行编译运行,很多文章或书籍中对该种编译运行方式不做介绍,但是我认为这有助于我们更好的了解.学习JAVA,是不可忽略的一部分,在我身边有很多人,学完一段时间JAVA后,只知道如何在IDE中进行开发,却不知脱离IDE后该如何运行,不得不说这也是一种悲哀. 言归正传,我们来看一下上一篇博客中的例子"Hello World",这也是几乎所有的编程语言都会编写的一个例子,非常的经典. 下面我们就来分析一下: /**  *  我的第

二、第一个ExtJS程序:helloExtJS

开发前的准备 下载并解压ExtJS包后,可以得到下图的文件目录结构: 在实际开发过程中并不需要所有的文件和目录,所需的包含如下目录即可: 若使用eclipse进行开发,只需将上述文件复制到WebRoot目录或其子目录. 开始 新建firstextjs.html 在使用ExtJS之前,需要在页面引入相应的样式和js文件,一般包括的最小集合是这样:ext-all.js,adapter/ext/ext-base.js,locale/ext-lang-zh_CN.js和整个resources目录. ex

当世界上只剩下一个Java程序员

公元2050年,世界上只剩下了一个Java程序员. 你可能要问了,别的人都去哪儿了?原因很简单, Java没落了. 大约在2030年左右,出现了一个叫做X的语言,它既能做系统级开发(操作系统.数据库.编译器),也能做服务器端的开发,手机端,Web端都不在话下. 更为重要的是,这个新的编程语言和人类的自然语言很接近,无论大人小孩,稍微一学,很快就可以来编程.于是排名前100的语言统统消失了, 程序员们都失业了. Java也不例外,这个昔日的霸主在留下了一堆庞大而复杂的系统以后就不见了. Java程

作为一个女程序员,有感而发

下午,在CSDN看到了一篇女程序员的迷茫的贴子,突然有感而发,写下了自己的一些感想,以及为什么我突然会来考教师资格证的奇怪想法(奇怪的想法,这是很多朋友对我的评价). 我是一个女程序员,目前是一个公司的技术架构师,写着项目核的代码,同时管理着一个不大不小的开发团队,今年一开年,大大小小6-7个新项目转到我手上,加上原有的项目维护,就能初步估计这一年又没什么假期了,还必须照顾着下面一群小伙子的心态.做项目,的确很累,特别是对于女性同胞们来讲.但是生活就是这么回事,为了不让IT狂潮把自己给淹没了,必

关于链表的一个小程序

关于链表的一个小程序: /**************************链表*****************************//* 具备功能 *//* 链表按元素位置插入 *//* 链表按元素位置删除 *//* 链表全表遍历 *//* 链表整表创建(头插法) *//* 链表整表创建(尾插法) *//* 链表整表删除 *//**************************链表*****************************/ #include<stdio.h>#in

使用MyEclipse开发第一个Web程序

MyEclipse环境配置 首先,安装一个MyEclipse,然后进行一些相关的环境配置(Window->Preferences): 比如字体.Formatter等. 也可以从Eclipse中导出配置,然后在MyEclipse中导入. 这里需要特别注意的是两个配置: 1.JSP的打开方式: 选为用编辑器打开: Window->Preferences->General->File Associations 然后在右边窗口选jsp,下面选择MyEclipse JSP Editor,在右