【问题标题】:Bat file open chrome in app mode with focusBat文件以应用程序模式打开chrome并获得焦点
【发布时间】:2019-09-20 10:54:54
【问题描述】:

我正在尝试制作一个像程序启动器一样工作的 HTA 应用程序..

但我的应用程序有一些问题,在我的 HTA 应用程序下方打开..

现在我正在尝试以应用模式在 chrome 中打开网页。但是 chrome 从我的 hta 下面开始..

我用chrome app模式打开网页的代码:

Start "" "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" chrome --app=https://www.google.com/

我找不到可以开始工作的解决方案。我之前没有批处理编程等方面的经验。

编辑: 我正在制作的 Hta 应用程序用于锁定课后俱乐部中的一些游戏计算机。我已经这样做了,用户无法访问桌面。我在应用程序中禁用了 ALT+F4 等,所以我无法关闭。

但现在他们想玩像 plix.io 这样的网页游戏,所以我制作了下面的批处理脚本来启动游戏,并且可以在没有浏览器访问且地址栏可见的情况下加入团队游戏。

这是我的 bat 文件

@echo off

rem not really necessary for this part
title Splix.io Launcher
color 0f
mode con: cols=80 lines=15
rem below is necessary
cls
goto main
@echo off

:main
Echo .
Echo                                Splix.io Launcher
Echo  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
Echo  º                                                                            º
Echo  º 1 Start Splix      Start singpleplayer eller host en team server           º
Echo  º                                                                            º
Echo  º 2 Join Team spil   Deltag i et team spil                                   º
Echo  º                                                                            º
Echo  º 3 EXIT             Luk Splix.io Launcher                                   º
Echo  º                                                                            º
Echo  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Echo .
Choice /C 123 /M "Vil du starte singleplayer eller join et team spil:"
If Errorlevel 3 Goto 3
If Errorlevel 2 Goto team
If Errorlevel 1 Goto single

:single
Start "" "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" chrome --app=https://www.splix.io/
echo Starter Splix.io
exit

:team
cls
color 0f
set str=error
echo Skriv de sidste 5 tegn fra Splix team adressen på hjemmesiden
echo.
set /p str=Splix.io/#team- 
set len=0
goto sl

:sl
call set this=%%str:~%len%%%
if not "%this%" == "" (set /a len+=1
goto :sl)
cls
if not "%len%" == "5" (echo Fejl, Du skal skrive de sidste 5 tegn i Splix team adressen
color 4f
pause >nul
cls
goto team)
Start "" "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" chrome --app=https://www.splix.io/#team-%str%
echo Starter Splix.io Team spil
exit

:3
cls
exit

我不知道问题是批处理脚本还是我在 HTA 中使用的代码使我能够从 hta 打开程序:

function runApp(which) {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run (which,1,true);
}

谁能告诉我打开 Chrome 应用后如何专注于它?

【问题讨论】:

  • 嗯,批处理可能是控制 GUI 应用程序的最糟糕选择,因为它根本不是为此而设计的......
  • 好的,我编辑了主题并添加了更多信息..

标签: google-chrome batch-file focus hta


【解决方案1】:

不知道这个HTA文件能不能帮到你:

<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="Open link with chrome browser"
BORDER="THIN"
BORDERSTYLE="NORMAL"
ICON="Explorer.exe"
INNERBORDER="NO"
MAXIMIZEBUTTON="NO"
MINIMIZEBUTTON="NO"
SCROLL="NO"
SELECTION="NO"
SINGLEINSTANCE="YES"/>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<title>Open link with chrome browser</title>
<SCRIPT LANGUAGE="VBScript">
'************************************************************************************
Option Explicit
 Function Executer(StrCmd)
 Dim ws,MyCmd,Resultat
 Set ws = CreateObject("wscript.Shell")
 MyCmd = "CMD /C " & StrCmd & " "
 Resultat = ws.run(MyCmd,0,True)
 Executer = Resultat
End Function
'************************************************************************************
Sub window_onload()
 CenterWindow 400,320
End Sub
'************************************************************************************
Sub CenterWindow(x,y)
 Dim iLeft,itop
 window.resizeTo x,y
 iLeft = window.screen.availWidth/2 - x/2
 itop = window.screen.availHeight/2 - y/2
 window.moveTo ileft,itop
End Sub
'************************************************************************************
</script>
</head>
<p>Links :</p>
<ol>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.google.com chrome --app=https://www.google.com/')">Link Google</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe https://stackoverflow.com chrome --app=https://stackoverflow.com/')">Link Stackoverflow with Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.yahoo.fr chrome --app=www.yahoo.fr/')">Link Yahoo with Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.autoitscript.fr chrome --app=www.autoitscript.fr/')">Link Autoitscript.fr (Français) with Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.autoitscript.com chrome --app=www.autoitscript.com/')">Link autoitscript.com (Anglais) with Chrome.exe</a></li>
</ol>
<BODY text=white bgcolor="DarkOrange" TOPMARGIN="1" LEFTMARGIN="1">
 <center><button onclick="Call Executer('Start chrome.exe www.google.com chrome --app=https://www.google.com/')">Open Google Link </button></center>
</body>
</html>

【讨论】:

  • 感谢您的回复。它看起来确实是一种更好的打开程序的方法。但是当我的 HTA 使用 content="IE=9" 元数据时,我遇到了一些脚本无法正常工作的问题标签..我需要它与 IE=9 一起工作,因为没有它其他一切都会中断..
  • 我用你的脚本做了一些测试,它看起来像 Chrome,当我使用你的 HTA 脚本启动 Chrome 时,在我的全屏 HTA 后面打开 chrome 窗口没有问题。所以,如果我能废弃蝙蝠的东西并使用类似的东西,我会很棒。但是我仍然需要用户输入,将其添加到 url 中。就像我的批处理文件一样。经过一番谷歌搜索后,我没有找到任何简单的脚本或任何可以帮助我构建它的东西。就像我提到的那样,我以前没有使用过 HTA,而且很少使用批处理文件。所以我真的可以用一个简单的例子来说明它是如何工作的。
猜你喜欢
  • 1970-01-01
  • 2015-02-26
  • 1970-01-01
  • 1970-01-01
  • 2021-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多