|
-
May 4th, 2008, 06:03 AM
#1
If Process found by Name then Send Minimize Window Command.
Howdy all and anyone who cares to read this. I was hoping somoeone could help me with one small issue I am having. OK to cut a long story short...
I need to be able to search through all running process.id and then sendmessage(hwnd, blah,blah, MIN_WINDOW);
In other words I need find notepad by name in the running processes and then get the Handle for it window. Then send a message to that handle to minimize the window or Set the Window Position.
Now my problem is that when I get the Handle using:
string pname="notepad";
foreach (Process theprocess in Myprocess)
{
if (theprocess.ProcessName == pname)
{
textBox1.Text = theprocess.Id.ToString();
//_________________________________//
AS you can see that the textbox1.text will show that the handle value(process.id) is an int. Now when I pass it to the showwindow(hwnd.......). It's not the Hexadecimal value so it doesn’t exist...It seem that when it's pulled using the Process[] method it converts it to a short type of Int. Please is there away to collect the Process.Id and the pass it to Handle name as Hex...
int handle = 0x00D7A;
postmessage(handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
Now this would work if a window with that PID exist...Which It did AS I used WinSpy to get the value for notepad then check it and it worked...but soon as I pass the handle via the above collected method it only pass a short version of the handle. I need to convert it to HEX to pass it. Please can you point me in the right direction...?
Cheers
Sound
PS. Quick Update. Basiclly need to Collect the Handle from the Process(Say Notepad.exe(say Handle 0005130E) then pass it a MinWIndow Command. Problem the method use to get Handle form process name is only returns a small PID(Int(3500) when it should be 0x130E <- that is the vaule i need to pass which is just 0005130E then i have knocked off the first 4(?) chars and manully enterd "0x" on the start of Handle. So how can it get the HEx of a Handle and use it to sendmessge(HANDLE(PID)) - <as example
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
|