Results 1 to 4 of 4
  1. #1
    Rico is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    Perth Australia
    Posts
    31

    Post Trying to open the on screen keyboard


    I need code to open the on screen keyboard in form open or load.
    I am running windows 11.
    I have looked through the forum without much success.
    Any help would be greatly appreciated.
    Thanks, Rico

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    After giving me 5 false starts (and apologizing profusely after each failure) Copilot gave me this which works with my 32 bit access 365 in 64 bit Win 11
    Code:
    Private Sub Form_Open(Cancel As Integer)
        On Error Resume Next
        Shell "cmd.exe /c start """" ""%SystemRoot%\System32\osk.exe""", vbHide
        If Err.Number <> 0 Then
            MsgBox "Failed to launch OSK. Error: " & Err.Number, vbExclamation
        End If
        On Error GoTo 0
    End Sub

  3. #3
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,205
    There are in fact two on-screen keyboards
    The older version is called osk.exe and was designed as an accessibility control
    The newer version was mainly designed for use with tablets and is called tabtip.exe. This is the one I normally use and is usually loaded from my system tray area

    I also have code to load both of these which is available from my article: Running Access on a Tablet PC
    Suggest downloading the example app from my article to test out both on screen keyboards

    The code has changed over the years in line with changes in Windows
    Here are the main items of code

    1. Run OSK

    Code:
    Option Compare DatabaseOption Explicit
    
    
    '###############################################
    #If VBA7 Then 'A2010 or later - 32/64-bit
        Private Declare PtrSafe Function ShellExecute 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 'A2007 or earlier
        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
    #End If
    '###############################################
    
    
    Dim lngPtr As Long
    
    
    'Call Wow64DisableWow64FsRedirection prior to calling ShellExecute and Wow64RevertWow64FsRedirection, immediately after.
    'Disables file system redirection for the calling thread. File system redirection is enabled by default.
    #If VBA7 Then 'A2010 or later - 32/64-bit
         Private Declare PtrSafe Function Wow64DisableWow64FsRedirection Lib "kernel32.dll" (ByRef ptr As Long) As Boolean
         Private Declare PtrSafe Function Wow64RevertWow64FsRedirection Lib "kernel32.dll" (ByRef ptr As Long) As Boolean
    #Else  'A2007 or earlier
        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
    #End If
    
    
    Public Function RunOSK()
    
    
    '=====================================================
    'Colin Riddington - Mendip Data Systems
    'Updated 21/06/2021
    
    
    'opens on screen keyboard if opened in tablet mode
    'To test it on a standard PC, disable the 'If ...End If
    
    
    'NOTE: Settings have changed in recent years
    ' For 32-bit Access, must now Call Wow64DisableWow64FsRedirection prior to calling ShellExecute and Wow64RevertWow64FsRedirection, immediately after.
    
    
    'Alternatively enable in Windows Settings ...Ease of Access...Keyboard
    'OR just press Win+Ctrl+O
    
    
    '=====================================================
    
    
    'If modMetrics.System(SM_TABLETPC) Then
        #If Win64 Then
            ShellExecute 0, "open", "osk.exe", vbNullString, "c:\", 1
        #Else
            Call Wow64DisableWow64FsRedirection(lngPtr)
            ShellExecute 0, "open", "osk.exe", vbNullString, "c:\", 1
            Call Wow64RevertWow64FsRedirection(lngPtr)
        #End If
    'End If
    
    
    End Function
    2. Open TabTip

    Code:
    Public Function OpenTabTip()
    
    
    ''=====================================================
    'Colin Riddington - Mendip Data Systems
    '18/09/2018
    
    
    '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
        #If Win64 Then
            ShellEx "C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe", , True
        #Else
            Call Wow64DisableWow64FsRedirection(lngPtr)
            ShellEx "C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe", , True
            Call Wow64RevertWow64FsRedirection(lngPtr)
        #End If
    'End If
    
    
    End Function
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  4. #4
    Rico is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    Perth Australia
    Posts
    31
    Thanks to davegri and isladogs for their quick reply.
    I will use the osk.exe this time, but keep the tabtip.exe for future use.
    Rico

Please reply to this thread with any new information or opinions.

Similar Threads

  1. MS Access Form and On Screen Keyboard
    By ramirezx@ddmfg.com in forum Access
    Replies: 3
    Last Post: 11-18-2021, 11:40 AM
  2. Replies: 3
    Last Post: 09-13-2018, 04:10 PM
  3. usu screen keyboard in access
    By Cuasitos in forum Programming
    Replies: 3
    Last Post: 05-13-2018, 10:30 PM
  4. Calling the on screen keyboard
    By redekopp in forum Access
    Replies: 10
    Last Post: 05-25-2017, 04:16 PM
  5. Replies: 11
    Last Post: 06-05-2011, 09:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums