-
[RESOLVED] Onscreen Keyboard No Workie
I have an application for a Windows 8 tablet that is a modified VB6.0 program and needs a keyboard input. I am trying to use Microsoft's onscreen keyboard, by accessing osk.exe. I have attempted different configurations all resulting in errors, but the one I have tested successfully in Windows XP, but won't work in newer versions of Windows, is this:
Private Sub Command1_Click()
Shell "OSK.EXE", vbMaximizedFocus
End Sub
Which results in:
"Invalid procedure call or argument."
Very simple. Should work. Doesn't. Hmm?
-
Re: Onscreen Keyboard No Workie
Initial guess: file doesn't exist, permissions preventing execution or executing from file's location. Just curious, is this a 64 bit system? Have you tried ShellExecute APis?
-
Re: Onscreen Keyboard No Workie
When I use ShellExecute, I get an error that seems closer to functional: "Could not start On-screen Keyboard."
ShellExecute Me.HWND, vbNullString, "C:\Windows\System32\osk.exe", vbNullString, "C:\", SW_SHOWNORMAL
But still not functional. The link is good. I would love for something like "Shell "OSK.EXE"" to work, because I don't want to have to count on the path being identical in a new computer.
And yes, this is a 64-bit system.
-
Re: Onscreen Keyboard No Workie
You say the link is good so that means it is locating osk.exe but you then say it is not functional. By that I assume it is executed but just doesn't work. Is this correct
-
Re: Onscreen Keyboard No Workie
Is the screen a touch screen? I'd wonder if the OSK doesn't work on non-touchscreen systems.
-tg
-
Re: Onscreen Keyboard No Workie
This code works to open On Screen Keyboard
In a module
Code:
Option Explicit
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
In a form
Code:
Option Explicit
Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "C:\Windows\System32\osk.exe", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
However, when osk loads you receive "Could not start On-Screen keyboard". That is despite the program being loaded in the background.
-
Re: Onscreen Keyboard No Workie
I can manually open osk.exe without any problem, but the ShellExecute command always gives the error "Could not start on-screen keyboard." I have it set up as in the example provided by Nightwalker 83.
-
Re: Onscreen Keyboard No Workie
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Private Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "C:\Windows\System32\osk.exe", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Works for me. I'm using XP/SP4 which you also say that XP is the only OS where you got it to work so it must not be compatible with other OS's; only thing I can think of. Is the osk.exe part of your OS's applications or did you copy it from somewhere else and place it in your OS
I notice if Shell cannot find the EXE it gives no messages at all
Doesn't sound right for ShellExecute to give error "Could not start on-screen keyboard." I would think it would say "Could not start osk.exe" since Shell would not know that osk means on-screen-keyboard and also it would give an error code if it gives any message at all
-
Re: Onscreen Keyboard No Workie
I don't think the error is coming from Shell... sounds like it's coming from OSK itself. It's looking for something in its initialization that it is not finding.
-tg
-
Re: Onscreen Keyboard No Workie
Quote:
Originally Posted by
jmsrickland
Works for me. I'm using XP/SP4 which you also say that XP is the only OS where you got it to work so it must not be compatible with other OS's; only thing I can think of. Is the osk.exe part of your OS's applications or did you copy it from somewhere else and place it in your OS
It is part of Windows 7 or put in the above located by a system update. All I did was type "OSK" in to the computer search and it came up as a result.
-
Re: Onscreen Keyboard No Workie
This appears to be an issue on x64 OS only.
This works on Windows 7 Ultimate x64:
Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal LpszDir As String, ByVal FsShowCmd As Long) As Long
Private Declare Function Wow64EnableWow64FsRedirection Lib "kernel32.dll" (ByVal Enable As Boolean) As Boolean
Private Sub Command1_Click()
Const SW_SHOWNORMAL = 1
On Error Resume Next
Wow64EnableWow64FsRedirection False
ShellExecute Me.hwnd, "open", "osk.exe", "", App.Path, SW_SHOWNORMAL
Wow64EnableWow64FsRedirection True
End Sub
-
Re: Onscreen Keyboard No Workie
I tried his code:
But it's not working we have the same error...
I tried using API call for the OSK.exe. it runs smoothly.
I'm using Windows 7 Ultimate 32-Bit.
-
Re: Onscreen Keyboard No Workie
Quote:
Originally Posted by
DrUnicode
This appears to be an issue on x64 OS only.
This works on Windows 7 Ultimate x64
I was using Windows 7 x32bit when I tried the code I posted above.
-
Re: Onscreen Keyboard No Workie
On XP you can simply Shell "osk.exe" without any problems
-
Re: Onscreen Keyboard No Workie
I am running Windows 7 64-bit. It seems clear to me at this point that this is an issue on my computer. Possibly in my VB installation? I guess the problem isn't resolved, but I can't expect anyone else to help me who can't repeat the problem...
-
Re: Onscreen Keyboard No Workie
Apparently you did not try the solution at http://www.vbforums.com/showthread.p...=1#post4762329
The issue is on 64bit OS where you have to disable WOW 64 redirection and then re-enable after calling OSK.exe
-
Re: Onscreen Keyboard No Workie
Dang. I didn't see that post. DrUnicode, you are absolutely correct! It works!
I don't understand exactly what this is doing. If it is disabling WOW 64 redirection, could that cause problems?
-
Re: Onscreen Keyboard No Workie
Quote:
I don't understand exactly what this is doing. If it is disabling WOW 64 redirection, could that cause problems?
It is only turning it off so that we can call the 32bit version of OSK.exe. It then immediately turns redirection back on. I don't see any problems here.
-
Re: Onscreen Keyboard No Workie
Quote:
Originally Posted by
DrUnicode
It is only turning it off so that we can call the 32bit version of OSK.exe. It then immediately turns redirection back on. I don't see any problems here.
Although, I did notice that the program stops responding for a few seconds while attempting to close OSK! Is there a way to stop this?
-
Re: [RESOLVED] Onscreen Keyboard No Workie
Quote:
Although, I did notice that the program stops responding for a few seconds while attempting to close OSK! Is there a way to stop this?
Closes right away on my machine.
Can other x64 users verify this?
-
Re: [RESOLVED] Onscreen Keyboard No Workie
Quote:
Originally Posted by
DrUnicode
Closes right away on my machine.
Can other x64 users verify this?
I am using x32 I my pc which, I am using to write this post! That method was the only way I could get VB6 to open OSK without problems.
-
Re: [RESOLVED] Onscreen Keyboard No Workie
Here is another version that detects x64. x86 only needs the ShellExecute.
At least this version gets rid of the On Error Resume Next:
Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal LpszDir As String, ByVal FsShowCmd As Long) As Long
Private Declare Function Wow64EnableWow64FsRedirection Lib "kernel32.dll" (ByVal Enable As Boolean) As Boolean
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProc As Long, bWow64Process As Long) As Long
Private Sub Command1_Click()
If Is64bit Then
Wow64EnableWow64FsRedirection False
ShellExecute 0, "open", "osk.exe", "", "", vbNormalFocus
Wow64EnableWow64FsRedirection True
Else
ShellExecute 0, "open", "osk.exe", "", "", vbNormalFocus
End If
End Sub
Public Function Is64bit() As Long
If GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process") > 0 Then
IsWow64Process GetCurrentProcess(), Is64bit
End If
End Function
-
Re: [RESOLVED] Onscreen Keyboard No Workie
I had the same issue.
I just restarted my vb6 project and
Shell "C:\Windows\System32\OSK.EXE"
command worked for me...
-
Re: [RESOLVED] Onscreen Keyboard No Workie
Hello,
I've been trying to do what you all suggested but I don't seem to achieve it.
I'm trying to run this on a tablet with W10 64bits.
Any suggestion?
Quote:
Originally Posted by
DrUnicode
Here is another version that detects x64. x86 only needs the ShellExecute.
At least this version gets rid of the On Error Resume Next:
Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal LpszDir As String, ByVal FsShowCmd As Long) As Long
Private Declare Function Wow64EnableWow64FsRedirection Lib "kernel32.dll" (ByVal Enable As Boolean) As Boolean
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProc As Long, bWow64Process As Boolean) As Long
Private Sub Command1_Click()
If Is64bit Then
Wow64EnableWow64FsRedirection False
ShellExecute Me.hwnd, "open", "osk.exe", "", App.Path, vbNormalFocus
Wow64EnableWow64FsRedirection True
Else
ShellExecute Me.hwnd, "open", "osk.exe", "", App.Path, vbNormalFocus
End If
End Sub
Public Function Is64bit() As Boolean
If GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process") > 0 Then
IsWow64Process GetCurrentProcess(), Is64bit
End If
End Function
-
Re: [RESOLVED] Onscreen Keyboard No Workie
Quote:
Originally Posted by
carotsss
Hello,
I've been trying to do what you all suggested but I don't seem to achieve it.
I'm trying to run this on a tablet with W10 64bits.
Any suggestion?
An idea. The IsWow64Process API declaration is incorrect, following includes changes (in blue)
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal LpszDir As String, ByVal FsShowCmd As Long) As Long
Private Declare Function Wow64EnableWow64FsRedirection Lib "kernel32.dll" (ByVal Enable As Boolean) As Boolean
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProc As Long, bWow64Process As Long) As Long
Private Sub Command1_Click()
If Is64bit Then
Wow64EnableWow64FsRedirection False
ShellExecute Me.hwnd, "open", "osk.exe", "", App.Path, vbNormalFocus
Wow64EnableWow64FsRedirection True
Else
ShellExecute Me.hwnd, "open", "osk.exe", "", App.Path, vbNormalFocus
End If
End Sub
Public Function Is64bit() As Long
If GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process") > 0 Then
IsWow64Process GetCurrentProcess(), Is64bit
End If
End Function
-
Re: [RESOLVED] Onscreen Keyboard No Workie
Changed to bWow64Process As Long and it still works OK here on Win10 x64 Ver 1703.
Update code at http://www.vbforums.com/showthread.p...=1#post4763319
-
Re: [RESOLVED] Onscreen Keyboard No Workie
Without change in API declare from boolean to long, bad DLL calling convention error received in VBA.
With change noted, works in VBA module also, x64, if you remove the Me & App references, i.e...
ShellExecute 0, "open", "osk.exe", "", "", vbNormalFocus
-
Re: [RESOLVED] Onscreen Keyboard No Workie
Seems to work just fine, pretty much anywhere:
Code:
'Use late binding because Microsoft has failed to maintain binary compatibility
'for Shell32.dll between different versions of Windows.
Const ssfSYSTEM = 37
With CreateObject("Shell.Application")
.NameSpace(ssfSYSTEM).ParseName("osk.exe").InvokeVerb "open"
End With
-
Re: [RESOLVED] Onscreen Keyboard No Workie
ok, (i'm a beginner on this). So I should create a new modul and put this code on...
and then, how do I call it in the textboxt I want the keyboard to appear on?
Quote:
Originally Posted by
dilettante
Seems to work just fine, pretty much anywhere:
Code:
'Use late binding because Microsoft has failed to maintain binary compatibility
'for Shell32.dll between different versions of Windows.
Const ssfSYSTEM = 37
With CreateObject("Shell.Application")
.NameSpace(ssfSYSTEM).ParseName("osk.exe").InvokeVerb "open"
End With
-
Re: [RESOLVED] Onscreen Keyboard No Workie
It may make more sense to take a look at:
How to automatically display the touch keyboard in Windows 10 desktop mode
The OSK is a keyboard, it isn't anchored to input to any specific control. The keystrokes go to whatever control has focus.
Tablet input has changed from version to version of Windows anyway, and these days can vary based on what type(s) of digitizers are present and active. Things work differently for low-res capacitive fat finger digitizers and hi-res stylus digitizers.
-
Re: [RESOLVED] Onscreen Keyboard No Workie
it doesn't work. The keyboard doesn't display when I click on the textbox...
Quote:
Originally Posted by
dilettante
It may make more sense to take a look at:
How to automatically display the touch keyboard in Windows 10 desktop mode
The OSK is a keyboard, it isn't anchored to input to any specific control. The keystrokes go to whatever control has focus.
Tablet input has changed from version to version of Windows anyway, and these days can vary based on what type(s) of digitizers are present and active. Things work differently for low-res capacitive fat finger digitizers and hi-res stylus digitizers.