你好,请问在PB中如何判断run()函数执行完毕呢?该怎么操作?

现在我在PB 中调用了RUN()函数
但是不知道如何判断run()函数是否执行完毕!
在网上查了一下说要定义外部函数:
function long findwindowa (string lpclassname , string lpwindowname ) library "user32.dll"
function boolean iswindow (long hwnd ) library "user32.dll" 这两个要如何定义!请帮助!

慕桂英546537
浏览 661回答 2
2回答

摇曳的蔷薇

PB自己的函数做不到的不要找了,只能看返回值是1就成功,想别的方法吧非要找的话就找找APT函数,判断那些烦人的句柄吧

MM们

在PB中常常需要运行一些外部的程序或命令,并等待其执行完成后,才接下来运行剩余的代码。我们可以有两种方法:  先定义全局外部函数:  Function long ShellExecuteA (long hwnd, string lpOperation ,String lpFile, String lpParameters, String lpDirectory, Long nShowCmd) Library "shell32.dll"  Function long FindWindowA (String lpClassName , String lpWindowName ) Library "user32.dll"  Function boolean IsWindow (Long hwnd ) Library "user32.dll"  第一种方式用Run() 函数,可在窗口上建立按扭,clicked事件中包含如下Script:  ulong ll_handle  int li_loop  SetPointer(HourGlass!)  //最小化执行xxx.bat  run("xxx.bat", Minimized!)  //循环到窗口打开,根据程序执行打开所需的时间设定li_loop的循环次数,可预留长一些。  for li_loop= 1 to 10000  ll_handle = FindWindowA("tty","xxx")  yield()  if ll_handle $#@60;$#@62; 0 then  exit  end if  next  //一直循环到窗口关闭  Do While isWindow(ll_handle)  Yield()  Loop  //应用执行完成  messagebox(‘ok’, ‘执行完成!’)  这种方法的缺点是不能隐藏外部应用程序窗口,只能最小化。  第二种方式用API函数,可以隐藏应用程序的窗口,但是调用bat批处理命令时需要先建立一个PIF文件指定执行完成后关闭窗口,否则窗口不会自行关闭。可在窗口上建立按扭,clicked事件中包含如下Script:  uint lu_return  ulong ll_handle  int li_loop  string ls_Path  SetPointer(HourGlass!)  lu_return = ShellExecutea(handle(parent), "open", "xxx.pif", "", ls_path, 0)  //最后一个参数改为 4,可以显示执行情况  if lu_return $#@62; 32 then  for li_loop= 1 to 10000  ll_handle = FindWindowA("tty","xxx")  yield()  if ll_handle $#@60;$#@62; 0 then  exit  end if  next  //一直循环到窗口关闭  Do While isWindow(lu_handle)  Yield()  Loop  //应用执行完成  Messag x("ok", "执行完成!")  Else  //error  messagebox("错误", "调用外部应用程序不成功,请检查应用程序路径!")  end if
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL
MongoDB