QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

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

[分享] SetForegroundWindow

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

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

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

x
Get a handle to an application window.
& H5 @7 {  q& ^Declare Auto Function FindWindow Lib "USER32.DLL" ( _
% v! Y/ h1 _( w3 l2 R0 XByVal lpClassName As String, _
- d9 L' ?$ B$ I6 A6 uByVal lpWindowName As String) As IntPtr + N% l6 R" c' Q6 k) H  X, m+ Q9 @
0 s9 p5 m3 C, }
' Activate an application window. 9 @: q9 z7 U0 n& ?- Q2 M! D3 Q: ^  T/ }. X
Declare Auto Function SetForegroundWindow Lib "USER32.DLL" _
  @  K: p, l9 n" L/ T, i(ByVal hWnd As IntPtr) As Boolean 6 x* c; b' ?8 v7 Z% K
+ K/ _7 i$ F  ~2 y7 n9 V
' Send a series of key presses to the Calculator application.
$ j* j6 y1 O( R" E# x& gPrivate Sub button1_Click(ByVal sender As Object, _
  F8 @5 ?. B. W& Z. Q: X) G8 f3 V" vByVal e As EventArgs) Handles button1.Click
* ]2 d+ {, t1 n$ |4 a+ h6 b
2 I3 V! ~8 L# e1 a, L2 w; o3 T$ q' Get a handle to the Calculator application. The window class % O/ V, ~- w! x. I3 O
' and window name were obtained using the Spy++ tool.
$ v7 ]6 [% g' |* }; nDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") & L2 E& U- |4 Z* `6 i
+ D' b$ O: M) L$ o
' Verify that Calculator is a running process.
% }8 x# _; V4 a- O# A0 c7 N1 @If calculatorHandle = IntPtr.Zero Then / j7 f" t2 S+ e
MsgBox("Calculator is not running.")
( H. p5 @, s# SReturn
. [' y! U- T$ X6 \9 k, n; @End If

  u* P  |: l1 d( m# Y& S- B8 y  P9 H" j
[ 本帖最后由 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 )

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