Windows 批处理文件启动带有按钮的 gui [英] Windows Batch file launch a gui with buttons

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

问题描述

如何创建一个带有多个按钮的窗口,点击它们后不会消失.我正在尝试使用可以打开程序的按钮制作一个简单的窗口框.我一直在为我的 gui 使用 WBox.exe,但是当您按下任何按钮时,它会在程序启动之前关闭窗口.我想到了 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 批处理文件启动带有按钮的 gui的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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