QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

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

[分享] SetForegroundWindow

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

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

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

x
Get a handle to an application window. 2 u) L+ g0 R+ t) D
Declare Auto Function FindWindow Lib "USER32.DLL" ( _
' H3 l. M' y' F& u3 Y. e/ g6 d4 ZByVal lpClassName As String, _
7 }( C: s5 a& NByVal lpWindowName As String) As IntPtr
& A# R" q5 @4 M7 d5 s/ v0 w5 v& H
+ T1 q: P( ~# l7 b0 w7 a9 T' Activate an application window.
* L; K) {+ Z- P9 z9 O* IDeclare Auto Function SetForegroundWindow Lib "USER32.DLL" _ # m) N/ s! R7 `6 z6 t
(ByVal hWnd As IntPtr) As Boolean . a8 K' B- q1 R4 @; i

' @  M1 R/ z* H' ^/ B7 G: ]. ?$ [; S' Send a series of key presses to the Calculator application.
8 O8 P  I8 @! ~; \) W' g# R3 WPrivate Sub button1_Click(ByVal sender As Object, _ 5 F* G  C; ]2 ^5 s6 K) y" Z4 D
ByVal e As EventArgs) Handles button1.Click
% k) `" v; v: d6 P% z7 t7 }- a( x$ D4 m) r( _# z" Q
' Get a handle to the Calculator application. The window class
! _' e+ z; @1 Q/ v( l, d/ Z; `' and window name were obtained using the Spy++ tool.
1 ]5 x1 i. [6 _( Q& T5 dDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator") - ]- \+ c  o; d* i- p. O7 B" d

; S3 M9 M& ~" g" S/ N7 k2 R' Verify that Calculator is a running process.
8 J- ?  F! g& eIf calculatorHandle = IntPtr.Zero Then
' _: |6 D0 z- C6 F0 V* f; X4 wMsgBox("Calculator is not running.")
; e1 z( z. a% t* }# AReturn
/ d2 ~7 ^( x1 [  wEnd If

( s) a( u; A, P9 T. G7 w# A' w, S) `6 ^6 y; z
[ 本帖最后由 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 )

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