如何在不使 Internet Explorer 可见的情况下实现自动化



My AutoIt脚本执行Google搜索查询。对于每一个货币,它都会拉出美元与另一种货币的兑换率。它显示Internet Explorer,我不希望它显示。

代码如下:

#include <Constants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIEdit.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <array.au3>
#include <String.au3>
#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "https://www.google.com/search?q=convert+us+dollars+to+euros")
$aText = _IEBodyReadText($oIE)
If StringInStr($aText, "equals") Then
    $num_pos = StringInStr($aText, "equals")
    $one_num = StringMid($aText, ($num_pos + 10), 4)
EndIf
_IENavigate($oIE, "https://www.google.com/search?q=convert+us+dollars+to+japanese+yen")
$aText = _IEBodyReadText($oIE)
If StringInStr($aText, "equals") Then
    $num_pos = StringInStr($aText, "equals")
    $two_num = StringMid($aText, ($num_pos + 10), 6)
EndIf
_IENavigate($oIE, "https://www.google.com/search?q=convert+us+dollars+to+british+pounds")
$aText = _IEBodyReadText($oIE)
If StringInStr($aText, "equals") Then
    $num_pos = StringInStr($aText, "equals")
    $three_num = StringMid($aText, ($num_pos + 10), 4)
EndIf
_IENavigate($oIE, "https://www.google.com/search?q=convert+us+dollars+to+aruban+florins")
$aText = _IEBodyReadText($oIE)
If StringInStr($aText, "equals") Then
    $num_pos = StringInStr($aText, "equals")
    $four_num = StringMid($aText, ($num_pos + 10), 4)
EndIf
$res_string = $one_num & "+" & $two_num & "+" & $three_num & "+" & $four_num
MsgBox($MB_OK, "Here are the results", $res_string)

...没有 Internet Explorer 可见。

根据文档 - 用户定义的函数参考 - _IECreate()

$iVisible [可选] 指定浏览器窗口是否可见
0 = 浏览器窗口隐藏
1 =(默认(浏览器窗口可见

例:

#include <IE.au3>
Global Const $g_sUrl     = 'https://stackoverflow.com/'
Global Const $g_iAttach  = 0
Global Const $g_iVisible = 0
Global Const $g_iWait    = 1
Global Const $g_iFocus   = 0
Global       $g_oIE      = _IECreate($g_sUrl, $g_iAttach, $g_iVisible, $g_iWait, $g_iFocus)
Global       $g_sPage    = _IEBodyReadText($g_oIE) & @CRLF
ConsoleWrite($g_sPage)
_IEQuit($g_oIE)

相关内容

  • 没有找到相关文章

最新更新