|
|
马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
Get a handle to an application window. & @% m# L; T1 a1 d; g
Declare Auto Function FindWindow Lib "USER32.DLL" ( _ , B' E. F: ?7 J$ a, ^5 G' L: X
ByVal lpClassName As String, _
3 d0 P% c, L# C- D1 e7 NByVal lpWindowName As String) As IntPtr ~, _6 o0 D5 ?3 q% y- h
5 ^/ g6 F0 V' x: R" G' K' Activate an application window.
. s/ C8 g4 y+ i1 }5 ADeclare Auto Function SetForegroundWindow Lib "USER32.DLL" _ # h; _( S' S! i5 |/ u
(ByVal hWnd As IntPtr) As Boolean 8 @ ^& @( G! p2 ~. N
$ M+ N: g$ \: B' _) L' Send a series of key presses to the Calculator application.
5 v z$ k& s' M) OPrivate Sub button1_Click(ByVal sender As Object, _ $ N. Z' _: ]+ K5 {5 F: f' C
ByVal e As EventArgs) Handles button1.Click ) @( x' u+ O' G" z5 h
' v) l, O9 K9 C$ }- r' Get a handle to the Calculator application. The window class
4 U4 C% Y, W( j! I' and window name were obtained using the Spy++ tool. 1 o2 v9 r+ E" \ q( L+ @
Dim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") . M; r% w2 \& V! V% {0 R- U6 e
6 k ]. v0 i* I x) H8 v; R+ t
' Verify that Calculator is a running process.
: j. K9 [: N8 P" ? V* E+ e* v# MIf calculatorHandle = IntPtr.Zero Then
: s6 H( e7 O- y3 }7 K% Z9 SMsgBox("Calculator is not running.")
8 W. D$ u7 \/ x2 l3 oReturn
- b! W0 Z: M2 ~, V% oEnd If
! `- n9 g: [$ p8 z5 C* `* l7 \
9 |3 a; [* y6 J4 [" W4 z[ 本帖最后由 zhaojianhong 于 2009-7-8 11:26 编辑 ] |
评分
-
查看全部评分
|