I have seen a tutorial of how to set text to external application using API and I tried this code .. There is no error but it doesn't work as expected
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal
hWnd1 As Long, ByVal hwnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As
String) As Long
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal
hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long)
As Long
'Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd
As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function SendMessageByString Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As String) As Long
Const SW_NORMAL = 1
Const WM_SETTEXT = &HC
Sub Test()
Dim x, hwnd As Long, TLogin As Long, subWindow As Long
'hwnd = FindWindow(vbNullString, "Untitled - Notepad")
x = ShellExecute(hwnd, "open", "C:\Program Files\Skype\Phone\Skype.exe", 0,
0, SW_NORMAL)
If x = 2 Or x = 3 Then Exit Sub
Do
DoEvents
hwnd = FindWindow("TLoginForm", vbNullString)
Loop Until hwnd > 0
Application.Wait Now + TimeValue("00:00:03")
'First Try
' TLogin = FindWindowEx(hwnd, 0&, "TLoginAppControl", vbNullString)
' subWindow = FindWindowEx(TLogin, 0&, "Shell Embedding", vbNullString)
' subWindow = FindWindowEx(subWindow, 0&, "Shell DocObject View", vbNullString)
' subWindow = FindWindowEx(subWindow, 0&, "Internet Explorer_Server", vbNullString)
' Call SendMessageByString(subWindow, WM_SETTEXT, 0, "HelloWorld")
'Second Try
' TLogin = FindWindowEx(hwnd, 0&, "TLoginControlBar", vbNullString)
' Call SendMessageByString(TLogin, WM_SETTEXT, 0, "HelloWorld")
'Third Try
TLogin = FindWindowEx(hwnd, 0&, "TNativeLoginControl", vbNullString)
Call SendMessageByString(TLogin, WM_SETTEXT, 0, "HelloWorld")
End Sub
In the code there are three tries but none of them enables me to set text to the skype name ..
This is screenshot of Spy++
And when I used Spy++ to search for the desired window I got this and found that "HelloWorld" became a caption for this window .. but no clue for what's in this window