QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

全站
8天前
查看: 1803|回复: 0
收起左侧

[分享] SetForegroundWindow

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

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

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

x
Get a handle to an application window. 9 {& g4 |1 X! b! a
Declare Auto Function FindWindow Lib "USER32.DLL" ( _
( z+ h5 S1 U$ v+ _& _$ lByVal lpClassName As String, _ ! `% r/ ?4 k% ]4 h. z) P3 V( m
ByVal lpWindowName As String) As IntPtr * S/ G4 W, i$ z' A" {
# R* m6 a9 D7 H. `' I0 u' y
' Activate an application window.
5 w) _) ?# e2 }Declare Auto Function SetForegroundWindow Lib "USER32.DLL" _
2 o' @& V1 }, p# z% p(ByVal hWnd As IntPtr) As Boolean
( Q) U. l, {8 C+ [* K# W. b; L) n% q  J5 U
' Send a series of key presses to the Calculator application.
$ T& P% ]  X: ~2 n$ ]9 d7 M! R4 RPrivate Sub button1_Click(ByVal sender As Object, _
9 J1 ]) s! }; F' tByVal e As EventArgs) Handles button1.Click / G. r# g! O% q+ A0 t9 n; w

7 w5 t, G  U3 l+ z* {0 V, V' Get a handle to the Calculator application. The window class
* `: J# x1 y" b% f" u0 P' and window name were obtained using the Spy++ tool. 5 @/ t2 a* `) `' n7 `; c
Dim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") 9 M$ n) j7 B! K' \6 F

) n, H6 ]+ _* d  t* ]; Z, ?' Verify that Calculator is a running process.
& i; c! g2 U4 w3 ^' f' @0 i: aIf calculatorHandle = IntPtr.Zero Then . g3 O2 W% A- X# z% q
MsgBox("Calculator is not running.")
% R% y" n6 v1 X3 V9 xReturn 3 t; u4 M0 M7 E- a
End If

# ]& x5 e3 z$ C5 S
# N& d$ ], [1 e3 V[ 本帖最后由 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 )

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