QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

全站
9天前
查看: 1806|回复: 0
收起左侧

[分享] SetForegroundWindow

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

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

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

x
Get a handle to an application window. 8 ?8 o# x) F7 i. w; p( c1 \
Declare Auto Function FindWindow Lib "USER32.DLL" ( _ 7 h7 C  O; a, S0 y/ I& h
ByVal lpClassName As String, _
4 v3 ]$ q7 _6 N2 ?5 MByVal lpWindowName As String) As IntPtr " C: @8 U) W' R2 ?) J

0 w9 \- N9 l- U  d. A5 x' z* X9 s' Activate an application window. 2 Y2 I3 d! f0 f2 V
Declare Auto Function SetForegroundWindow Lib "USER32.DLL" _
5 R$ @) l: P, j! b; |3 {9 c& c/ L(ByVal hWnd As IntPtr) As Boolean
8 T9 ?0 k; d% s9 @7 v7 S! f2 g- w" A
' Send a series of key presses to the Calculator application.
% L2 i2 |5 f" z! T' tPrivate Sub button1_Click(ByVal sender As Object, _ : z# ~/ L0 S; A3 u) J
ByVal e As EventArgs) Handles button1.Click * n8 a, q. X* |

3 y1 _7 s- z0 T: Q% ~$ C' Get a handle to the Calculator application. The window class % r, n5 u6 I" `& a
' and window name were obtained using the Spy++ tool.
5 X+ @+ I5 w! Y" E3 Z( B- g9 LDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator")
8 t4 V8 {* v- m+ M6 d. h" C$ ?- R
' Verify that Calculator is a running process. " G% z) S6 `: `2 B% x
If calculatorHandle = IntPtr.Zero Then 6 a" V) r% T& U4 k
MsgBox("Calculator is not running.")
) |( J# {6 ]7 |; Q9 GReturn 8 d" G) f# M" R. l8 F# d: [
End If
1 v+ x0 g) R/ E' d
# x! L) h; W0 c- W
[ 本帖最后由 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 )

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