QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

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

[分享] SetForegroundWindow

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

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

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

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

评分

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

查看全部评分

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

本版积分规则


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

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

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