so I declare:
Declare
Function FindWindow Lib "User32" Alias "FindWindowA" _(
ByVal lpClassName As String, ByVal lpWindowName As String) As LongPublic
WinWnd As Longand make the call inside a sub:
Dim
windowName As StringwindowName = "Title"
WinWnd = FindWindow(vbNullString, windowName)
WinWnd gets trash, end the error variable is set to 126, wich means specific module not loaded
I tried to put the auto keyword, not sure what it means but I saw it on an example on making api call in msn website (waltrough to making api call in vb.net or something like) but it instead of giving 126 he gives 127 error #
What I am trying to accomplish is to get the window handle from it's name, what I need is to detect if the user pressed ctrl in other window than the app I'm working, so I need to set up a hook
any other way to get the window handle
thanks in advance
marcel

making an api call error 126 (findWindow)
_Raj_
findWindow now returns 127 instead of 126... the difference I think is the auto
SunilKannan
I was testing with a window called test.txt - Notepad
looks like the problem is with the .
if I rename the file just for test it woks.. but just for the first time, if I try to run it again it doesn't work, I have to close and open my app
anyway, I got it working by calling
AppActivate(windowName)
just before ShowWindow since AppActive doesn't works properly sometimes..now I have to hook the keyboard, I'll just create another thread...
Sean Allison
http://pinvoke.net/default.aspx/user32/FindWindow.html
Regards,
Vikram
Jake Montgomery
Kinetic Media
the difference was just in the declaration of findwindow
the error number after calling findwindow is 0
the value of the handle returned byt window appears to be trash, a very high number.. but
when testing the handle with :
Const
SW_SHOWNORMAL = 1Public WinWnd As New IntPtr(0)
Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As IntPtr
Declare Function ShowWindow Lib "User32" (ByVal Hwnd As IntPtr, _ ByVal nCmdShow As Long) As Long
'the original Hwnd was long, but I changed to IntPtr because of the declaration of findWindow
and call it as:
WinWnd = FindWindow(vbNullString, windowName)
ShowWindow(WinWnd, SW_SHOWNORMAL)
error # is 0, but nothing happens, also the value returned by showWindow looks like trash..
thanks again
marcel
Rabtok