想用PB通过API实现一个较复杂的功能

zhouliweizhouliwei 2012-05-22 05:35:33
用PB把二代身份信息读出来后,如想把姓名,身份证号码发送(或叫自动填充)到另一应用程序的姓名、身份证号码录入文本框内。注:无数据库接口。baidu查了好久,只能用通过api获取应用窗口句柄,找到控件ID,用SendMessage完成。本人对AP编程还不懂。求助有过类似开发的高手给点支持。
...全文
780 17 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouliweizhouliwei 2012-06-05
  • 打赏
  • 举报
回复
为xufxuf结贴,必须的
zhouliweizhouliwei 2012-06-04
  • 打赏
  • 举报
回复
非常感谢xufxuf,http://download.csdn.net/download/xufxuf/4351425地址打不开?请您发个邮件给我,能加我QQ 805730908吗? 这个问题困扰我两个星期了,求职帮我远程调试下。
xufxuf 2012-06-04
  • 打赏
  • 举报
回复
遍历窗口的函数:

// ulong wf_enumchildwindows (ulong hh,integer level, string path , integer n)
// 本函数对窗口进行深度优先的遍历
// hh 窗口的句柄
// level 当前深度
// path 当前路径
// n 在兄弟窗口中排行第几
//返回 0 ,无意义。统统遍历完了返回上一层,

long ll_hh=0,ll_hh_old
long ll_len //tmpstr的可用缓冲区长度
string tmpstr
string ls_text //窗口的标题
string ls_class //窗口的类名



ll_hh=hh

tmpstr=space(256)
ll_len=len(tmpstr )- 1

GetWindowText(ll_hh,ref tmpstr,ll_len) //获得当前窗口标题到tmpstr

if isnull(tmpstr) then tmpstr='' //避免null值,免得下面拼接字符串变成null
path=path+'/'+tmpstr //拼接到路径下

ls_text=tmpstr //保留当前窗口标题到ls_text
mle_log.text=mle_log.text+'~r~n深'+string(level)+';排'+string(n)+';柄'+string(hh)+';径='+path //记录路径

tmpstr=space(256)
getclassname(ll_hh,ref tmpstr ,len(tmpstr) - 1) //获得当前窗口的类名到tmpst
if isnull(tmpstr) then tmpstr='' //避免null
ls_class=tmpstr //保留当前窗口的类名到ls_class
mle_log.text=mle_log.text+';类='+tmpstr //路径后再记录当前窗口的类名


//按照一定特征,辨别是否是需要的句柄。
//找“查询”按钮


ll_hh=GetWindow(hh,5) //获得hh的子窗口
n=1 //第一个子窗口,当然是排行第一
do while ll_hh<>0 //找到了子窗口
ll_hh_old=ll_hh //备份找到的子窗口句柄

wf_enumchildwindows(ll_hh,level + 1,path,n) //继续遍历该子窗口,深度+1,路径带进去,排行也带进去

ll_hh=GetWindow(ll_hh,2) //获得兄弟窗口。前面那个字窗口遍历完毕了,退出了,就换它弟弟。
if ll_hh_old = ll_hh then ll_hh=0 //如果找到的还是前一个子窗口,那么说明它没弟弟了,那么就退出。
n++ //排行加1
loop

return(0)

xufxuf 2012-06-04
  • 打赏
  • 举报
回复
其实我的帖子已经说得很清楚了
xufxuf 2012-06-04
  • 打赏
  • 举报
回复
是不是就是这个: http://download.csdn.net/download/xufxuf/4351425
zhouliweizhouliwei 2012-06-03
  • 打赏
  • 举报
回复
不吝赐教,给个完整的代码吧!!!
xufxuf 2012-05-27
  • 打赏
  • 举报
回复
像个外挂程序嘛。
1、用API函数FindWindow找到主窗口:

ls_windowtext='被外挂程序窗口标题'
handle = FindWindowA(0,ref ls_windowtext)

2、通过API函数GetWindow()和一个递归的程序对该主窗口下全部控件进行全遍历搜索。

深度优先的遍历函数f_find():
...对当前控件是否是所要找的控件做判断,是,则做所要做的事情,然后return;否,则继续。
ll_hh=GetWindow(hh,5) //获得子窗口
do while ll_hh<>0
f_find(ll_hh)
ll_hh=GetWindow(ll_hh,2) //获得兄弟窗口
...
loop

3、只要找到所要的控件句柄,则可用PB的send函数
send(ll_hh,258,65,0) 可向对方控件发送一个字符A 。
模拟一个鼠标左键click,可以用
send(ll_hh,513,0,0)
send(ll_hh,513,0,0)
send(ll_hh,514,0,0)


pbwubaba 2012-05-26
  • 打赏
  • 举报
回复
这种还是用C去写比较容易哦
感觉用PB调用API不怎么好
zhouliweizhouliwei 2012-05-24
  • 打赏
  • 举报
回复
加到100分看有没好消息
zhouliweizhouliwei 2012-05-23
  • 打赏
  • 举报
回复
另一应用程序是别人写的。
zhouliweizhouliwei 2012-05-23
  • 打赏
  • 举报
回复
求sbigwolf(老郎) ,给个调用顺利或实例,万分感激。。。
路人甲cw 2012-05-22
  • 打赏
  • 举报
回复
你指的另一个应用程序是自己开发还是别人的?
sbigwolf 2012-05-22
  • 打赏
  • 举报
回复
小儿科的东西。//关于windows窗口操作的api
//根据进程获得程序的主窗口
Function ulong GetProcessWindow_local(ulong processid) Library "user32.dll" alias for "GetProcessWindow"
//根据窗口获得进程
SUBROUTINE GetWindowThreadProcessId_local(ulong hwnd, ref ulong pid) Library "user32.dll" alias for "GetWindowThreadProcessId"
Function ulong FindWindowA_local(String lpClassName,String lpWindowName) Library "user32.dll" alias for "FindWindowA"
Function Long SetWindowPos_local(Long hwnd, Long ord, Long px, Long py, Long dx, Long dy, Long uflag) Library "user32.dll" alias for "SetWindowPos"
Function int GetClassName_local(ulong hWnd, ref string lpClassName, int nMaxCount) library "user32" alias for "GetClassNameA"
function long GetWindowText_local(long hwnd, ref string lpString, long nMaxCount) library "user32" alias for "GetWindowTextA"
function long SetWindowText_local(long hwnd, string lpString ) library "user32" alias for "SetWindowTextA"
Function ulong FindWindow_Handle_local(ulong lpClassName,String lpWindowName) Library "user32.dll" alias for "FindWindowW"
Function ulong FindWindowEx_local(ulong hWnd1 , ulong hWnd2 , String lpClassName , String lpsz2 ) Library "user32" Alias for "FindWindowExA"
Function Ulong FindWindowByWindowName_local(String lp_WindowName ) Library "user32" Alias for "FindWindowByWindowNameA"
function ulong GetWindow_local(ulong hwindow,int nrelationship) library "user32.dll " alias for "GetWindow"
//将窗口恢复到原来的位置
SUBROUTINE SwitchToThisWindow_local(Long hWnd,boolean fAltTab ) Library "user32.dll" alias for "SwitchToThisWindow"
//获得指定的窗口
Function ulong GetWindow_local(ulong hWd,ulong ul_wm_message) Library "user32.dll" alias for "GetWindow"
FUNCTION ulong lstrcat_local(ref string lpString1,ref string lpString2) LIBRARY "kernel32.dll" ALIAS FOR "lstrcatA"
FUNCTION ulong lstrcmp_local(ref string lpString1,ref string lpString2) LIBRARY "kernel32.dll" ALIAS FOR "lstrcmpA"
FUNCTION ulong lstrcmpi_local(ref string lpString1,ref string lpString2) LIBRARY "kernel32.dll" ALIAS FOR "lstrcmpiA"
FUNCTION ulong lstrcpy_local(ref string lpString1,ref string lpString2) LIBRARY "kernel32.dll" ALIAS FOR "lstrcpyA"
FUNCTION ulong lstrcpyn_local(ref string lpString1,ref string lpString2,ulong iMaxLength) LIBRARY "kernel32.dll" ALIAS FOR "lstrcpynA"
FUNCTION ulong lstrlen_local(ref string lpString) LIBRARY "kernel32.dll" ALIAS FOR "lstrlenA"
Function long StrCopy_local(long Destination, REF string Source, long Size) library "kernel32.dll" Alias for "RtlMoveMemory"
Function long LocalAlloc_local(long Flags, long Bytes) library "kernel32.dll" alias for "GetProcessWindow"
Function long LocalFree_local(long MemHandle) library "kernel32.dll"
FUNCTION ulong MapVirtualKeyA_local(UINT uCode, UINT uMapType) Library "user32.dll" alias for "MapVirtualKeyA"
//剪贴版得函数
FUNCTION boolean OpenClipboard_local( UINT hWndNewOwner) Library "user32.dll" alias for "OpenClipboard"
FUNCTION boolean EmptyClipboard_local( ) Library "user32.dll" alias for "EmptyClipboard"
FUNCTION boolean CloseClipboard_local() Library "user32.dll" alias for "CloseClipboard"

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧