1

我在 Lotus-Notes 中有一个应用程序。我没有开发者权利。我的主要目标是自动化一些过程。为此,我需要知道如何在 Lotus-Notes 应用程序的视图中模拟单击按钮。我用VBA开发它。

我的入口点是使用 NotesUIWorkspace 的 OpenDatabase 方法打开视图:

Call notesUIWorkspace.OpenDatabase( server$, file$, view$, key$, newInstance, temp )

现在,当视图打开时,我想模拟单击其上的按钮。非常感谢您的帮助。

顺便说一句,我不想​​直接从数据库中插入/读取文档。我需要按原样完成所有过程。

4

4 回答 4

1

我相信您可能会在使用这种方法时遇到一些障碍。Notes 中没有模拟按钮单击的 COM 方法。您可能能够获得 NotesUIDocument 的句柄,然后运行 ​​Save 操作等,但如果您的按钮执行的操作不止这些,那将无济于事。

我会检查AutoHotKey。它是一个 Windows 键盘和鼠标自动化工具。您可以编写一个脚本来自动执行所有操作,也许只使用键盘快捷键。

于 2013-01-02T23:33:38.413 回答
0

在那个按钮中,你想执行什么?

通常,您不能以编程方式单击注释操作。您可以在 Queryopen 中针对您的所有视图编写代码。

否则,您可以创建自定义工具栏操作,您可以在那里创建和计算 @Formula。

http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.notes85.help.doc/fram_customize_toolbars_t.html

于 2013-01-03T05:23:17.160 回答
0

为什么不能简单地将代码从按钮移动到库并调用函数而不是单击按钮?

于 2013-01-03T09:48:08.817 回答
0

没办法通过COM,你可以通过Winapi发送消息功能的办法。像下面这样的东西会起作用,虽然它很笨重。我在一些自动化项目中使用它来模拟点击注释按钮。

   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 GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wCmd 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 Long) As Long

' GetWindow() Constants
Public Const GW_HWNDFIRST = 0
Public Const GW_HWNDLAST = 1
Public Const GW_HWNDNEXT = 2
Public Const GW_HWNDPREV = 3
Public Const GW_OWNER = 4
Public Const GW_CHILD = 5
Public Const GW_MAX = 5

'button click constants for SendMessage
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const BM_SETSTATE = &HF3
Public Const BM_GETSTATE = &HF2
Public Const BM_CLICK = &HF5

Public hwndAction As String
Public hwndClass As String
Public hwndCaption As String
Public hwndHandle As Long

Sub ClickNotes()

hwndAction = "FindHandle"
hwndCaption = "WindowCaption" ''Window Caption here
hwndClass = "NotesSubprog"


FindChildWindows(FindWindow("SWT_Window0", "Windowtitle"))

hwndAction = "FindHandle"
hwndCaption = "WindowCaption"
hwndClass = "NotesSubprog"

FindChildWindows(hwndHandle)


hwndAction = "FindHandle"
hwndCaption = ""
hwndClass = "ActionBar"

FindChildWindows(hwndHandle)

hwndAction = "Click"
hwndCaption = "Comment"
hwndClass = "IRIS.bmpbutton"

FindChildWindows(hwndHandle)

Do While FindWindow("SWT_Window0","New Comment - IBM Notes") = 0
DoEvents
Loop

Wait 3


End Sub

'the method signature is like this only to stay compatible with the Win32 API - lParam will not be used anyway
Function EnumChildWindow(ByVal hChild As Long, ByVal lParam As Long) As Long

Dim ClassBuffer As String
Dim CaptionBuffer As String
Dim TempVar As Long

ClassBuffer = Space(150)
TempVar = GetClassName(hChild, ClassBuffer, 149)
ClassBuffer = Left(ClassBuffer, TempVar)

CaptionBuffer = Space(250)
TempVar = GetWindowText(hChild, CaptionBuffer, 250)

CaptionBuffer = Left(CaptionBuffer, TempVar)

Debug.Print "Handle: " & hChild & ", Class: " & ClassBuffer & ", Caption: " & CaptionBuffer

If hwndClass = ClassBuffer And hwndCaption = CaptionBuffer Then
Select Case hwndAction
Case "Click"
SendMessage(hChild, WM_LBUTTONDOWN, 0, 0)
SendMessage(hChild, WM_LBUTTONUP, 0, 0)
SendMessage(hChild, BM_SETSTATE, 1, 0)
Case "FindHandle"
hwndHandle = hChild
End Select

Exit Function

End If

'Continue enumeration by recursion
EnumChildWindow = True

End Function

Function FindChildWindows(ByVal hParent As Long)

Dim hChild As Long
Dim Continue As Boolean

Continue = True
hChild = GetWindow(hParent, GW_CHILD)
Continue = EnumChildWindow(hParent, 0)

While Not hChild = 0 And Continue

If Continue Then Continue = FindChildWindows(hChild)
hChild = GetWindow(hChild, GW_HWNDNEXT)

Wend

FindChildWindows = Continue

End Function
于 2014-10-31T10:59:12.093 回答