Question (newb) about some api |
Author: |
Message: |
AITEE
New Member
Posts: 3
Joined: Nov 2006
|
O.P. Question (newb) about some api
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. ^^
|
|
11-15-2006 01:40 AM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Question (newb) about some api
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);
}
This post was edited on 11-15-2006 at 03:46 AM by matty.
|
|
11-15-2006 01:57 AM |
|
|
AITEE
New Member
Posts: 3
Joined: Nov 2006
|
O.P. RE: Question (newb) about some api
Thank you so much, I figured I was going about it wrong somehow. Thanks again, fast replies.
AITEE
|
|
11-15-2006 03:58 AM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Question (newb) about some api
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.
This post was edited on 11-15-2006 at 04:37 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
11-15-2006 04:34 AM |
|
|
Plan-1130
Full Member
I keep askin' myself: why?
Posts: 142
73 / / –
Joined: Feb 2005
|
RE: Question (newb) about some api
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.
This post was edited on 11-15-2006 at 11:25 PM by Plan-1130.
|
|
11-15-2006 11:24 PM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Question (newb) about some api
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)
This post was edited on 11-16-2006 at 02:43 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
11-16-2006 12:53 AM |
|
|
Plan-1130
Full Member
I keep askin' myself: why?
Posts: 142
73 / / –
Joined: Feb 2005
|
RE: Question (newb) about some api
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?
|
|
11-16-2006 06:32 AM |
|
|
|
|