加了延迟后没办法关掉IE进程!(已解决)
本帖最后由 xiaosu 于 2010-5-19 14:55 编辑延迟1000毫秒以后就没办法关掉。不过300毫秒的时候就会关闭IE了。代码如下。那位大虾帮忙看看
FileWrite("C:\Documents and Settings\Administrator\桌面\脚本\wglm.net.txt","wglm.net.asd")
FileMove("C:\Documents and Settings\Administrator\桌面\脚本\wglm.net.txt","C:\Documents and Settings\Administrator\桌面\脚本\bbs.wglm.net.txt",1)
RunWait("C:\Program Files\Internet Explorer\iexplore")
Sleep(500)
ProcessExists("IEXPLORE.exe")
ProcessClose("IEXPLORE.exe") 那就不是延迟的事。是runwait的事。。你查下这个函数的说明。
运行一个外部程序并暂停脚本的执行直至该程序执行完毕.
看懂了没??? 直到外部程序结束才继续。。
你的代码应该改为:FileWrite("C:\Documents and Settings\Administrator\桌面\脚本\wglm.net.txt","wglm.net.asd")
FileMove("C:\Documents and Settings\Administrator\桌面\脚本\wglm.net.txt","C:\Documents and Settings\Administrator\桌面\脚本\bbs.wglm.net.txt",1)
Run("C:\Program Files\Internet Explorer\iexplore.exe")
Sleep(500)
If ProcessExists("IEXPLORE.exe") Then ProcessClose("IEXPLORE.exe") 哦。。谢谢啊。。
要是在加上打开浏览器后。。让他自动输入一个网址的代码要怎么写呢??? FileWrite("C:\Program Files\Internet Explorer\iexplore.exe","bbs.wglm.net")我是这么写。。但是他只是打开IE。。没完成输入 和明显楼主用Filewrite就大错特错了.
看列子!; *******************************************************
; Example 1 - Create a browser window and navigate to a website
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("www.autoitscript.com")
; *******************************************************
; Example 2 - Create new browser windows pointing to each of 3 different URLs
; if one does not already exist ($f_tryAttach = 1)
; do not wait for the page loads to complete ($f_wait = 0)
; *******************************************************
;
#include <IE.au3>
_IECreate ("www.autoitscript.com", 1, 1, 0)
_IECreate ("my.yahoo.com", 1, 1, 0)
_IECreate ("www.google.com", 1, 1, 0)
; *******************************************************
; Example 3 - Attempt to attach to an existing browser displaying a particular website URL
; Create a new browser and navigate to that site if one does not already exist
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("www.autoitscript.com", 1)
; Check @extended return value to see if attach was successful
If @extended Then
MsgBox(0, "", "Attached to Existing Browser")
Else
MsgBox(0, "", "Created New Browser")
EndIf
; *******************************************************
; Example 4 - Create an empty browser window and populate it with custom HTML
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ()
$sHTML = "<h1>Hello World!</h1>"
_IEBodyWriteHTML ($oIE, $sHTML)
; *******************************************************
; Example 5 - Create an invisible browser window, navigate to a website,
; retrieve some information and Quit
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://sourceforge.net", 0, 0)
; Display the innerText on an element on the page with a name of "sfmarquee"
$oMarquee = _IEGetObjByName ($oIE, "sfmarquee")
MsgBox(0, "SourceForge Information", $oMarquee.innerText)
_IEQuit ($oIE)
; *******************************************************
; Example 6 - Create a browser window attached to a new instance of iexplore.exe
; This is often necessary in order to get a new session cookie context
; (session cookies are shared among all browser instances sharing the same iexplore.exe)
; *******************************************************
;
#include <IE.au3>
ShellExecute ("iexplore.exe", "about:blank")
WinWait ("Blank Page")
$oIE = _IEAttach ("about:blank", "url")
_IELoadWait ($oIE)
_IENavigate ($oIE, "www.autoitscript.com") 感谢kemyliu和lanfengc 。都解决了我的难题。。
kemtliu6个例子是每个运行的都不同。。
也直接解决了我后面的问题。。
感谢:face (23):
页:
[1]