我想让我的脚本检查,如果在Google Chrome中打开或不打开特定标签,例如“https://stackoverflow.com/”。
我知道如何检查浏览器是否运行,但我不确定,是否可以检查特定选项卡是否打开。
有人有想法,我怎么能意识到这一点?
答案 0 :(得分:1)
排序..
首先,您需要OpenList扩展名为chrome。然后您需要snedkeys.bat。这是与snedKeys.bat在同一目录中的脚本。它将列出chrome中所有打开的链接:
@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过滤结果,以检查所需的链接是否已打开。
E.g。这将检查stackoverflow是否已打开:
@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 "stackoverflow" >nul 2>&1 && (
echo stackoverflow is open
)
)
call sendKeys.bat "" "^w"
答案 1 :(得分:0)
是:
tasklist /V | find /i "chrome"
将显示具有焦点的打开标签的标题。