Archive: FindWindow *boggle*


Alright, so I admit: I'm an amateur programmer. Right now I'm using Visual Basic 6. I'm wondering if anyone has used VB and FindWindow to detect whether their application is running or not.

Maybe I'm missing something here. Could someone explain how FindWindow works and what exactly a WindowClass is? I feel really stupid asking these questions but I gotta learn somehow :-D.

Thanks all,

P


Doesn't VB use the CreateWindowEx function of the WIN32 API? Three you have to specify one parameter: the ClassName. It is like the template of a Window.

You can e.g. you the free util atm (Another Task Manager) http://atm.idic.caos.it/higheng.html (it's like 80kb or so IIRC), to choose a process and get a list of its Windows and ClassNames, if you are not sure.

Winamp2 will e.g. use the ClassName "Winamp v1.x" for it's main Window. Other programms (like ICQ) have just a cryptic name AFX:40000 (or similar) for their class.

HTH
Sebastian


Unfortunately, it appears that VB automatically assigns windowclass names to an application. Is there anyway that FindWindow could also accept a Window Title? For example, if I wanted to find Internet Explorer with NSIS, I could just do:

FindWindow prompt "Microsoft Internet Explorer" "bleh bleh bleh"

If not, has anyone been able to use FindWindow with their VB application?


I know that the MFC FindWindow function in Visual C++ can do a find Window on a Window Title so I am sure that it can be put into the NSIS source code if you need it to do that.


All VB programs will have the same classname.

ThunderRT6Form >> For VB 6
ThunderRT5Form >> For VB 5

.. and so on.

Unless Justin updates NSIS to have an option to read the window title you're out of luck.


FindWindowTitle Function added
I decided that it would be useful to find windows based on title so I added to my own personal version, if you want it download it from http://www.shoutclub.com/nsis/

Justin feel free to modify it for your version the source code is included and is just below your FindWindow Function.

To use the function just put this in your script

FindWindowTitle <mode> <Window title> <Message Prompt>

Let me know how it works out, this is the first time I have modified this code and it appears to work fine on my system.

Jay


Thanks! Works great.

By the way, it appears that your change also affected the FindWindow command. I was able to use FindWindow and FindWindowTitle interchangeably.

P


hmmm I am not able to duplicate that here, if I do a search for a window title with FindWindow, it doesn't appear to work only FindWindowTitle can find a window by title.

FindWindow will only search for windows by class, at least that the only way I can do it here.

Does FindWindow work with class names still?

Can you give me an example of what you are trying to do?


I've tried it with my application, and other applications. FindWindow works with both Window Title and WindowClass name.

:-P


Sorry, what I'm doing is this:

for ICQ:

(windowclass name)
FindWindow prompt "#32770" "bleh bleh bleh"

I get the message box with Retry, Abort, and Ignore

(window title)
FindWindow prompt "11136292" "bleh"

same thing

If I do:

FindWindow prompt "sdfkjsdfkljsdfl" "bleh"

no message box

However, this does not work with FindWindowTitle. It will only accept Window Titles.


ok I found the bug

Bad switch statement on my part

it would probably be a good idea to download this new version. I am not sure what adverse effects the other version could have on other commands.

download from same location as above
http://www.shoutclub.com/nsis/


Thanks again. I applied the previous tests to the new version and it seems to work great.

P