|
|
马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
Get a handle to an application window. 9 {& g4 |1 X! b! a
Declare Auto Function FindWindow Lib "USER32.DLL" ( _
( z+ h5 S1 U$ v+ _& _$ lByVal lpClassName As String, _ ! `% r/ ?4 k% ]4 h. z) P3 V( m
ByVal lpWindowName As String) As IntPtr * S/ G4 W, i$ z' A" {
# R* m6 a9 D7 H. `' I0 u' y
' Activate an application window.
5 w) _) ?# e2 }Declare Auto Function SetForegroundWindow Lib "USER32.DLL" _
2 o' @& V1 }, p# z% p(ByVal hWnd As IntPtr) As Boolean
( Q) U. l, {8 C+ [* K# W. b; L) n% q J5 U
' Send a series of key presses to the Calculator application.
$ T& P% ] X: ~2 n$ ]9 d7 M! R4 RPrivate Sub button1_Click(ByVal sender As Object, _
9 J1 ]) s! }; F' tByVal e As EventArgs) Handles button1.Click / G. r# g! O% q+ A0 t9 n; w
7 w5 t, G U3 l+ z* {0 V, V' Get a handle to the Calculator application. The window class
* `: J# x1 y" b% f" u0 P' and window name were obtained using the Spy++ tool. 5 @/ t2 a* `) `' n7 `; c
Dim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") 9 M$ n) j7 B! K' \6 F
) n, H6 ]+ _* d t* ]; Z, ?' Verify that Calculator is a running process.
& i; c! g2 U4 w3 ^' f' @0 i: aIf calculatorHandle = IntPtr.Zero Then . g3 O2 W% A- X# z% q
MsgBox("Calculator is not running.")
% R% y" n6 v1 X3 V9 xReturn 3 t; u4 M0 M7 E- a
End If
# ]& x5 e3 z$ C5 S
# N& d$ ], [1 e3 V[ 本帖最后由 zhaojianhong 于 2009-7-8 11:26 编辑 ] |
评分
-
查看全部评分
|