|
-
May 24th, 2005, 10:59 AM
#1
Thread Starter
Member
Service to send a keypress to application?
Hi Everyone -
I am in the process of creating a windows service that will monitor
for a dialog to be displayed, and when it is displayed, the service will
send a keypress to it...
This all works fine for a .exe application, but when i place the code
in the service shell, it never finds the window in order to close it!!!
[DllImport("USER32.DLL", SetLastError=true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
IntPtr XXXErrorWindowHandle = FindWindow(null, "XXX");
while (done == false)
{
if (XXXErrorWindowHandle != IntPtr.Zero)
{
SetForegroundWindow(XXXErrorWindowHandle);
SendKeys.SendWait("~");
ReturnStatus = true;
}
XXXErrorWindowHandle = FindWindow(null, "XXX");
done = (XXXErrorWindowHandle == IntPtr.Zero);
}
Like i said, the application works fine as an .exe
but when inserted into my service, it never finds the XXX window....
I have tried with interact with desktop on and off - same results!!
please advise
take care
tony
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
|