|
|
马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
Get a handle to an application window.
& H5 @7 { q& ^Declare Auto Function FindWindow Lib "USER32.DLL" ( _
% v! Y/ h1 _( w3 l2 R0 XByVal lpClassName As String, _
- d9 L' ?$ B$ I6 A6 uByVal lpWindowName As String) As IntPtr + N% l6 R" c' Q6 k) H X, m+ Q9 @
0 s9 p5 m3 C, }
' Activate an application window. 9 @: q9 z7 U0 n& ?- Q2 M! D3 Q: ^ T/ }. X
Declare Auto Function SetForegroundWindow Lib "USER32.DLL" _
@ K: p, l9 n" L/ T, i(ByVal hWnd As IntPtr) As Boolean 6 x* c; b' ?8 v7 Z% K
+ K/ _7 i$ F ~2 y7 n9 V
' Send a series of key presses to the Calculator application.
$ j* j6 y1 O( R" E# x& gPrivate Sub button1_Click(ByVal sender As Object, _
F8 @5 ?. B. W& Z. Q: X) G8 f3 V" vByVal e As EventArgs) Handles button1.Click
* ]2 d+ {, t1 n$ |4 a+ h6 b
2 I3 V! ~8 L# e1 a, L2 w; o3 T$ q' Get a handle to the Calculator application. The window class % O/ V, ~- w! x. I3 O
' and window name were obtained using the Spy++ tool.
$ v7 ]6 [% g' |* }; nDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") & L2 E& U- |4 Z* `6 i
+ D' b$ O: M) L$ o
' Verify that Calculator is a running process.
% }8 x# _; V4 a- O# A0 c7 N1 @If calculatorHandle = IntPtr.Zero Then / j7 f" t2 S+ e
MsgBox("Calculator is not running.")
( H. p5 @, s# SReturn
. [' y! U- T$ X6 \9 k, n; @End If
u* P |: l1 d( m# Y& S- B8 y P9 H" j
[ 本帖最后由 zhaojianhong 于 2009-7-8 11:26 编辑 ] |
评分
-
查看全部评分
|