homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

hta flash window

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

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?



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

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)

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)

Hmm I'm getting kind of confused as how to implement this vbscript function into a javascript function. Any ideas?

Bernard Marx

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

I think the functions gph has referred to are VB (ie not VBScript). So I doubt you can use them.

Bernard Marx

 4:29 pm on Jan 28, 2006 (gmt 0)


..any use?


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

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?


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

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:

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"')),
if(htas.item().CommandLine.indexOf(me)!=-1)return htas.item();
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]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved