hta 窗口_如何使HTA窗口依赖于另一个窗口?

I need to make an .hta window dependent on the other .hta window. So, basically window A cannot be closed without window B being close first. I have the two window right next to each other and they act as one window when settings is click (it basically displays a popout or extension of the first window that has options for the application).

Second window is executed by:

Sub Settings()

Set objShell = CreateObject("WScript.Shell")

objShell.Run "Launcher-Settings.hta"

End Sub

And the button is:

Both windows are close by:

解决方案

There's a typo in my comment, it should be "unload events are not cancelable...".

You can force window B to be closed just before closing A using WMI, something like this:

top.onbeforeunload = function () {

var wmiLocator = new ActiveXObject('WbemScripting.SWbemLocator'),

wmiService = wmiLocator.ConnectServer('.', 'root\\CIMV2'),

htaProcesses = new Enumerator(wmiService.ExecQuery("Select * from Win32_Process Where name = 'mshta.exe'")),

htas = [], n;

while (!htaProcesses.atEnd()) {

if (htaProcesses.item().CommandLine.indexOf('Launcher-Settings.hta') > -1) {

htas.push(htaProcesses.item());

}

htaProcesses.moveNext();

}

for (n = 0; n < htas.length; n++) {

htas[n].Terminate();

}

return;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值