|
|
马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
Get a handle to an application window. - Q0 E; G& b9 G" [ H
Declare Auto Function FindWindow Lib "USER32.DLL" ( _ ' \6 W, T' Y: W/ W
ByVal lpClassName As String, _
! l4 ?% {$ T cByVal lpWindowName As String) As IntPtr / D( N% |) E( n) t2 }0 A- F: w5 }
6 S9 \& C3 {, y- m$ T. Y' Activate an application window.
# T( G; s3 {4 l( WDeclare Auto Function SetForegroundWindow Lib "USER32.DLL" _
8 f. t# B+ F, D' ~4 L8 N7 A(ByVal hWnd As IntPtr) As Boolean
. R9 l7 _. e( I4 \; D+ ]/ u- q( o
9 E5 j/ R! c* H9 c! M; u$ ^$ |# C' Send a series of key presses to the Calculator application.
5 @7 Y' x0 e- O' f4 WPrivate Sub button1_Click(ByVal sender As Object, _
3 M# o1 F# c" L aByVal e As EventArgs) Handles button1.Click
! h' m) }8 s9 ~; r6 L, U
2 `( u* s* X* n1 y' Get a handle to the Calculator application. The window class
! ]* x, {% @4 m: Z" d, \! i: v' and window name were obtained using the Spy++ tool.
# Y# m# ^+ ^( ]: m Q6 P% \8 U) lDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator")
* s/ @2 X" E7 b3 e" Y; I8 g, u8 A" T( O5 N& {* U
' Verify that Calculator is a running process. % k' S4 x' [ |( W7 K4 H3 F& s
If calculatorHandle = IntPtr.Zero Then
1 }- k4 S) ^. ~- t; yMsgBox("Calculator is not running.")
& o8 o2 M3 {. I3 o2 R8 H# oReturn
7 d, f! Z+ I* t" YEnd If * K' k' O3 f7 V- X6 R
/ s- @$ |/ x' `7 q3 P0 @[ 本帖最后由 zhaojianhong 于 2009-7-8 11:26 编辑 ] |
评分
-
查看全部评分
|