 Registrato il: Wed Sep 19 2007, 03:42PM messaggi: 617
| Colin and Judy Jeffress: Here is the code (in typical format) that works in VB.NET so that others may not have to muddle through it as I did.
Const WM_CSKEYBOARD = &H400 + 192
Const WM_CSKEYBOARDMOVE = &H400 + 193
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
'Open/show the Comfort Onscreen Keyboard
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim hWnd As Integer
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm")
PostMessage(hWnd, WM_CSKEYBOARD, 1, 0)
End Sub
'Close the Comfort Onscreen Keyboard
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim hWnd As Integer
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm")
PostMessage(hWnd, WM_CSKEYBOARD, 2, 0)
End Sub
'Move the Comfort Onscreen Keyboard; Move it first then show it
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim hWnd As Integer
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm")
PostMessage(hWnd, WM_CSKEYBOARDMOVE, 200, 200)
PostMessage(hWnd, WM_CSKEYBOARD, 1, 0)
End Sub
'Toggle the Comfort Onscreen Keyboard
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim hWnd As Integer
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm")
PostMessage(hWnd, WM_CSKEYBOARD, 4, 0)
End Sub
'Fade the Comfort Onscreen Keyboard
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim hWnd As Integer
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm")
PostMessage(hWnd, WM_CSKEYBOARD, 3, 0)
End Sub
'Change the keyboard type and show it
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
'Change the Registry entry for the required keyboard
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\ComfortSoftware\CKeyboard", "KeyboardName", "Name of your chosen keyboard")
'Open the keyboard
Dim hWnd As Integer
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm")
PostMessage(hWnd, WM_CSKEYBOARD, 1, 0)
End Sub
'Change to another keyboard type and show it
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
'Change the Registry entry for the required keyboard
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\ComfortSoftware\CKeyboard", "KeyboardName", "Name of another chosen keyboard")
'Open the keyboard
Dim hWnd As Integer
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm")
PostMessage(hWnd, WM_CSKEYBOARD, 1, 0)
End Sub
Have a nice day |