_iecreate创建得到的项目$oie如何取得其对应的进程id? [已解决]
本帖最后由 kevinch 于 2011-12-20 19:01 编辑如我用ie.au3函数_iecreate创建浏览页面#include <ie.au3>
$oie=_IECreate("http://www.autoitx.com/forum-4-1.html",1,1,1,0)
MsgBox(0,"",IsHWnd($oie)&@tab&ObjName($oie))所得到的$oie项目,如何才能取得其对应的进程ID呢?或者是其父进程的ID?望高手指教。 $oie只是一个文档对象,进程还是ie进程 我想获取pid,比如我不是用ie打开的,而是第三方浏览器,如何取得这个浏览器程序的pid呢? 继续寻找解决办法
#include <ie.au3>
#include <winapi.au3>
$oie=_IECreate("http://www.autoitx.com/forum-4-1.html");,1,1,1,0)
Local $iProcessId,$iThreadid
$iThreadid = _WinAPI_GetWindowThreadProcessId($oie.hwnd,$iProcessId)
MsgBox(0,0,$iProcessId)
ceoguang 发表于 2011-12-18 18:26 http://www.autoitx.com/images/common/back.gif
感谢出手相助!
在引用$oie.hwnd时出错,不知是否版本不同的原因,我现在用的是3.3.6.1 应该与版本无关
因为对象成员是存在的
如果出错,请调用 objevent 来获取得错误信息 err.description is:
err.windescription: 未指定的错误
err.number is: 80020009
err.lastdllerror is: 0
err.scriptline is: 7
err.source is:
err.helpfile is:
err.helpcontext is: 0有用的信息似乎不多 #include <ie.au3>
#include <winapi.au3>
$oie=_IECreate("http://www.autoitx.com/forum-4-1.html");,1,1,1,0)
Local $iProcessId,$iThreadid
$iThreadid = _WinAPI_GetWindowThreadProcessId($oie.hwnd(),$iProcessId)
MsgBox(0,0,$iProcessId)http://msdn.microsoft.com/en-us/library/aa752126(v=VS.85).aspx http://msdn.microsoft.com/en-us/library/aa752126(v=VS.85).aspx
ceoguang 发表于 2011-12-18 20:49 http://www.autoitx.com/images/common/back.gif#include <ie.au3>
#include <winapi.au3>
Global $oMyError,$g_eventerror = 0
$oie=_IECreate("http://www.autoitx.com/forum-4-1.html",1,1,1,0)
$oMyError=ObjEvent("AutoIt.Error","MyErrFunc")
MsgBox(0,"",$oie.document.body.innertext)
Local $iProcessId,$iThreadid
$iThreadid = _WinAPI_GetWindowThreadProcessId($oie.hwnd,$iProcessId)
MsgBox(0,0,$iProcessId)
Func MyErrFunc()
ConsoleWrite("We intercepted a COM Error !" & @CRLF& @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & hex($oMyError.number,8)& @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext & @CRLF _
)
Local $err = $oMyError.number
If $err = 0 Then $err = -1
$g_eventerror = $err; to check for after this function returns
Endfunc我试了其他属性可以,这个hwnd一直不行,好奇怪 #include <ie.au3>
Global $oMyError,$g_eventerror = 0
$oie=_IECreate("http://www.autoitx.com/forum-4-1.html",1,1,1,0)
$oMyError=ObjEvent("AutoIt.Error","MyErrFunc")
$arr=stringsplit($oie.fullname,"\")
MsgBox(0,0,ProcessExists($arr))
Func MyErrFunc()
ConsoleWrite("We intercepted a COM Error !" & @CRLF& @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & hex($oMyError.number,8)& @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext & @CRLF _
)
Local $err = $oMyError.number
If $err = 0 Then $err = -1
$g_eventerror = $err; to check for after this function returns
Endfunc暂时这样解决了,不过如果存在多个相同进程的话,不知道要如何解决啦 都是高手,观看给位表演! $oie=_IECreate("http://www.autoitx.com/forum-4-1.html")
等待IE加载完成即可
注意_IECreate的参数
5#及9#的代码都是没有问题的 我用的是世界之窗浏览器,不知是否这个的原因,hwnd始终报错 #include <IE.au3>
$oIE = _IECreate('www.baidu.com')
$Hwnd = _IEPropertyGet($oIE, 'hwnd')
MsgBox(0,'进程PID',WinGetProcess($Hwnd))
页:
[1]
2