homepage Welcome to WebmasterWorld Guest from 54.161.166.171
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
possible?
adni18




msg:1483835
 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?

 

gph




msg:1483836
 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.

adni18




msg:1483837
 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!

adni18




msg:1483838
 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




msg:1483839
 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




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

window.focus();

..any use?

adni18




msg:1483841
 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?

gph




msg:1483842
 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:

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]

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