|
-
Apr 26th, 2006, 07:53 PM
#1
Thread Starter
Hyperactive Member
[resolved] [2.0] findwindow explanation
hi all, i was hoping that someone could explain findwindow to me and possibly give me an example on how to use it to bring a window "to front"? thanks
Last edited by cdubb07; May 11th, 2006 at 01:11 AM.
"Anybody can get angry or sad and frown but it takes a person with character to smile when times are hard."
-
Apr 27th, 2006, 02:02 PM
#2
Re: [2.0] findwindow explanation
top of your code window ...
VB Code:
[COLOR=Blue]using[/COLOR] System.Runtime.InteropServices;
to use FindWindow ...
VB Code:
[[COLOR=Green]DllImport[/COLOR]([COLOR=Purple]"user32.dll"[/COLOR], EntryPoint = "FindWindowA")]
[COLOR=Blue]private static extern[/COLOR] [COLOR=Green]IntPtr[/COLOR] FindWindow([COLOR=Blue]string[/COLOR] lpClassName, [COLOR=Blue]string[/COLOR] lpWindowName);
[[COLOR=Green]DllImport[/COLOR]([COLOR=Purple]"user32.dll"[/COLOR])]
[COLOR=Blue]private static extern int[/COLOR] BringWindowToTop([COLOR=Green]IntPtr[/COLOR] hwnd);
[COLOR=Blue]private void[/COLOR] button1_Click([COLOR=Blue]object[/COLOR] sender, EventArgs e)
{
[COLOR=Green]/// in this case an open instance of Notepad in the background[/COLOR]
[COLOR=Green]IntPtr[/COLOR] hwnd = FindWindow([COLOR=Purple]"Notepad"[/COLOR], [COLOR=Blue]null[/COLOR]);
[COLOR=Green]/// if you have retreived a valid handle ...[/COLOR]
[COLOR=Blue]if[/COLOR](!hwnd.Equals([COLOR=Green]IntPtr[/COLOR].Zero))
{
BringWindowToTop(hwnd);
}
}
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
May 11th, 2006, 12:28 AM
#3
Thread Starter
Hyperactive Member
Re: [2.0] findwindow explanation
I can't get this to work with any other program but Notepad, can somebody help?
"Anybody can get angry or sad and frown but it takes a person with character to smile when times are hard."
-
May 11th, 2006, 12:42 AM
#4
Re: [2.0] findwindow explanation
You're probably using the wrong class name. See gigemboy's signature for a tool (WinID) that will allow you to determine the class name of an open window or else use Spy++.
-
May 11th, 2006, 01:10 AM
#5
Thread Starter
Hyperactive Member
Re: [2.0] findwindow explanation
that was it, thanks a ton!
"Anybody can get angry or sad and frown but it takes a person with character to smile when times are hard."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|