Sendkeys from WPF application

大兔子大兔子 提交于 2019-12-24 00:16:00

问题


I have an WPF full screen application and I configured Skype´s "Focus Skype" Hotkey to Ctrl+F6 combination.

Now... How can I send this message to windows (Ctrl+F6)? I tried by sendkeys but is not working, it says that: "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."

I tried Sendkeys.sendwait method but it minimized my full screen application and I need it remains full screen.

any help or clue?

Thanks in advance


回答1:


Try this:

Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)

Private Const kbdDown = 0
Private Const kbdUp = 2



Private Sub SendKey(ByVal Key As Byte)
    Call keybd_event(Key, 0, kbdDown, 0)
    Call keybd_event(Key, 0, kbdUp, 0)

End Sub

The keycodes can be viewed here: http://www.codeproject.com/KB/system/keyboard.aspx



来源:https://stackoverflow.com/questions/6408168/sendkeys-from-wpf-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!