|
|
马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
Get a handle to an application window. 2 u) L+ g0 R+ t) D
Declare Auto Function FindWindow Lib "USER32.DLL" ( _
' H3 l. M' y' F& u3 Y. e/ g6 d4 ZByVal lpClassName As String, _
7 }( C: s5 a& NByVal lpWindowName As String) As IntPtr
& A# R" q5 @4 M7 d5 s/ v0 w5 v& H
+ T1 q: P( ~# l7 b0 w7 a9 T' Activate an application window.
* L; K) {+ Z- P9 z9 O* IDeclare Auto Function SetForegroundWindow Lib "USER32.DLL" _ # m) N/ s! R7 `6 z6 t
(ByVal hWnd As IntPtr) As Boolean . a8 K' B- q1 R4 @; i
' @ M1 R/ z* H' ^/ B7 G: ]. ?$ [; S' Send a series of key presses to the Calculator application.
8 O8 P I8 @! ~; \) W' g# R3 WPrivate Sub button1_Click(ByVal sender As Object, _ 5 F* G C; ]2 ^5 s6 K) y" Z4 D
ByVal e As EventArgs) Handles button1.Click
% k) `" v; v: d6 P% z7 t7 }- a( x$ D4 m) r( _# z" Q
' Get a handle to the Calculator application. The window class
! _' e+ z; @1 Q/ v( l, d/ Z; `' and window name were obtained using the Spy++ tool.
1 ]5 x1 i. [6 _( Q& T5 dDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") - ]- \+ c o; d* i- p. O7 B" d
; S3 M9 M& ~" g" S/ N7 k2 R' Verify that Calculator is a running process.
8 J- ? F! g& eIf calculatorHandle = IntPtr.Zero Then
' _: |6 D0 z- C6 F0 V* f; X4 wMsgBox("Calculator is not running.")
; e1 z( z. a% t* }# AReturn
/ d2 ~7 ^( x1 [ wEnd If
( s) a( u; A, P9 T. G7 w# A' w, S) `6 ^6 y; z
[ 本帖最后由 zhaojianhong 于 2009-7-8 11:26 编辑 ] |
评分
-
查看全部评分
|