Welcome to WebmasterWorld Guest from 23.22.46.195

Forum Moderators: open

hta flash window

possible?

   
1:41 am on Jan 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi. I was wondering if anyone knows of a good script that can "flash" the window of an HTA program in the taskbar, to get the user's attention without actually focusing on the window.

Any suggestions?

gph

11:43 pm on Jan 27, 2006 (gmt 0)

10+ Year Member



There is a flashWindow() method in VB. Also flashWindowEX() (I'm not sure if that is spelled correctly). I believe flashWindowEX() allows setting the frequency and duration.

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.

2:53 pm on Jan 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've never seen either of these functions in VBScript.

You mean JScript? :P anyways, thanks for the help!

3:03 pm on Jan 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm I'm getting kind of confused as how to implement this vbscript function into a javascript function. Any ideas?
3:46 pm on Jan 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think the functions gph has referred to are VB (ie not VBScript). So I doubt you can use them.
4:29 pm on Jan 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



window.focus();

..any use?

12:57 am on Jan 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



nah. I'm building a chat client with javascript, see. There is a focus window option, but it gets kind of annoying after a while. Any other ideas for attention-getting stuff, maybe?

gph

7:00 am on Jan 29, 2006 (gmt 0)

10+ Year Member



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]

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month