Domino Code Fragment

Code Name*
API Call to User32 to get and Set Active Window Title
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.188.108.54
Description*
Gets the Active Windows Title using WIN32 library calls.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

(Declarations)
'-- GetActiveWindow takes no parameters and returns the handle (an integer) of the active window (the window with focus)
Declare Function GetActiveWindow Lib "User32" () As Integer
'-- SetWindowTextA returns nothing, so you can declare it as a sub. It has two input parameters: The window handle and a string.
'-- As long as they are valid LotusScript identifiers, you can use your own parameter names or copy the names used in the API documentation
Declare Sub SetWindowText Lib "User32" Alias "SetWindowTextA" (Byval hWnd As Integer, Byval lpString As String)
'-- GetWindowTextA has one input parameter(the window handle) and two outoput parameters: a string variable and a buffer size.
Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" (Byval hWnd As Integer, Byval lpString As String, Byval chMax As Integer) As Integer


Sub Click(Source As Button)
Dim activeWin As Integer
Dim winTitle As String
winTitle = String(255, 0)
activeWin% = GetActiveWindow()
winTitleLength% = GetWindowText(activeWin%, winTitle$, 255)
winTitle$ = Left(wintitle$, winTitleLength%)
Messagebox winTitle$, 64, "The Current Window Title is:"
winTitle$ = Inputbox("Enter a New Title", "New Window Title")
SetWindowText activeWin%, winTitle$
Messagebox winTitle$, 64, "The New Window Title is:"
End Sub