Hi all you good m8
I try to make my first small program in vb, but im not very succesfull :D
(Im using Visual Studio 2005)
Form my own program i will like to set focus on an other running application. Then i will get and set cursor positon. After that i will like to send KeyCommand.
But to start with i will be very happy if i can get "user32" dll to work :)
Therefore i have try this code - but i got a 18 character long number back as windowshandel - can it be right ?
I have the feeling that my use of "user32" is wrong - im using windows XP.
Hobe any can help me :o)
Private Structure POINTAPI
Dim X As Integer
Dim Y As Integer
End Structure
Private Declare Function GetCursorPos Lib "user32" Alias "GetCursorP os" (ByVal lpPoint As POINTAPI)
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function FindWindow Lib "user32.dll " Alias "FindWindow A" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Function WindowHandle(By Val sTitle As String) As Long
WindowHandle = FindWindow(vbNu llString, sTitle)
End Function
Dim mouseposition As POINTAPI
Dim notepadID As Long
Dim lhWnd As Long
Sub Main()
' Shell runs a new instance of Notepad.
notepadID = Shell("C:\windo ws\system32\NOT EPAD.EXE", AppWinStyle.Nor malFocus)
' Activate the new instance of Notepad.
AppActivate(not epadID)
'First look at ID
lhWnd = FindWindow("Unt itled Notepad", vbNullString)
MsgBox(CStr(lhW nd))
'Next look at ID
MsgBox(WindowHa ndle("Untitled Notepad"))
End Sub
I try to make my first small program in vb, but im not very succesfull :D
(Im using Visual Studio 2005)
Form my own program i will like to set focus on an other running application. Then i will get and set cursor positon. After that i will like to send KeyCommand.
But to start with i will be very happy if i can get "user32" dll to work :)
Therefore i have try this code - but i got a 18 character long number back as windowshandel - can it be right ?
I have the feeling that my use of "user32" is wrong - im using windows XP.
Hobe any can help me :o)
Private Structure POINTAPI
Dim X As Integer
Dim Y As Integer
End Structure
Private Declare Function GetCursorPos Lib "user32" Alias "GetCursorP os" (ByVal lpPoint As POINTAPI)
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function FindWindow Lib "user32.dll " Alias "FindWindow A" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Function WindowHandle(By Val sTitle As String) As Long
WindowHandle = FindWindow(vbNu llString, sTitle)
End Function
Dim mouseposition As POINTAPI
Dim notepadID As Long
Dim lhWnd As Long
Sub Main()
' Shell runs a new instance of Notepad.
notepadID = Shell("C:\windo ws\system32\NOT EPAD.EXE", AppWinStyle.Nor malFocus)
' Activate the new instance of Notepad.
AppActivate(not epadID)
'First look at ID
lhWnd = FindWindow("Unt itled Notepad", vbNullString)
MsgBox(CStr(lhW nd))
'Next look at ID
MsgBox(WindowHa ndle("Untitled Notepad"))
End Sub