Windows Batch文件使用按钮启动GUI [英] Windows Batch file launch a gui with buttons

查看:114
本文介绍了Windows Batch文件使用按钮启动GUI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何创建一个包含多个按钮的窗口,而这些按钮在单击后不会消失.我正在尝试制作一个带有可以打开程序的按钮的简单窗口框.我一直在使用WBox.exe作为gui,但是当您按任意按钮时,它将在程序启动前关闭窗口. HTML引起了我的注意,但是我不知道如何制作按钮,甚至不知道它是否可以在单击时启动程序.

How can I create a window with multiple buttons in which do not go away apon clicking them. I'm trying to make a simple Windowed Box with buttons that can open programs. I've been using WBox.exe for my gui, however it closes the window before the program launches when you press any button. HTML crossed my mind, but I don't know how to make buttons or even know if it can launch a program on click.

推荐答案

您可以通过Batch-HTA 混合文件以相对简单的方式进行操作;这是一个例子:

You may do that in a relatively simple way via a Batch-HTA hybrid file; this is an example:

<!-- :: Batch section
@echo off
setlocal

echo Select an option:
for /F "delims=" %%a in ('mshta.exe "%~F0"') do set "HTAreply=%%a"
echo End of HTA window, reply: "%HTAreply%"
goto :EOF
-->


<HTML>
<HEAD>
<HTA:APPLICATION SCROLL="no" SYSMENU="no" >

<TITLE>HTA Buttons</TITLE>
<SCRIPT language="JavaScript">
window.resizeTo(374,100);

function closeHTA(reply){
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   fso.GetStandardStream(1).WriteLine(reply);
   window.close();
}

</SCRIPT>
</HEAD>
<BODY>
   <button onclick="closeHTA(1);">First option</button>
   <button onclick="closeHTA(2);">Second option</button>
   <button onclick="closeHTA(3);">Third option</button>
</BODY>
</HTML>

将此代码保存在扩展名为.BAT的文件中.也许您需要调整window.resizeTo(374,100);行中的值以匹配屏幕分辨率.此示例非常简单,即使您对.HTA文件一无所知,您也可以理解它.有关此问题的更多详细信息和链接,请参见这篇文章.

Save this code in a file with .BAT extension. Perhaps you would need to adjust the values in window.resizeTo(374,100); line in order to match the resolution of your screen. This example is simple enough so you may understand it even if you know nothing about .HTA files. For further details and links on this matter, see this post.

这篇关于Windows Batch文件使用按钮启动GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆