【问题标题】:Close chrome depending on link in address bar根据地址栏中的链接关闭 chrome
【发布时间】:2016-11-06 00:10:12
【问题描述】:

让我从我很少的脚本/编程知识开始:)

我的问题是,我在呼叫中心有一个使用投影仪的仪表板网页。该网页位于内部网络服务器上。

网页随机超时并产生错误。

当网页地址更改为错误页面时,我需要关闭 Chrome(或 Firefox),例如:从 localsite.local/page 到 localsite.local/error

我使用 Auto-IT-Au3Record 和 SciTe 来记录页面超时时的鼠标点击。

这在某些 PC 上运行良好,但不是全部。有没有我可以运行的通用脚本, 所以我不必记录所有 PC 上的鼠标点击。

当前工作脚本

#Region v3.3.9.5 KeyboardLayout=00000809
Func _Au3RecordSetup() 
    Opt('WinWaitDelay',100)
    Opt('WinDetectHiddenText',1)
    Opt('MouseCoordMode',0)

    Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '')

    If $aResult[1] <> '00000809' Then
        MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000809->' & $aResult[1] & ')')
    EndIf
EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc

_AU3RecordSetup()

_WinWaitActivate("Website.com/site/Main_Dash_Reporting.aspx - Google Chrome","")
MouseClick("left",1342,14,1)

_WinWaitActivate("Program Manager","")
MouseClick("left",282,746,1)

_WinWaitActivate("Website.com/site/Dash_Viewer.aspx?DashID=5200&RevNum=null - Google Chrome","")
MouseMove(702,311)
MouseDown("left")
MouseMove(707,310)
MouseUp("left")
#EndRegion

【问题讨论】:

  • 它怎么不工作(在某些 PC 上)?可能是不同的屏幕分辨率? (注意:使用“primary”而不是“left”也适用于左撇子用户)如果可能,请摆脱任何鼠标仿真。 Windows 可以(几乎)完全通过按键操作。
  • 它似乎在 Windows 7 上工作,但在 Windows 8.1 上不太好。生病再试一次键击。但我希望 Universal strict 能够全面发挥作用

标签: google-chrome batch-file scripting autoit


【解决方案1】:

Internet Explorer 是程序员的工具。

Set objShell = CreateObject("Shell.Application")
Set AllWindows = objShell.Windows
For Each window in AllWindows
    msgbox window.locationname
    If window.locationname="Scripts" then window.quit
Next

这是一个 vbscript。由于历史原因,它包括 Explorer 和 IE 窗口。

另一个属性是window.locationURL

【讨论】:

  • 谢谢,但我需要使用 chrome,系统设计为在 chrome 中显示。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-10
  • 2017-11-29
  • 1970-01-01
相关资源
最近更新 更多