Sendkeys from WPF application

2019-07-09 20:10发布

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条回答
霸刀☆藐视天下
2楼-- · 2019-07-09 20:43

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

查看更多
登录 后发表回答