|
-
Mar 9th, 2001, 08:12 AM
#1
Thread Starter
Lively Member
Any body there to help me.......
I have a question...
How can i get windows handle of the
active edit control......
and is there any api for
keypress_event.....
telll me....
please tell me.....
[email protected]
-
Mar 9th, 2001, 11:51 AM
#2
PowerPoster
navram, here the sample from AllAPi.net for keypress simulation
Code:
Const VK_H = 72
Const VK_E = 69
Const VK_L = 76
Const VK_O = 79
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub Form_KeyPress(KeyAscii As Integer)
'Print the key on the form
Me.Print Chr$(KeyAscii);
End Sub
Private Sub Form_Paint()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'Clear the form
Me.Cls
keybd_event VK_H, 0, 0, 0 ' press H
keybd_event VK_H, 0, KEYEVENTF_KEYUP, 0 ' release H
keybd_event VK_E, 0, 0, 0 ' press E
keybd_event VK_E, 0, KEYEVENTF_KEYUP, 0 ' release E
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_O, 0, 0, 0 ' press O
keybd_event VK_O, 0, KEYEVENTF_KEYUP, 0 ' release O
End Sub
-
Mar 9th, 2001, 12:04 PM
#3
Fanatic Member
I think this should answer your first question. The following code will get the current position of the mouse and check to see if the mouse is currently over and Edit Box.....
Code:
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINT) As Long
Private Type POINT
x As Long
y As Long
End Type
Private Sub Timer1_Timer()
Dim ptCur As POINT
Dim strWnd As String
'get the current position of the cursor relative To the screen
GetCursorPos ptCur
strWnd = GetWindowType(WindowFromPoint(ptCur.x, ptCur.y))
If UCase(strWnd) = "THUNDERTEXTBOX" Or UCase(strWnd) = "EDIT" Then
Debug.Print "MOUSE IS OVER A TEXT/EDIT BOX!"
End If
End Sub
Private Function GetWindowType(ByVal hwnd As Long) As String
Dim str As String
str = String(255, Chr(0))
If GetClassName(hwnd, str, 255) Then
'strip the Null terminators
str = Left(str, InStr(1, str, Chr(0)) - 1)
Else
str = ""
End If
'return the name of the class
GetWindowType = str
End Function
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
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
|