Problems with keyboard events

I have agent which changes Notes printer with keybd_event:

    ' Open file menu and choose Print

keybd_event 18,0 ,0,0 ' Alt key down

keybd_event 70,0,0,0 ' F key down

keybd_event 70,0,2,0 ' F key up

keybd_event 80,0,0,0 ' P key down

keybd_event 80,0,2,0 ' P key up

keybd_event 18,0,2,0 ' Alt key up



 ' Change Printer

keybd_event 78,0,0,0 ' N key down

keybd_event 78,0,2,0 ' N key up



'Choose Printer

keybd_event 80,0,0,0 ' P key down

keybd_event 80,0,2,0 ' P key up



' Hit escape

keybd_event 27,0,0,0 ' escape key down

keybd_event 27,0,2,0 ' escape key up

Code works like a charm.

But when I try to print document after printer change:

SleepWin(3000)



Dim uiws As New NotesUIWorkspace 

Set uiview = uiws.Currentview

Call uiview.Print(1)

Or I try to use dialogbox with ws.DialogBox printer is not changed anymore.

Where’s the trick to make this work? It seems that SleepWin function doesn’t do it’s job.

Subject: Problems with keyboard events

Kake,

There are wonderful posts about this in the FAQ under “Printer Selection”.

I ended up using WSH (Windows Scripting Host) to change printers, but found that in R5 and Windows 2000, Notes cached the default printer on startup, even when I put the actual print command in the queryclose event.

However, in R5 windows XP, the default printer changed when I called it.

I would have to run tests in the R6 environment to tell you the results, but, long story short, I ended up displaying a dialog box with the current default printer name, and the printer they were supposed to use (i.e. PDF) and asking them to manually select the right printer if Notes didn’t make the change.

But check the posts…

Marilyn