Gui Add, ActiveX, w400 h225 vWB, Shell.Explorer
URL := certain url
WB.Navigate(URL)
ComObjConnect(
Gui Show,
我几乎不了解com,并试图通过网络搜索任何有用的信息。据我所知,上面显示的Explorer可以通过com进行控制。因此,我试图找到一种方法来检索显示的文本,而不是其中的源代码。我想一定有办法,但对我来说很难。希望有人能给我一个建议或解决方案。
我倾向于使用PowerShell来了解如何在使用Auto热键执行涉及COM对象的操作。
示例:
$ie = New-Object -ComObject InternetExplorer.Application
# Show the available members of the object
$ie | gm
$ie.Visible = $true
$ie.Navigate("www.google.com")
# This should show you all you can do on the document object
$ie.Document | gm
也就是说GUI中的ActiveX控件不是"InternetExplorer"。应用程序,所以它有点不同。你可以用类似的东西打开同一类型https://adminscache.wordpress.com/2013/05/22/open-web-browser-in-powershell-gui/.
无论如何,这里有一个工作的例子,它花了我很长时间!
; https://autohotkey.com/board/topic/93660-embedded-ie-shellexplorer-render-issues-fix-force-it-to-use-a-newer-render-engine/
FixIE(Version=0, ExeName="")
{
static Key := "SoftwareMicrosoftInternet Explorer"
. "MAINFeatureControlFEATURE_BROWSER_EMULATION"
, Versions := {7:7000, 8:8888, 9:9999, 10:10001, 11:11001}
if Versions.HasKey(Version)
Version := Versions[Version]
if !ExeName
{
if A_IsCompiled
ExeName := A_ScriptName
else
SplitPath, A_AhkPath, ExeName
}
RegRead, PreviousValue, HKCU, %Key%, %ExeName%
if (Version = "")
RegDelete, HKCU, %Key%, %ExeName%
else
RegWrite, REG_DWORD, HKCU, %Key%, %ExeName%, %Version%
return PreviousValue
}
FixIE()
Gui Add, ActiveX, w400 h225 vWB hwndTest, Shell.Explorer
URL := "https://en.wikipedia.org/wiki/AutoHotkey"
WB.Navigate(URL)
ComObjConnect(WB)
Gui Show,
while, WB.ReadyState < 4
Sleep, 10
jtest := "var r = document.createRange();r.selectNode(document.body);window.getSelection().removeAllRanges();window.getSelection().addRange(r);document.body.setAttribute('ahk', window.getSelection().toString().trim());window.getSelection().removeAllRanges();"
WB.document.parentwindow.execScript(jtest)
MsgBox, % WB.document.body.getAttribute("ahk")
return
GuiClose:
ExitApp
参考:https://autohotkey.com/board/topic/93660-embedded-ie-shellexplorer-render-issues-fix-force-it-to-use-a-newer-render-engine/
关键是使用JavaScript获取文本,获取特定元素的文本会更容易,只需使用getElementById或类似的东西。