|
|
马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
Get a handle to an application window. - V3 V9 m* [: [+ m1 ]/ l# Z5 Q
Declare Auto Function FindWindow Lib "USER32.DLL" ( _
/ z0 W! d( |3 s" y( AByVal lpClassName As String, _ ) g; @0 K* [$ |8 Z5 h
ByVal lpWindowName As String) As IntPtr
% v4 a4 H) l7 U
. L9 X! k9 A0 `' Activate an application window.
# K# W" g; X7 r% m1 d* A- o, f; o6 qDeclare Auto Function SetForegroundWindow Lib "USER32.DLL" _ ) M! O, B: \4 ?
(ByVal hWnd As IntPtr) As Boolean & f. V& t# W& c) b( o
# u3 k/ m$ d( Y7 {
' Send a series of key presses to the Calculator application.
/ `( K4 Z& n) B2 x# S3 `Private Sub button1_Click(ByVal sender As Object, _
$ `1 i1 R9 T8 v' |ByVal e As EventArgs) Handles button1.Click
3 K: j8 q6 Q' s1 P& H. n0 F
) ?4 S5 ]+ `" i9 k! u7 x+ f' y' Get a handle to the Calculator application. The window class 9 G0 D( G% {4 d1 M1 p3 J3 {
' and window name were obtained using the Spy++ tool.
1 f" N7 {' n" d7 cDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") % ^1 E( E. Z% U# v8 U, D
6 z: Y0 Y! t# U. z+ i' Verify that Calculator is a running process. 8 G9 {# g: t- O1 t+ M$ x& j( z% V
If calculatorHandle = IntPtr.Zero Then % j3 f+ b: S$ G% w- S" w
MsgBox("Calculator is not running.") + A) o# H9 j3 i0 t) F
Return , T# k( e8 o% X$ {
End If
; N4 F( o: r7 V7 L$ N. E) t0 s# | R, g+ b, ?2 s; m
[ 本帖最后由 zhaojianhong 于 2009-7-8 11:26 编辑 ] |
评分
-
查看全部评分
|