Simple method to select all/deselect all from LotusScript

View member feedback to this tip.

This code snippet demonstrates using the Windows API to perform Edit->Select All and Edit->Deselect All actions from the Notes edit menu. You can change the arguments being passed to the subroutine keybd_event to simulate other keyboard actions.
Place in declarations:

Declare Sub keybd_event Lib 
"user32.dll" (Byval bVk As Integer, Byval bScan 
As Integer, Byval dwFlags As Integer,
Byval dwExtraInfo As Integer)

Place in shared action or wherever desired:

Dim workspace As New NotesUIWorkspace

'select all documents
 keybd_event 18,0,0,0 ' Alt key down
 keybd_event Asc("E"),0,0,0 ' E key down -- 
invokes file menu
 keybd_event Asc("A"),0,0,0 ' A key down - 
Select All
 keybd_event Asc("A"),0,2,0 ' A key up 
 keybd_event Asc("E"),0,2,0  'E key up 
 keybd_event 18,0,2,0 ' Alt key up 

'deselect all documents 
 keybd_event 18,0,0,0 ' Alt key down
 keybd_event Asc("E"),0,0,0 ' E key down
 keybd_event Asc("E"),0,2,0 ' E key up
 keybd_event 18,0,2,0 ' Alt key up 
 keybd_event Asc("D"),0,0,0 ' D key down
 keybd_event Asc("D"),0,2,0 ' D key up 
 Call workspace.ViewRefresh
For example, the following snippet of code would invoke the open database dialog:

                        keybd_event 18,0,0,0 '
 Alt key down
                        keybd_event Asc
("F"),0,0,0 ' F key down -- invokes
edit menu
                        keybd_event Asc
("D"),0,0,0 ' D key down - Database
                        keybd_event Asc
("O"),0,0,0 ' O key down - open
database dialog
                        keybd_event 18,0,
0,0 ' Alt key down
                        keybd_event Asc("F"),
0,2,0 ' F key down -- invokes
edit menu
                        keybd_event Asc("D"),
0,2,0 ' D key down - Database
                        keybd_event Asc("O"),0,
2,0 ' O key down - open
database dialog
                        keybd_event 18,0,2,0 '
 Alt key up

Users must be careful, however; if the last line of code, to lift up the Alt key, is not included, the keyboard will continue to function as if the Alt key is being held down.


This method doesn't work with different Notes client languages. The sequence of keys is different.

-- Anonymous


Great workaround for SendKeys(). I just want to know, if Andrew Young can do this in a few lines of code why can't Lotus make SendKeys() work in the Notes client? Good work, Andrew.

-- Dale F.


The tip is good, but it's not NLS portable. The Windows key events are dependent on the NLS version of the Notes client.

-- Jesus M.


The Select All code could be minimized a little more by bypassing the Edit menu, and using CTRL+A instead. No big difference, but a few less lines.

'select all documents
      keybd_event 17, 0, 0, 0 ' CTRL key down
      keybd_event Asc("A"), 0, 0, 0 ' A key down (Select All)
      keybd_event Asc("A"), 0, 2, 0 ' A key up
      keybd_event 17, 0, 2, 0 ' CTRL key up
Unfortunately, Notes does not have a Deselect all key.

-- Anonymous


It does not work if you open another window after "deselect all" [e.g., UIWorkspace.ComposeDocument(...)].

-- Irina E.


I just created a Smarticon to have a deselect icon with this code:

Works great. Of course, this is done after doing a CTRL-A to select all.

-- Anonymous

Do you have comments on this tip? Let us know.

This was first published in July 2003

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.