AW: Bildschirmtastatur Windows Tablet
25.05.2018 14:04:43
Nepumuk
Hallo Phil,
im Modul deiner UserForm:
Private Sub TextBox1_Enter()
Call LoadScreenKeyboard
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call UnloadScreenKeyboard
End Sub
In einem Standardmodul:
' **********************************************************************
' Modul: basKeyboard Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Option Private Module
Private Declare PtrSafe Function GetCurrentProcess Lib "kernel32.dll" () As LongPtr
Private Declare PtrSafe Function IsWow64Process Lib "kernel32.dll" ( _
ByVal hProcess As LongPtr, _
ByRef Wow64Process As LongPtr) As Long
Private Declare PtrSafe Function ShellExecuteA Lib "shell32.dll" ( _
ByVal Hwnd As LongPtr, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Declare PtrSafe Function Wow64EnableWow64FsRedirection Lib "kernel32.dll" ( _
ByVal Enable As Boolean) As Boolean
Private Const SW_SHOWNORMAL As Long = 1&
Public Sub LoadScreenKeyboard()
Dim lngptrIsWow64 As LongPtr, lngptrProcess As LongPtr
lngptrProcess = GetCurrentProcess
Call IsWow64Process(lngptrProcess, lngptrIsWow64)
If lngptrIsWow64 = 0 Then
Call ShellExecuteA(Application.Hwnd, "open", "osk.exe", vbNullString, "C:\Windows\System32\", SW_SHOWNORMAL)
Else
Call Wow64EnableWow64FsRedirection(False)
Call ShellExecuteA(Application.Hwnd, "open", "osk.exe", vbNullString, "C:\Windows\System32\", SW_SHOWNORMAL)
Call Wow64EnableWow64FsRedirection(True)
End If
End Sub
Public Sub UnloadScreenKeyboard()
Dim objWMI As Object, objProcessList As Object, objProcess As Object
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objProcessList = objWMI.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'osk.exe'")
For Each objProcess In objProcessList
Call objProcess.Terminate
Next
Set objProcessList = Nothing
Set objWMI = Nothing
End Sub
Gruß
Nepumuk