Trigger Windows 10 On-screen Keyboard using VBA (1 Viewer)

jmaty23

Registered User
Joined
Jul 24, 2012
Messages
52
My apologies if this question has already been asked and if so, I cannot seem to find it.

I am working on building a front-end Access database that will be running on a Windows 10 Tablet.

What I would like to be able to do is trigger the tablet on-screen keyboard that shows up when you click the keyboard icon that resides in the lower right hand corner of the screen. (To the left of the clock.)

I've include 2 images as attachments. One images shows the keyboard button that i'm talking about and the other shows the actual keyboard that i'm trying to show/hide on the screen using VBA.

If anyone could point me to an API or function that they have been able to get to work, i'd appreciate it.
 

Attachments

Tieval

Still Clueless
Joined
Jun 26, 2015
Messages
429
I believe UncleGizmo did a tutorial on this and am sure he will be along to point you in the right direction
 

jmaty23

Registered User
Joined
Jul 24, 2012
Messages
52
I was able to create this subroutine to make the keyboard show. Thanks for the post!

Sub Keyboard()
On Error GoTo ErrorHandler

Call ShellEx("C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")

ProcedureExit:
Exit Sub

ErrorHandler:
MsgBox "Error" & ": " & Err.Number & vbCrLf & "Description: " _
& Err.Description, vbExclamation, "Module1.Keyboard"
Resume ProcedureExit

End Sub
 

fatkarl

New member
Joined
Mar 9, 2017
Messages
1
Thanks Jmaty,

Do you mind posting what you have for ShellEx? I'm not having luck with the versions of ShellExecute I've found...
 
Joined
Feb 5, 2020
Messages
2
this worked fine for us on Win 10 MS access 2013

it is available throughout the project. Hopefully it will help others



Dim lngPtr As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

'Call Wow64DisableWow64FsRedirection prior to calling ShellExecute and Wow64RevertWow64FsRedirection, immediately after.
Private Declare Function Wow64DisableWow64FsRedirection Lib "kernel32.dll" (ByRef ptr As Long) As Boolean
Private Declare Function Wow64RevertWow64FsRedirection Lib "kernel32.dll" (ByRef ptr As Long) As Boolean
Public Function ShowKeyboard()
Call Wow64DisableWow64FsRedirection(lngPtr)
ShellExecute 0, "open", "osk.exe", "", "", vbNormalFocus
Call Wow64RevertWow64FsRedirection(lngPtr)
End Function

Public Function HideKeyboard()
Call Wow64DisableWow64FsRedirection(lngPtr)
ShellExecute 0, "open", "tskill", "osk", "", vbHidden
Call Wow64RevertWow64FsRedirection(lngPtr)
End Function
 

isladogs

CID Moderator
Staff member
Joined
Jan 14, 2017
Messages
12,330
Hi 'Access Database Developer' and welcome to the forum
I'm amazed that username was available. Surprising its never been used before in the past 20 years of AWF

=============================================================

Anyway, to show yet again that there are several ways of doing the same thing...
I posted the attached DEMO a couple of years ago but have been unable to find the thread with the new search facility:

Capture.PNG

The DEMO app allows you to use either of the two different on-screen keyboards that can be used:
1. osk.exe - the old accessibility keyboard
2. tabtip.exe - the newer keyboard designed for tablets but available on any workstation

The code I use is similar to that in post #4
This code is used in a standard module and works in both 32-bit and 64-bit:

SQL:
Option Compare Database
Option Explicit

'###############################################
#If VBA7 Then 'use PtrSafe & LongPtr
    Private Declare PtrSafe Function apiShellExecute Lib "shell32.dll" _
        Alias "ShellExecuteA" _
        (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
#Else
    Private Declare Function apiShellExecute Lib "shell32.dll" _
        Alias "ShellExecuteA" _
        (ByVal hWnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As Long) _
        As Long
#End If
'###############################################

Public strApp As String

Public Function RunOSK()

'opens on screen keyboard if opened in tablet mode
'To test it on a standard PC, disable the 'If ...End If
'If modMetrics.System(SM_TABLETPC) Then
    apiShellExecute 0, vbNullString, "osk.exe", vbNullString, "C:\", 1
'   ShellEx "c:\windows\system32\osk.exe", , True
   strApp = "osk.exe"
'End If

End Function
Public Sub ShellEx(ByVal Path As String, Optional ByVal Parameters As String, Optional ByVal HideWindow As Boolean)

    If Dir(Path) > "" Then
        apiShellExecute 0, "open", Path, Parameters, "", IIf(HideWindow, 0, 1)
    Else
        MsgBox "Can't find application"
    End If

End Sub

Public Function OpenTabTip()

'opens tablet screen keyboard in tablet mode
'To test it on a standard PC, disable the 'If ...End If
'If modMetrics.System(SM_TABLETPC) Then
    ShellEx "C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe", , True
    strApp = "TabTip.exe"
'End If

End Function
Then in the form you just need to use either RunOSK or OpenTabTip on a button click or Form_Load event.
I have done that but in a slightly different way in the attached
 

Attachments

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom