What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » lpClassName

lpClassName
Author: Message:
saralk
Veteran Member
*****

Avatar

Posts: 2598
Reputation: 38
35 / Male / Flag
Joined: Feb 2003
O.P. lpClassName
How do you find out the ClassName of an application?
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
05-18-2007 12:24 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: lpClassName
You might want to take a look at this page in the MSDN library.
quote:
Parameters
    hWnd
        [in] Handle to the window and, indirectly, the class to which the window belongs.
    lpClassName
        [out] Pointer to the buffer that is to receive the class name string.
    nMaxCount
        [in] Specifies the length, in TCHAR, of the buffer pointed to by the lpClassName parameter. The class name string is truncated if it is longer than the buffer and is always null-terminated.
That means:
  • hWnd - The handle of the window, I guess you know how to retrieve that.
  • lpClassName - A buffer, so that means a DataBloc created by Interop.Allocate.
  • nMaxCount - Seems like the Win32 API even lets you choose how big you want to make your DataBloc. This is the length of the buffer you created for retrieving the class name.
According to this information, I guess you have to make something like this:

WARNING: UNTESTED CODE. Mattike was too bored to actually test this, since he would have no idea what to test it on.
code:
var hWnd = ChatWnd.Handle; //A handle of a window to get the class name from? I guess you know what to do with this.
var bufferClass = Interop.Allocate((255+1)*2); //Should be big enough I guess?
Interop.Call("user32", "GetClassName", hWnd, bufferClass, bufferClass.Size); //I think it's quite self-explaining...
Why don't you try it, and tell us if it worked? :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
05-18-2007 04:27 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: lpClassName
quote:
Originally posted by saralk
How do you find out the ClassName of an application?
It depends on what you mean by 'application'...

An application can contain many windows, and each window can have its own classname.

Also classnames are rarely unique. Many windows have the same classname (just pointing it out as this is sometimes a mistake made when searching for windows with Windows APIs like FindWindow)...

quote:
Originally posted by Mattike
[*]nMaxCount - Seems like the Win32 API even lets you choose how big you want to make your DataBloc.
Not really, a classname has a maximum length of 256 characters, incl. null character (iirc). This means your buffer must always be at least 256 characters big.

Also the Windows API GetClassName comes in two modes, ascii and wide. So you need to specify this too (best to use the wide/unicode version): Interop.Call("user32", "GetClassNameW", ...

This post was edited on 05-18-2007 at 04:47 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
05-18-2007 04:45 PM
Profile PM Find Quote Report
saralk
Veteran Member
*****

Avatar

Posts: 2598
Reputation: 38
35 / Male / Flag
Joined: Feb 2003
O.P. RE: lpClassName
ok, i'll tell you what I want to do and maybe you can help me more :)

I want to get the tooltip of a program that has been minimized to the tray (the bit next to the clock)
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
05-18-2007 05:06 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: lpClassName
Well, you can use Shell_NotifyIconW to create a tray icon and it uses a NOTIFYICONDATA structure for the information, but I can't seem to find a function to retrieve such structure from a tray icon...
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
05-19-2007 01:18 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On