0

This is a follow-up question to Launching 2 Google Chrome windows in different positions and Launch Google Chrome from the command line with specific window coordinates.

Apart from what has already been said in those 2 posts, I am wondering if there is a command I can add to a batch file which allows me to open a new Chrome window scrolled down to a specific position, or by a specific "amount".

I have checked this page and this page but have not found anything.

Daneel Olivaw
  • 2,077
  • 4
  • 15
  • 23

1 Answers1

0

Here I use sendkeys after opening chrome to open the console, focus on the console, and input some javascript to scroll 100px down.

@if (@CodeSection == @Batch) @then
@echo off

rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"

rem Start the other program in the same Window
call "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=netframework-4.8
timeout /t 2
%SendKeys% "^(+({J}))"
timeout /t 2
%SendKeys% "^(`)"
%SendKeys% "window.scrollBy{(}0, 100{)};~"


goto :EOF


@end
// JScript section

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
shadow2020
  • 1,315
  • 1
  • 8
  • 30