QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

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

[分享] SetForegroundWindow

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

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

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

x
Get a handle to an application window. : V. ]% h4 w/ @% l6 t- {
Declare Auto Function FindWindow Lib "USER32.DLL" ( _ 3 r3 ^% R6 x5 P7 `) P
ByVal lpClassName As String, _ % e3 ?1 Y& y- a7 `
ByVal lpWindowName As String) As IntPtr
% t/ j, G# }! C- U( x$ `0 @" g' h) a
' Activate an application window.
7 ?) c6 m, F5 b( g  V" xDeclare Auto Function SetForegroundWindow Lib "USER32.DLL" _
" L6 ]) `- @, P/ \(ByVal hWnd As IntPtr) As Boolean 0 V+ C1 z4 B% b' v7 F
: J- F2 p8 Q: \- v/ b
' Send a series of key presses to the Calculator application. 9 E* M  {" i- o
Private Sub button1_Click(ByVal sender As Object, _
& j; S3 p0 X- GByVal e As EventArgs) Handles button1.Click
# L3 j1 O( B* F* C5 u4 u. P) t
# |. F; s) g9 y5 F7 }' Get a handle to the Calculator application. The window class   I& V0 I( L- d
' and window name were obtained using the Spy++ tool.
5 U7 _2 W" P/ J  DDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") ! d& Q. `% d3 `! N% y. K

) P: {# V; |# V) Z4 s) B4 }" Q' Verify that Calculator is a running process.
& t- z; m' i0 L' u# tIf calculatorHandle = IntPtr.Zero Then # d: i1 W  f: _/ h6 k! S: D  D
MsgBox("Calculator is not running.") ' Z2 W7 q% ?; h$ U% F
Return $ }# g2 W/ c, J; H$ M
End If

3 }1 Z, E* N9 n. v/ ]
6 s2 M! M. z3 H2 ^' P[ 本帖最后由 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 )

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