惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
LangChain Blog
WordPress大学
WordPress大学
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
MyScale Blog
MyScale Blog
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
P
Proofpoint News Feed
D
DataBreaches.Net

博客园 - gyhanonline

Function Point in Vbscript Simulate click event using widows API. Static Constructor A Go Set program A Go Set program About Inherit Code for Inter-process communicate Integrity Level Test for publish blog by word 2007 托管为什么安全 The usage of intellisense in Vs .net 2005 我的面试(七) 关于singlton的一些问题 我的面试(六) 我的面试(五) 我的面试(四)补充1 我的面试(四) 我的面试(三) 我的面试(二)
Window API in QTP
gyhanonline · 2010-05-01 · via 博客园 - gyhanonline

In my previous post, I talk about How to use windows API send click message to an “ok” button of IE alert dialog. The code used c#. I’d like to transmit them to QTP. It’ll more stable and efficient than QTP built-in Function.

In QTP, if we want to do some action on a dialog, we should add a dialog object to repository.QTP can use their properties to find the dialog then execute command. But the problem is that some dialog’s properties are dynamic. Such as the title of Download Dialog.It lead to QTP couldn’t find exactly object. That’s why our automation script sometimes is slow and broken.

To avoid these tricky, QTP provide us external object. It can be used to call external function. Windows API is good experience. We can use Windows API in QTP. It’s terrific, right? We can using API do everything efficiently.

Following is the script segment to click “OK” button of IE pop dialog.

extern.Declare micHwnd,"FindWindowEx", "user32.dll","FindWindowEx",micHwnd,micHwnd,micString,micString

extern.Declare micLong, "PostMessage", "user32.dll", "PostMessageA", micHwnd, micLong, micLong, micLong

extern.Declare micHwnd,"SetActiveWindow","user32.dll","SetActiveWindow",micHwnd

extern.Declare micInteger,"SetForegroundWindow","user32.dll","SetForegroundWindow",micHwnd

hwndP = extern.FindWindowEx (0,0,"#32770", null)

hwndButton = extern.FindWindowEx (hwndP,0,"Button","OK")

extern.SetForegroundWindow hwndP

extern.SetActiveWindow hwndP

extern.PostMessage hwndButton,&H0F5,0,0

Enjoy QTP; enjoy your auto-life!