|
-
Aug 5th, 2000, 06:16 PM
#1
Thread Starter
Member
Hello, I am trying to code a program that would send keystrokes to an application, and i don't want to use the sendkeys utilities. First I want to get the handles for Intenet Explorer but i keep getting a handle of 0 which is invalid. I use the FindWindow API but when i put this code on the commnad button: intStr=FindWindow("IExplorer",vbNullString) all it gives me is a 0, which is not the handle. Can somebody please help me out. I want to get the Hanldes for Internet Explorer. Do i have to use a different API or what? i neeedddd heeelppp thanxx.
-
Aug 5th, 2000, 06:27 PM
#2
I don't think IExplorer is the correct classname. I believe it's IEFrame.
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Sub Command1_Click()
'Get the Handle of IE
Retval = FindWindow("IEFrame", 0&)
End Sub
-
Aug 8th, 2000, 07:25 PM
#3
Hyperactive Member
Im new to classes, how do you determine class names of other program sis there a api function??
thanks
Matt 
-
Aug 8th, 2000, 07:39 PM
#4
Use GetClassName
Code:
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Sub Command1_Click()
Dim sClass As String
sClass = Space(255)
'Get the ClassName of Command1
GetClassName Command1.hwnd, sClass, 255
'Remove the Null character at the end of the String
sClass = Left(sClass, InStr(1, sClass, vbNullChar) - 1)
MsgBox sClass
End Sub
-
Aug 8th, 2000, 07:45 PM
#5
If you want to get the ClassName of a Window on a foreign App: (Make sure to pre-open Calculator)
Code:
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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As Any, ByVal lpsz2 As Any) As Long
Private Sub Command1_Click()
Dim sClass As String
Dim hParent As Long
Dim hChild As Long
sClass = Space(255)
'Get the Handle of the Parent Window (Calculator)
hParent = FindWindow(0&, "Calculator")
'Get the Handle of a ChildWindow with a name of "Hex"
hChild = FindWindowEx(hParent, 0&, 0&, "Hex")
'Get the Classname
GetClassName hChild, sClass, 255
'Remove the Null Character
sClass = Left(sClass, InStr(1, sClass, vbNullChar) - 1)
MsgBox sClass
End Sub
-
Aug 8th, 2000, 07:45 PM
#6
Hyperactive Member
Thanks megatron..ill having to experiment some with it
Matt 
-
Aug 9th, 2000, 12:50 PM
#7
Hyperactive Member
megatron I don't get anything when I tried that code. I had calcultor open..??
Matt 
-
Aug 9th, 2000, 12:58 PM
#8
Is you Calculator set to Scientific? (In Calculator, go to View > Scientific and then try it)
-
Aug 9th, 2000, 12:58 PM
#9
Hyperactive Member
I got some of it to work within the form. I tried to get the class name of the form and it said thunderform. do you know if that is valid??Thanks for your help
Matt 
-
Aug 9th, 2000, 01:01 PM
#10
Hyperactive Member
yes now it works..I was wondering where it was going to find "hex"
Matt 
-
Aug 9th, 2000, 01:10 PM
#11
Yes, that Thunder stuff is normal because it's the class name for the Form. In VB, most of the classes have a prefix of Thunder, ie:
Code:
Visual Basic Windows
===============================
ThunderCommandButton Button
ThunderComboBox ComboBox
ThunderListBox ListBox
ThunderTextBox Edit
etc.
[Edited by Megatron on 08-09-2000 at 02:14 PM]
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
|