批处理文件检测特定选项卡是否打开? [英] Batch file detect if specific tab is open?

查看:79
本文介绍了批处理文件检测特定选项卡是否打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的脚本检查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"

这篇关于批处理文件检测特定选项卡是否打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆