QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

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

[分享] SetForegroundWindow

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

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

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

x
Get a handle to an application window.
! \0 h  f4 ~. m5 YDeclare Auto Function FindWindow Lib "USER32.DLL" ( _ 7 V- E% T& Y3 Q
ByVal lpClassName As String, _
! o+ Z5 J$ p8 x( ?) j7 t& X5 T0 XByVal lpWindowName As String) As IntPtr
/ z2 J' [- r* a  c7 ]6 L
3 D2 S8 X" u) }' Activate an application window.
& ?* T5 j* @5 g( a% ^Declare Auto Function SetForegroundWindow Lib "USER32.DLL" _
7 w4 @  u+ \5 }9 e& B(ByVal hWnd As IntPtr) As Boolean ! M, Q# A* L7 F& ?* m9 L+ d

. G8 {+ r: H# o0 [( J! u' Send a series of key presses to the Calculator application.
6 A, N. E* B6 D0 S$ D, O% bPrivate Sub button1_Click(ByVal sender As Object, _
3 M, s. D6 K* ]! @. j) C9 fByVal e As EventArgs) Handles button1.Click 5 L  D) g- F! `9 B; T& a

( s& x. @9 @# E7 ^' Get a handle to the Calculator application. The window class
( g$ N( T% t8 l- w9 b( V1 [' and window name were obtained using the Spy++ tool.
0 M  v' Q4 j, T3 l, E  hDim calculatorHandle As IntPtr = FindWindow("SciCalc", "Calculator")
5 ]2 O+ H* g5 O, C8 ]4 V" A; `* n
' Verify that Calculator is a running process. 2 C8 X/ }/ v7 R& w
If calculatorHandle = IntPtr.Zero Then
6 V: w! M$ Z! Q7 ~1 g1 C2 f: m; NMsgBox("Calculator is not running.") : p" T7 a8 {3 ^
Return
9 I. r0 J1 t/ o& uEnd If
/ R* {0 c4 ]- ^6 u6 ^

! _) D6 L# ?% ]: p) q3 \, O0 j8 Q[ 本帖最后由 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 )

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