QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

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

[分享] SetForegroundWindow

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

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

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

x
Get a handle to an application window. - V3 V9 m* [: [+ m1 ]/ l# Z5 Q
Declare Auto Function FindWindow Lib "USER32.DLL" ( _
/ z0 W! d( |3 s" y( AByVal lpClassName As String, _ ) g; @0 K* [$ |8 Z5 h
ByVal lpWindowName As String) As IntPtr
% v4 a4 H) l7 U
. L9 X! k9 A0 `' Activate an application window.
# K# W" g; X7 r% m1 d* A- o, f; o6 qDeclare Auto Function SetForegroundWindow Lib "USER32.DLL" _ ) M! O, B: \4 ?
(ByVal hWnd As IntPtr) As Boolean & f. V& t# W& c) b( o
# u3 k/ m$ d( Y7 {
' Send a series of key presses to the Calculator application.
/ `( K4 Z& n) B2 x# S3 `Private Sub button1_Click(ByVal sender As Object, _
$ `1 i1 R9 T8 v' |ByVal e As EventArgs) Handles button1.Click
3 K: j8 q6 Q' s1 P& H. n0 F
) ?4 S5 ]+ `" i9 k! u7 x+ f' y' Get a handle to the Calculator application. The window class 9 G0 D( G% {4 d1 M1 p3 J3 {
' and window name were obtained using the Spy++ tool.
1 f" N7 {' n" d7 cDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") % ^1 E( E. Z% U# v8 U, D

6 z: Y0 Y! t# U. z+ i' Verify that Calculator is a running process. 8 G9 {# g: t- O1 t+ M$ x& j( z% V
If calculatorHandle = IntPtr.Zero Then % j3 f+ b: S$ G% w- S" w
MsgBox("Calculator is not running.") + A) o# H9 j3 i0 t) F
Return , T# k( e8 o% X$ {
End If

; N4 F( o: r7 V7 L$ N. E) t0 s# |  R, g+ b, ?2 s; m
[ 本帖最后由 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 )

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