|
|
马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
Get a handle to an application window. ! k, l" ?2 b; j0 S
Declare Auto Function FindWindow Lib "USER32.DLL" ( _
" c0 P/ a0 B K( `6 y. O) A: bByVal lpClassName As String, _ 8 ]# c1 T6 @/ a+ `$ Q5 B7 |& \
ByVal lpWindowName As String) As IntPtr
/ }1 b5 O. b' F( P4 @: _- e5 u+ _; r8 h4 x8 j, i
' Activate an application window. & e7 p' C# f; |3 W! w6 M2 r
Declare Auto Function SetForegroundWindow Lib "USER32.DLL" _
+ z4 @$ j! {: r# m% l/ |! G$ G$ r(ByVal hWnd As IntPtr) As Boolean 1 X0 U0 k$ W3 l
. }8 A: p" N$ ^+ [
' Send a series of key presses to the Calculator application. ?* r$ Z% E9 e% p# u! U4 @3 D+ p
Private Sub button1_Click(ByVal sender As Object, _ ( H$ h& n3 l/ Z' n! ~6 v
ByVal e As EventArgs) Handles button1.Click . Q8 z. b* x/ z1 b% C; w6 E" D! X' j% [
* u( Y' d0 E" B- X' V" N4 F
' Get a handle to the Calculator application. The window class
* m* ]+ W& A/ O' and window name were obtained using the Spy++ tool.
# @* X! x3 |3 m6 R! b4 D6 BDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator")
) @' K1 C$ }/ ?+ _, F0 P' R
7 j% m9 d7 W' X3 K$ I' Verify that Calculator is a running process. 7 }# e/ }& t# O
If calculatorHandle = IntPtr.Zero Then - m% `& G; [" Q, y- r( T
MsgBox("Calculator is not running.")
, P7 g) @' [; j2 s, OReturn / ]5 n0 G7 v8 \/ M; m- c# @1 R
End If k2 }: m3 }+ {; b+ s
# g2 r7 f, Q$ p" G6 U* I# W I
[ 本帖最后由 zhaojianhong 于 2009-7-8 11:26 编辑 ] |
评分
-
查看全部评分
|