QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

查看: 1810|回复: 0
收起左侧

[分享] SetForegroundWindow

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

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

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

x
Get a handle to an application window.
: L7 |" p7 r$ D* wDeclare Auto Function FindWindow Lib "USER32.DLL" ( _ 0 p' ?8 ^- A, E4 M) ?" r
ByVal lpClassName As String, _ / r# [1 h& {9 }9 d7 G. o; \
ByVal lpWindowName As String) As IntPtr 4 V) U6 s. Y. r# @7 D1 t: V

9 k* A% X* D0 n3 p! {1 H' Activate an application window.
: V, A9 q# l* Q3 R3 P7 nDeclare Auto Function SetForegroundWindow Lib "USER32.DLL" _ 6 {8 |5 V0 V6 C; I
(ByVal hWnd As IntPtr) As Boolean
- B+ u2 {5 W: O, w4 }+ Y4 j
7 W6 D* W/ N% Q! B/ a3 V/ Z3 \' Send a series of key presses to the Calculator application.
* @# x  |& ~1 g/ DPrivate Sub button1_Click(ByVal sender As Object, _ 0 I3 U/ F# X% t' U5 e+ o
ByVal e As EventArgs) Handles button1.Click + A3 R- U% L1 x
1 L1 H8 t9 f# T8 y9 s  c- x) r) b. N2 c
' Get a handle to the Calculator application. The window class - Q, }/ L7 J: {* E9 g' }& W* l
' and window name were obtained using the Spy++ tool.
: W! K& K; ^$ A* cDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") ) R5 \0 \6 f7 ^7 l- D& |* l+ q  w
0 d; I9 Q/ Z7 d1 X2 h
' Verify that Calculator is a running process. : x7 j# f, M( l8 Q4 i2 \# z8 H: j+ K
If calculatorHandle = IntPtr.Zero Then
5 \" }, o: J$ I" @' D0 _; gMsgBox("Calculator is not running.") # n  z- `% [/ U: t: w
Return 9 G4 s+ H" ~4 y& i6 X) D/ x/ Y
End If

" b; k$ M& w) p/ L
0 A* [; g" F0 P4 H7 F2 G[ 本帖最后由 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 )

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