使Chrome在第二台显示器上打开?

用户名

我目前正在尝试制作一个可强制在第二台显示器上打开Chrome窗口的应用程序,但无论如何我都找不到使用自变量进行操作的窗口,现在我想知道是否可以通过某种方式使用Delphi强制其打开第二个屏幕还是特定的像素?这仅仅是我自己和PC的应用程序,因此我可以针对我的情况专门编写代码。

我目前正在使用这段代码来启动应用

procedure TForm1.BtnClick(Sender: TObject);
begin
 ExecProcess(ChromePath,'',False);
end;

function ExecProcess(ProgramName, WorkDir: string; Wait: boolean): integer;
var
  StartInfo: TStartupInfo;
  ProcInfo: TProcessInformation;
  CreateOK: boolean;
  ExitCode: integer;
  dwExitCode: DWORD;
begin
  ExitCode := -1;

  FillChar(StartInfo, SizeOf(TStartupInfo), #0);
  FillChar(ProcInfo, SizeOf(TProcessInformation), #0);
  StartInfo.cb := SizeOf(TStartupInfo);

  if WorkDir <> '' then
  begin
    CreateOK := CreateProcess(nil, Addr(ProgramName[1]), nil, Addr(WorkDir[1]),
      false, CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil, nil,
      StartInfo, ProcInfo);
  end
  else
  begin
    CreateOK := CreateProcess(nil, Addr(ProgramName[1]), nil, nil, false,
      CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil, Addr(WorkDir[1]),
      StartInfo, ProcInfo);
  end;

  { check to see if successful }

  if CreateOK then
  begin
    // may or may not be needed. Usually wait for child processes
    if Wait then
    begin
      WaitForSingleObject(ProcInfo.hProcess, INFINITE);
      GetExitCodeProcess(ProcInfo.hProcess, dwExitCode);
      ExitCode := dwExitCode;
    end;
  end
  else
  begin
    ShowMessage('Unable to run ' + ProgramName);
  end;

  CloseHandle(ProcInfo.hProcess);
  CloseHandle(ProcInfo.hThread);

  Result := ExitCode;

end;

我可以以某种方式使用某些东西StartInfo.wShowWindow吗?

纳特

Chrome允许您在命令行中使用--window-position和--window-size传递位置和大小。请查看此页面以获取详细信息。

例:

:: Left screen is 1024x768
"C:\chrome.exe" "https://www.example.com/?a=0&b=1" --window-position=0,0  --window-size=1024,768 --user-data-dir="C:\my-chrome1"

:: Right screen is 1280x720
:: Now chrome.exe we need to open in the second screen then we do it as below:
:: we might want to use --kiosk but combination of --kiosk and --window-position wont work so in that case we can use --app


"C:\chrome.exe" --app="https://www.example.com/?a=0&b=1" --window-position=1025,0 --window-size=1280,720 --user-data-dir="C:\my-chrome2"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

第二台显示器上的AVD崩溃

Chrome扩展程序弹出窗口未显示在第二台显示器上

无法提高第二台显示器上的显示器刷新率

检测到第二台显示器但未打开

使用Nvidia旋转第二台显示器

如何获得第二台显示器的预览?

查找禁用第二台显示器的过程

不再检测到第二台显示器

如何在第二台显示器上显示快速启动栏

监听键和第二台显示器上的全屏显示

在Wayland上的Ubuntu 17.10的第二台显示器上重复鼠标指针

19.10 Kubuntu 在第二台显示器上启用菜单栏

第二台显示器上的Ubuntu 12.04白色条纹

第二台显示器Fedora 24上的分辨率很差

登录屏幕出现在第二台显示器上

Ubuntu 破折号在第二台显示器上

在Ubuntu Budgie中是否可以在第二台显示器上安装面板?

在 Ubuntu 18.04.2 LTS 上加入时,第二台显示器变黑

如何将系统托盘放在第二台显示器上?

第二台显示器无法在Windows 10上运行

在第二台显示器上登录屏幕的分辨率是错误的

Rasberry pi 4 上的 Ubuntu Mate 20.10 无法识别第二台显示器

使第二台显示器显示位于主显示器左侧的工作区

系统无法正常启动-屏幕关闭并打开。仅在插入第二台显示器时

第二台显示器在Thinkpad T410上具有垂直分隔14.04

如何在第二台显示器上禁用顶部面板?或至少适当地隐藏它

在第二台显示器上使用 VGA 时任务栏被切断

第二台显示器与第一台显示器不兼容

为什么我的第二台显示器显示黑屏?