cancel
Showing results for 
Search instead for 
Did you mean: 

vb.net : SendKeys.Send don't work , SendKeys.SendWait -->deadlock

Former Member
0 Kudos

hi,

i active the printer dialog by menu 520 and want to send some keys.


moSBOApplication.ActivateMenuItem("520") 
...
i fetch the printer dialogue by the MENU-EVENT
Select Case pVal.MenuUID
            Case "520":
                        SendKeys.SendWait("E")
                        SendKeys.SendWait("{TAB}")
                        SendKeys.SendWait("{ENTER}")

My code worked well in vb6, but now i need the same behaviour in vb.net, but it don't seem to work.

In vb6 i used sendkeys.send("E")

when i use this in vb.net there is the following error:

SendKeys cannot run inside this application because the application is not handling Windows messages. Either change the application to handle messages, or use the SendKeys.SendWait method.

But when i use sendkeys.sendwait("E") the systems will stay in deadlock and i get no controll anymore.

Does anybody knows how to solve this?

thanks

Markus

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I posted a new message for you...

Former Member
0 Kudos

nobody an idea?

Former Member
0 Kudos

i really need help.

AdKerremans
Active Contributor
0 Kudos

Hi Markus,

I did also have problems sending keys to a windows form from SBO.

If we want to control printing from SBO we use Word and the Office API.

This way I have total control over the printing.

Regards

Ad

Former Member
0 Kudos

hi Ad,

i already heard about this technique, but its not what i want. I want to control the printer dialog. I need this function for an addon which is used by different customers and i don't want to create layouts in word.

thanks

Markus

AdKerremans
Active Contributor
0 Kudos

Hi Markus,

I think I have to disappoint you, because there is no option to fully control Windows forms from SBO.

It has already been asked in the forum.

Regards

Ad

Former Member
0 Kudos

Hi together,

I had the same problem. But I solved it by using a new thread.

1st) The major problem is, that the printer dialog is modal to SBO and you are not able to send commands like sendkeys. One possibility is to fill the keyboard buffer with hundred of TAB and ENTER Keys but that's not very nice.

2nd) In my first try I started a new thread before activating the SBO Menu Item. The Thread looked by using WinAPI for the printer window (you should look for the child windows of your SBO application, to verify that your get the right window) and then send TAB and ENTER. It works fine.

3rd) In my last try and this is the way I am doing print jobs now, is to post a new click message into the windows message queue. So my program simulates a mouseclick to the Print button.

If you want to get some code... feel free to ask!

Regard,

Sebastian