批处理文件检测特定选项卡是否打开?
我想让我的脚本检查Google chrome中是否打开了特定选项卡,例如" https://stackoverflow.com/".
I want to let my script check, if a specific tab is open or not in google chrome, for example "https://stackoverflow.com/".
我知道如何检查浏览器是否完全运行,但是不确定是否可以打开特定的选项卡进行检查.
I know how to check if the browser runs at all, but I am not sure, if it's possible to let check it if an specific tab is open.
有人有一个主意,我怎么能意识到这一点?
Does someone has an idea, how i could realize this?
..
首先,您需要chrome的 OpenList 扩展名.然后,您需要 snedkeys.bat .这是一个与snedKeys.bat位于同一目录中的脚本,它将列出chrome中所有打开的链接:
First you need OpenList extension for chrome.Then you need snedkeys.bat. This is a script in the same directory as the snedKeys.bat.It will list all opened links in 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过滤结果,以检查所需的链接是否打开.
You can filter the result with FINDSTR or FIND to check if desired link is open.
例如这将检查stackoverflow是否打开:
E.g. this will check if stackoverflow is open:
@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"