I decided to write this article because it took me a long time to find an answer to this question, and surprisingly, most places I searched gave me the answer that this task is impossible on XP!
Well, it is possible!!!
Locking the keyboard and mouse and using SendKeys to an application window
Here is a simple VB.NET code which demonstrates how to do this:
Public Class WinControl
Declare Function BlockInput Lib "User32" _
(ByVal fBlockIt As Boolean) As Boolean
Public Shared Function Wait2Send(ByVal caption As String, _
ByVal keys As String, ByVal seconds As Integer)
Dim success As Boolean = False
Dim now As DateTime = DateTime.Now
While (success = False And (DateTime.Now.Subtract(now).Seconds _
< seconds Or seconds = 0))
success = True
Here is an example of using this function:
In this example, the function will wait 30 seconds for some application window with the caption: "Calculator" to appear. While waiting, it locks the keyboard and mouse.
If such an application window exists or will appear in the given 30 seconds, it will be given the key stroke - 22*22 and then the ENTER special key. If you activate your calculator, you will get the result to this calculation.
You can get further help on: