Я на windows 10 64 бит, и я пытаюсь автоматизировать приложение под названием "PUTTY".
Мне удалось использовать Finwindowex, используя имя класса, но была 1 часть, не имеющая имя класса, и я не могу найти другой способ нажать на эту часть.
Ниже мой код:
Public Declare PtrSafe Function SendMessageA Lib "USER32" (ByVal hWnd As LongPtr, ByVal wMsg As Long, _
ByVal wParam As LongPtr, lParam As Any) As LongPtr
Private 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
Private Declare PtrSafe Function FindWindowEx Lib "USER32" _
Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr
Public Declare PtrSafe Function GetClassName Lib "USER32" Alias "GetClassNameA" _
(ByVal hWnd As LongPtr, ByVal lpClassName As String, _
ByVal nMaxCount As LongPtr) As Long
Public Const WM_CLOSE = &H10
Public Const WM_SETTEXT = &HC
Public Const WM_CLICK = &HF5&
Sub open_window()
vPid = Shell("D:\Thinh\NIKE\Putty - RF gun on laptop\PUTTY.EXE")
If vPid = 2 Or vPid = 3 Then Exit Sub
Do
DoEvents
hWnd = FindWindow("PuTTYConfigBox", vbNullString)
Loop Until hWnd > 0
Debug.Print "hWnd = " & hWnd
mainview = FindWindowEx(hWnd, 0, "Edit", vbNullString)
Debug.Print "mainview = " & mainview
Call SendMessageByString(mainview, WM_SETTEXT, 0, "thinh.doan") 'insert text
ListBox = FindWindowEx(hWnd, 0, "ListBox", vbNullString)
Debug.Print "Listbox = " & ListBox
prod = FindWindowEx(ListBox, 0, vbNullString, "VNNIKEJDAPROD") 'this is where i stuck, result always = 0
Debug.Print "prod = " & prod
Call Shell("TaskKill /F /PID " & CStr(vPid), vbHide)
End Sub
