on 04-28-2010 12:01 PM
Dear Developers,
I would like to know how can I push the OK button on Printing windows dialog after SBO_Application.ActivateMenuItem ("520") in code. I'm working on a alternative printing wizard and need help on it.
Thank you in advance.
Cheers,
Nghia
Nghia,
Please note, you can automatically print invoices when you add them (there is a customizing option when you press the add button you can print out the invoice) our you can use document printing wizard.
This stuff is not easy, but try the following:
Logic:
You should implement a multi-threaded program, which is looking for the operating system actual window, and compares with the SAP B1 Window ID. If differs, then you can send an enter key. (click on default button).
You can build up thread safe procedure with custom code, but i have used there a timer, which starts when you send the printing, and stops when enter has been sent.
Add the following code to your addon variables declare section:
Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
Dim _timer As New System.Timers.Timer
Dim lCurHwnd As Integer
When you activating the Print Menu, add the following code
' SAP B1 Window ID via Windows API Call
lCurHwnd = GetForegroundWindow()
_timer.Interval = 100
AddHandler _timer.Elapsed, New System.Timers.ElapsedEventHandler(AddressOf Me.Timer1_Elapsed)
_timer.Enabled = True
'RockAndRoll
SBO_Application.ActivateMenuItem("520")
Now impement the timer eventhandler (thread safe, you can send any keys like ENTER which closes the print dialog box and ESC when you would like to cancel
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs)
Dim lHwnd As Integer = GetForegroundWindow
If lCurHwnd = lHwnd Then Exit Sub
' Send enter key to Commit the dialog window
System.Windows.Forms.SendKeys.SendWait("{ENTER}")
'Stop timer
_timer.Enabled = False
End Sub
Regards,
J
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.