Click to See Complete Forum and Search --> : how can i send keys


shafiqurrehman
October 31st, 1999, 03:57 PM
how can i send keys from my application to any other programe that i make active by mouse clicking. or i have to use the z-order method to find second active programe?

Waseem Sadiq
November 1st, 1999, 04:39 PM
Use SendKeys (Check the online help for details), it's very easy to use. Unfortunatly I don't have sample-projects at this time, sorry.

November 2nd, 1999, 02:42 PM
This is an example with Windows Dialer (some of elements are not shown):

private Sub Dial()
'FindWindow and SetWindowPos& are API finctions declared as public in a module
Dim lngReturnValue as Long
lngReturnValue = FindWindow("DialerClass", vbNullString)
'make Dialer the most top form
lngReturnValue = SetWindowPos&(lngReturnValue, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

'create DialNumber depending on area code. Variable intListIndex is used to determine which lstAccountPhone is highlighted
If Left(lstAccountPhone(intListIndex).Text, 7) <> " (" & strAreaCode & ")" then 'check whether the area code is a local
DialNumber = "1" & lstAccountPhone(intListIndex).Text 'add 1 and use full entry from the field PhoneNumber
else
DialNumber = Right(lstAccountPhone(intListIndex).Text, 8) ' if area code is local, use only last 7 digits (plus one dash) from the phoneNumber
End If
'there are List Boxes on the form, but for testing you can set DialNumber variable directly, for example DialNumber = "718-743-1210"
SendKeys DialNumber, true
SendKeys "{Enter}", true
End Sub



HTH
Vlad

shafiqurrehman
November 5th, 1999, 02:12 PM
thanks, but the problem is that how can i make the last active window active from my programe. for example
i am using note pade, then i started my programe, now active window is my programe, i press a button in my programe, and the keys
r send to notepade

shafiqurrehman
November 5th, 1999, 02:20 PM
thanks, but the problem is that how can i make the last active window active from my programe. for example
i am using note pad, then i started my programe, now active window is my programe, i press a button in my programe, and the
keys r send to notepad