Shoutbox

Question (newb) about some api - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Question (newb) about some api (/showthread.php?tid=68459)

Question (newb) about some api by AITEE on 11-15-2006 at 01:40 AM

I have some code, from looking at other peoples code just to get the idea, and this is what I have so far, but it says somethings wrong and I don't know what. can anyone help me??

code:
if (Messenger.MyEmail=='XXXXXXXXXX') {



var Transparency=Math.ceil(( (0 * 255)/100)); 
var Hwnd=Interop.Call("User32.dll","FindWindowW","MSBLWindowClass",0);
Interop.Call("User32.dll","SetWindowLongW",Hwnd,-20,524288);
Interop.Call("User32.dll","SetLayeredWindowAttributes",Hwnd,0,Transparency,2);
   
    Interop.Call("User32", "AnimateWindow", Wnd.Handle, 180, "0x10000" | "0x80000");

    FreeDll("User32.dll");   


}


So I want to beable to use this code to hide (completely) the Windows Messenger window. I have the Class which is MSBLWindowClass
and I'm just not sure what I am doing wrong. probably some error in not understanding a part of someone elses code.



Any help appreciated,

Thanks

AITEE
yeah, but is there a way to do exactaly that through code?  or not even API just acessing that through code.

btw thanks for repying so fast. ^^
RE: Question (newb) about some api by matty on 11-15-2006 at 01:57 AM

code:
function MakeWndTransparent(hWnd, lTransparencyLevel){
     var nMsg = Interop.Allocate(4);
     var GWL_STYLE = (-20);
     var LWA_ALPHA = 0x2;
     var WS_EX_LAYERED = 0x80000;
     var WS_EX_TRANSPARENT = 0x20;
     nMsg.WriteDWORD(0, Interop.Call('user32', 'GetWindowLongW', hWnd, GWL_STYLE); | WS_EX_LAYERED);
     Interop.Call('user32', 'SetWindowLongW', hWnd, GWL_STYLE, nMsg.ReadDWORD(0));
     Interop.Call('user32', 'SetLayeredWindowAttributes', hWnd, 0, lTransparencyLevel, LWA_ALPHA);
}
I just read your post, you want to hide the window, well your code was to try set the Transparency level. To hide and show a window you can use this:
code:
/* function : _hide | hides the window */
function _hide(hWnd){
     var SW_HIDE = 0;
     Interop.Call('user32', 'ShowWindow', hWnd, SW_HIDE);
}

/* function : _show | shows the window */
function _show(hWnd){
     var SW_SHOW = 5;
     Interop.Call('user32', 'ShowWindow', hWnd, SW_SHOW);
}

RE: Question (newb) about some api by AITEE on 11-15-2006 at 03:58 AM

Thank you so much, I figured I was going about it wrong somehow. Thanks again, fast replies.

AITEE


RE: Question (newb) about some api by CookieRevised on 11-15-2006 at 04:34 AM

Sorry if I'm mistaken, but if you want to hide the contactlist, why don't you simply close it (because as you know, when you close the contactlist, it will actually be hidden from sight, but still accessable)?

Interop.Call("User32", "SendMessageW", hWnd, 0x10, 0, 0);

Doing this will even not tamper with the normal flow of program or whatever messenger might wanna do with the contactlist.

You see, there are many things which all do sort of the same, but are slightly different. It helps if you state exactly, in full detail what you want to do and for what this is. In that way we can give you the proper code/advise...

"I want to hide the contactlist" is still vague as hiding can mean hundreds of things in Windows.

;)


RE: Question (newb) about some api by Plan-1130 on 11-15-2006 at 11:24 PM

code:
Interop.Call("User32", "SendMessageW", hWnd, 0x10, 0, 0);

actually SendMessageW will force the close command to be executed immidiately, for the mainwindow that might work, but using PostMessageW just puts the close command at the end of the line...
Use instead:
code:
Interop.Call("User32", "PostMessageW", hWnd, 0x10, 0, 0);
if you want to play it safe.
RE: Question (newb) about some api by CookieRevised on 11-16-2006 at 12:53 AM

quote:
Originally posted by Plan-1130
code:
Interop.Call("User32", "SendMessageW", hWnd, 0x10, 0, 0);

actually SendMessageW will force the close command to be executed immidiately, for the mainwindow that might work, but using PostMessageW just puts the close command at the end of the line...
Use instead:
code:
Interop.Call("User32", "PostMessageW", hWnd, 0x10, 0, 0);
if you want to play it safe.
Nothing is forced in either of them. The only difference is that SendMessage will wait until the message is processed. Which is in almost all code, prefereable. PostMessage returns immediatly and this can lead to many bugs in your code as it is not sure if the message is processes in time and thus things after this code line will be executed immediatly which in many cases should wait until the window has been closed (eg: clearing up handles, closing files, etc).

Also, this is part of the reason that I ask for far more details of him as everything depends on what he exactly wants and what it will be used for.


(PS: FYI, messenger itself does also a sendmessage when sending WM_CLOSE)
RE: Question (newb) about some api by Plan-1130 on 11-16-2006 at 06:32 AM

Hmm, interesting, there was a thread in which i found PostMessageW to be working, while SendMessageW crashed wlm...
can be found here.
Why did that work, and SendMessageW didn't?