google-chrome - Bat file open chrome in app mode with focus
问题描述
I'm trying to make a HTA application that works like a program launcher..
But I have some problems with apps, that opens below my HTA app..
Right now i'm trying to open a webpage in chrome with app mode. But chrome starts below my hta..
The code I use to open the webage in chrome app mode:
Start "" "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" chrome --app=https://www.google.com/
I have not been able to find a solution that I can get to work.. I Have no prior experience with batch programming etc.
Edit: Hta app i'm making is used to lock down some gaming commputers in a after school club. I have done so the user don't have access to the desktop.. I have disabled ALT+F4 etc. in the application so i can't be closed..
But now they want to play web games like plix.io, so I made the batch script below to launch the game and make it possible to join a team game without browser access with adress bar visible.
this is my bat file
@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
I don't knows if the problem is the batch script or the code i use in the HTA to enable me to open programs from the hta:
function runApp(which) {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run (which,1,true);
}
Can anyone tell me how I focus on the Chrome app after I open it?
解决方案
我不知道这个 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>
推荐阅读
- stdoptional - 我找不到 std::option 有用的地方
- r - 使用 R 在一个中绘制多个折线图
- reactjs - 我怎么能理解“主要”在?
- git - 带有 Git Bash 的 Cmder/ConEmu 中缺少黑色
- android - 如何在构建 gradle 上实现 iText
- c++11 - 无法理解 IO 目录和管道命令
- raspberry-pi - 树莓派无法安装mysql或nginx
- javascript - 重新绘制图例不匹配格式化的数据键
- dialogflow-es - 如何为上下文建立满足感?
- python - Python相当于`curl -v http://example.com/`