.batch 파일을 통해 현재 탭의 URL을 가져옵니다.

.batch 파일을 통해 현재 탭의 URL을 가져옵니다.

저는 Firefox 사용자입니다. 파일을 통해 활성 탭의 URL을 얻을 수 있는 방법이 있습니까 .batch?

예를 들어 Firefox의 활성 탭 URL이 이면 파일을 사용해야 whatever.com합니다 .whatever.combat

답변1

활성 탭에만 으로 감지할 수 있는 제목이 있습니다 tasklist. 그래서:

tasklist /v /fi "imagename eq firefox.exe"  |findstr /r /v "N/A"

또는 다음으로 처리됨 FOR:

for /f "skip=1 tokens=9* delims= " %%a in ('tasklist /v /fi "imagename eq firefox.exe"  ^|findstr /r /v "N/A"') do @echo %%b

제목은 링크와 다를 수 있습니다.

와 함께sendkeys.bat브라우저를 속여 제목을 현재 링크로 변경할 수 있습니다.

@echo off
::get the title of the active page
for /f "skip=3 tokens=9* delims= " %%a in ('tasklist /v /fi "imagename eq firefox.exe"  ^|findstr /r /v "N/A nsAppShell:EventWindow"') do set "fftitle=%%b"
::get the first 10 sympols needs to be passed to the sendkeys command
set "fftitle=%fftitle:~0,10%"
::opens the console of the browser
call sendkeys.bat "%fftitle%" "{f12}"
::waits for 2 seconds
w32tm /stripchart /computer:localhost /period:2 /dataonly /samples:2  1>nul
::changing the title with the link location
call sendkeys.bat "%fftitle%" "document.title=window.location.href{ENTER}"
::wait for 3 seconds
w32tm /stripchart /computer:localhost /period:3 /dataonly /samples:2  1>nul
::get the new title
for /f "skip=3 tokens=9* delims= " %%a in ('tasklist /v /fi "imagename eq firefox.exe"  ^|findstr /r /v "N/A nsAppShell:EventWindow"') do set "fftitle=%%b"
echo "%fftitle%"

편집하다. 콘솔 직접 열기:

@echo off
::get the title of the active page
for /f "skip=3 tokens=9* delims= " %%a in ('tasklist /v /fi "imagename eq firefox.exe"  ^|findstr /r /v "N/A nsAppShell:EventWindow"') do set "fftitle=%%b"
::get the first 10 sympols needs to be passed to the sendkeys command
set "fftitle=%fftitle:~0,10%"
::opens the console of the browser
call sendkeys.bat "%fftitle%" "^+K"
::waits for 2 seconds
w32tm /stripchart /computer:localhost /period:2 /dataonly /samples:2  1>nul
::changing the title with the link location
call sendkeys.bat "%fftitle%" "document.title=window.location.href{ENTER}"
::wait for 3 seconds
w32tm /stripchart /computer:localhost /period:3 /dataonly /samples:2  1>nul
::get the new title
for /f "skip=3 tokens=9* delims= " %%a in ('tasklist /v /fi "imagename eq firefox.exe"  ^|findstr /r /v "N/A nsAppShell:EventWindow"') do set "fftitle=%%b"
echo "%fftitle%"

관련 정보