QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

全站
10天前
查看: 1807|回复: 0
收起左侧

[分享] SetForegroundWindow

[复制链接]
发表于 2009-7-7 19:52:32 | 显示全部楼层 |阅读模式 来自: 中国河南鹤壁

马上注册,结识高手,享用更多资源,轻松玩转三维网社区。

您需要 登录 才可以下载或查看,没有帐号?注册

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 编辑 ]

评分

参与人数 1三维币 +10 收起 理由
hh749 + 10 好资料,感谢您对论坛的支持!

查看全部评分

发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则


Licensed Copyright © 2016-2020 http://www.3dportal.cn/ All Rights Reserved 京 ICP备13008828号

小黑屋|手机版|Archiver|三维网 ( 京ICP备2023026364号-1 )

快速回复 返回顶部 返回列表