Forum Moderators: open
I've never seen either of these functions in VBScript. I tried flashWindow() and got errors. That doesn't mean it's not possible, just that I can't make it work.
I've never seen either of these functions in VBScript.You mean JScript?
No, I did mean VBScript.
if(VBS==VB)canBeJS = true :)
To your question.
Abbreviated story = I don't think it can be done.
Long story =
new ActiveXObject('WScript.Shell').AppActivate('app title')
causes any application to flash in the taskbar. Unfortunately, htas are processes, not applications. Open an hta then press Ctrl + Alt + Del and you'll see your hta under Processes (mshta.exe), not Applications.
AppActivate() takes either the app title or the process id. This will give AppActivate() the process id:
String.prototype.toLocalPath=function(){
return unescape(this.slice(this.search(/[A-Z]:\/[^\/]/i)).replace(/\//g,'\\'))
};function getMSHTA(){
var htas=new Enumerator(GetObject('winmgmts:\\\\.\\root\\cimv2').ExecQuery('select * from Win32_Process where Name="mshta.exe"')),
me=window.location.href.toLocalPath();
while(!htas.atEnd()){
if(htas.item().CommandLine.indexOf(me)!=-1)return htas.item();
htas.moveNext()
}
return 0
}
setTimeout("new ActiveXObject('WScript.Shell').AppActivate(getMSHTA().ProcessId)",4000)
After all that, it can't distinguish between multiple instances of the hta and it doesn't flash the hta in the taskbar. It brings the hta to the top. I have created an incredibly complex alternative to window.focus().
On an unrelated but more positive note, Win32_Process exposes lots of properties [msdn.microsoft.com]