当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > Sendkeys 和 Sendmessage 使用技巧一例

ASP.NET
many-to-many多对多映射
.NETRemotingChannelListener
转载李建忠老师的一篇文章
原创ColorComboBox控件
用IDisposable接口释放.NET资源
c#v2.0 扩展特性 翻译1
XPath中如何比较不同类型的对象
用哈希表搜索对象
C#陷阱int i = 10; i += i++; i =
Make a window that pops up from taskbar
获取网站返回的头部信息
自己动手写屏保
在DataGrid中添加Radio单选按钮列
实现性能目标的几种方法
增强.NETFramework中线程的功能
ASP.NET 2.0,写无限级下拉菜单不再难
book_dotnet
用.NET武装你的头脑
准备你的发布阶段
移植到.NET

ASP.NET 中的 Sendkeys 和 Sendmessage 使用技巧一例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 65 ::
收藏到网摘: n/a


Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Function sqrx(ByVal x As Double) As String '计算平方根(比VB DOUBLE 类型精度高)
Dim temp As String, i As Long, j As Long
Shell "Calc.EXE", vbMinimizedNoFocus '运行计算器
temp = x & "y0.5="
For i = 1 To Len(temp)
SendKeys Mid(temp, i, 1), True '向计算器顺序发送按键消息X (X^Y) 0.5=
Next
temp = String(64, Chr(0))
i = FindWindow(vbNullString, "计算器") '窗口句柄
j = FindWindowEx(i, ByVal 0&, "Edit", vbNullString) '编辑框句柄
SendMessage j, &HD, Len(temp), ByVal temp '发送编辑框文本至temp

SendKeys "%{F4}", True '调用ALT+F4关闭计算器窗口
sqrx = temp
End Function
Private Sub Command1_Click()
Dim i As Integer
For i = 17 To 24
Debug.Print "sqrx(" & i & ")=" & sqrx(i)
Next
End Sub
返回:
sqrx(17)=4.1231056256176605498214098559741
sqrx(18)=4.2426406871192851464050661726291
sqrx(19)=4.3588989435406735522369819838596
sqrx(20)=4.4721359549995793928183473374626
sqrx(21)=4.582575694955840006588047193728
sqrx(22)=4.6904157598234295545656301135445
sqrx(23)=4.7958315233127195415974380641627
sqrx(24)=4.8989794855663561963945681494118"