批处理文件检测特定选项卡是否打开?

Batch file detect if specific tab is open?

我想让我的脚本检查 google chrome 中的特定选项卡是否打开,例如“https://whosebug.com/”。

我知道如何检查浏览器是否运行,但我不确定是否可以在特定选项卡打开时检查它。

有人有想法吗,我怎么能实现这个?

有点……

首先你需要OpenList extension for chrome.Then you need snedkeys.bat。这是与 snedKeys.bat.It 相同目录中的脚本,将列出 chrome 中所有打开的 link:

@echo off

start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "chrome-extension://nkpjembldfckmdchbdiclhfedcngbgnl/popup.html?focusHack"

::sleeps for 5 seconds
w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:5  >nul 2>&1

::call sendKeys.bat ""  "^A"

::w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:5  >nul 2>&1

call sendKeys.bat ""  "^c"

w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:5  >nul 2>&1

for /f "usebackq tokens=* delims=" %%i in (
   `mshta "javascript:Code(close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(clipboardData.getData('Text'))));"`
) do (
 echo cntent of the clipboard:
 echo "%%i"
)

您可以使用 FINDSTR 或 FIND 筛选结果以检查是否需要 link 已打开。

例如这将检查 Whosebug 是否打开:

@echo off

start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "chrome-extension://nkpjembldfckmdchbdiclhfedcngbgnl/popup.html?focusHack"

::sleeps for 5 seconds
w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:5  >nul 2>&1

call sendKeys.bat ""  "^c"

for /f "usebackq tokens=* delims=" %%i in (
   `mshta "javascript:Code(close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(clipboardData.getData('Text'))));"`
) do (
 echo "%%i"| find "Whosebug" >nul 2>&1 && (
    echo Whosebug is open
 )
)

call sendKeys.bat ""  "^w"

是:

tasklist /V | find /i "chrome"

将显示具有焦点的打开选项卡的标题。