-
Sep 23rd, 2014, 01:40 PM
#1
Thread Starter
Member
[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?
-
Sep 23rd, 2014, 02:26 PM
#2
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?
-
Sep 23rd, 2014, 03:01 PM
#3
Thread Starter
Member
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.
-
Sep 23rd, 2014, 03:41 PM
#4
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
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Sep 23rd, 2014, 04:55 PM
#5
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
-
Sep 24th, 2014, 03:19 AM
#6
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 24th, 2014, 07:42 AM
#7
Thread Starter
Member
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.
-
Sep 24th, 2014, 10:39 AM
#8
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
Last edited by jmsrickland; Sep 24th, 2014 at 12:21 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Sep 24th, 2014, 11:53 AM
#9
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
-
Sep 24th, 2014, 06:21 PM
#10
Re: Onscreen Keyboard No Workie
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 24th, 2014, 08:09 PM
#11
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
Last edited by DrUnicode; Sep 25th, 2014 at 08:56 AM.
Reason: 64bit OS Solution for OSK.exe
-
Sep 24th, 2014, 09:22 PM
#12
Addicted Member
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.
If I had helped you...
Don't forget to mark your Inquiry as RESOLVED...
I will be glad if you can also give me some Reputation points in helping you (by Clicking Rate This Post)...
Happy VB Coding Everyone!
-
Sep 24th, 2014, 10:25 PM
#13
Re: Onscreen Keyboard No Workie
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 25th, 2014, 02:20 AM
#14
Re: Onscreen Keyboard No Workie
On XP you can simply Shell "osk.exe" without any problems
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Sep 25th, 2014, 07:32 AM
#15
Thread Starter
Member
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...
-
Sep 25th, 2014, 08:49 AM
#16
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
-
Sep 25th, 2014, 09:08 AM
#17
Thread Starter
Member
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?
-
Sep 25th, 2014, 09:11 AM
#18
Re: Onscreen Keyboard No Workie
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.
-
Sep 26th, 2014, 07:25 PM
#19
Re: Onscreen Keyboard No Workie
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?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 26th, 2014, 08:20 PM
#20
Re: [RESOLVED] Onscreen Keyboard No Workie
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?
-
Sep 26th, 2014, 11:13 PM
#21
Re: [RESOLVED] Onscreen Keyboard No Workie
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 26th, 2014, 11:24 PM
#22
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
Last edited by DrUnicode; Aug 9th, 2017 at 11:16 AM.
Reason: Implemented changes bby LaVolpe
-
Jan 15th, 2016, 10:01 AM
#23
Registered User
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...
-
Aug 9th, 2017, 08:57 AM
#24
New Member
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?
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
-
Aug 9th, 2017, 09:55 AM
#25
Re: [RESOLVED] Onscreen Keyboard No Workie
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
-
Aug 9th, 2017, 10:43 AM
#26
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
Last edited by DrUnicode; Aug 9th, 2017 at 10:48 AM.
-
Aug 9th, 2017, 10:52 AM
#27
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
-
Aug 9th, 2017, 11:30 AM
#28
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
-
Aug 9th, 2017, 01:00 PM
#29
New Member
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?
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
-
Aug 10th, 2017, 09:21 AM
#30
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.
-
Aug 10th, 2017, 10:13 AM
#31
New Member
Re: [RESOLVED] Onscreen Keyboard No Workie
it doesn't work. The keyboard doesn't display when I click on the textbox...
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|