excel - 如何使用 VBA 代码自动化登录页面,如共享图像中所示
问题描述
我需要自动化一个需要登录插件的工作流程。在这个插件中有一个登录按钮,我需要点击它,以便出现登录弹出窗口。之后我需要输入用户名和密码。然后在最后点击继续按钮。
我尝试将“SetCursorPos”用于单击事件,但输入文本部分对我不起作用。
我还尝试使用“FindWindow”和“SendMessage”api 来处理弹出窗口,但我无权访问 SPY++ 来了解应用程序的类名然后要知道类名我使用了“WindowFromPoint”/“GetCursorPos”/“GetClassName”
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Label3.Caption = "KeyCode = " & KeyCode
End Sub
Private Sub Form_Load()
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Dim b As POINTAPI
Dim r, s, t As String
GetCursorPos b
Label1.Caption = "Mouse Position =" & " { " & b.X & " , " & b.Y & " }"
r = WindowFromPoint(b.X, b.Y)
t = Space(128)
s = GetClassName(r, t, 128)
Label2.Caption = "ClassName = " & t
End Sub
但仍面临 Label1.Caption 中的问题或有时在 bX 或 bY 上出现错误
我尝试了很多次,但仍然没有得到结果。
解决方案
推荐阅读
- ubuntu - 修改上传图片 ASP.Net Core
- javascript - 单击 index.html 中的按钮,如何使该函数多次运行?
- vba - 查询 PostgreSQL 视图时出现 VBA 未指定错误
- ruby-on-rails - Rails 端点性能 - 寻找什么?
- python - 非常具体的应用程序的递归算法(Python)
- spring - JPA/Spring/Hibernate/etc 中是否有类似于 JPA 的 @PrePersist 允许更改相关实体的功能?
- google-apps-script - 谷歌课堂表格
- swagger - Swagger - 属性名称约定
- python - 如何键入检查引用类的数据类函数?
- sql-server - SQL 配置中没有 sqlbrowser