Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programatically opening the On Screen Keyboard 4

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
542
MU
Hi,

Anyone has an idea how we can open the Windows OSK (On Screen Keyboard, osk.exe) programatically?
In fact, for example, I want to invoke OSK upon clicking a button.

Thanks
 
Mike,

Mike said:
Rajesh, I was going to ask you if you had considered building your own keyboard?

Yes, for time being only a Num pad, not full keyboard. Anyway, I was not building a generalized keyboard but only wanted to have for current form I am working on. I made a container with numeric keys turning its Visible on/off as required and it works for my purpose.

Rajesh


 
strongm,

It invokes the OSK upon click of a button. Works fine!

My need is actually for a form which is supposed to work on a touch screen where there is no keyboard/mouse.
So, now my problem is, how do I close the OSK programmatically, once the user confirms (by touching Enter) what he was typing?

In my current form, where I have my own Num pad, I take off the Num Pad, once user touch Enter and in that case, many of my Textboxes will run its 'VALID'/'LOSTFOCUS' etc as the case maybe, processing it further.

But, with our Windows OSK, all these controls are not in my hands, I suppose!

However, dear strongm,
I have many other ideas coming up in my mind (not for OSK though).
Thank you very much for triggering that... :)

Rajesh
 
>So, now my problem is, how do I close the OSK programmatically

Just run the code I provided a second time ...
 
strongm,

Oh..... was it that simple?!
I didn't think that way.
Now, let me check if all these can be turned to match my requirements.

Thank you dear
Rajesh
 
Dear strongm / Dear others,

It seems fantastic now!
I can activate/deactivate OSK from a button on the form.

Now, I want to check if OSK is already activated or not.
I tried WEXISTS(), WONTOP() etc with the Title "On-Screen Keyboard" that OSK shows.
But, that's not the name we have to refer, it seems!

Any idea?
To go through Windows Processes is one way? Let me check it.

Rajesh
 
Hi All,

I managed to determine if on screen keyboard is running or not by checking OSK.EXE in Win32_Process

Thanks
Rajesh
 
I thought another approach for Win10 could be to KEYBOARD Win+Ctrl+o, which would pop up the OSK. But apparently VFP has no code for the Win key (that I could find, anyway). Srongm's code is a great workaround though!

Steve
 
>I tried WEXISTS(), WONTOP() etc with the Title "On-Screen Keyboard" that OSK shows.

Try something like the following

Code:
[COLOR=blue]DECLARE INTEGER FindWindowEx IN user32;
	INTEGER  hwndParent,;
	INTEGER  hwndChildAfter,;
	STRING @ lpszClass,;
	STRING @ lpszWindow

OSKRunning = FindWindowEx(0, 0, "OSKMainClass", "On-Screen Keyboard") <> 0[/color]
 
Strongm,

I have already managed to determine if the On screen keyboard is running or not by checking OSK.EXE in Win32_Process.
It's working.

Anyway, I will make your code as a procedure and try to use it.
Thank you.

Rajesh

 
Win32_process normally indicated the use of WMI and, whilst very useful, WMI quite slow. So just thought I'd offer a faster alternative more in keeping with you own easier efforts (I.e. looking for the window)
 
strongm / other friends,

The OSK toggle code which works in Win 10 doesn't seem to work in Windows Server 2016 Datacenter.
I mean, it's the Shortcut key combination that doesn't work. If I Run osk.exe, it opens up.

Too, Mike's code with ShellExecute and your subsequent suggestion of same with 'Wow64EnableWow64FsRedirection',
both did not work.

Are these problems because of a security concern in Win Server 2016?

Any idea?

Rajesh
 
If you physically press win + ctrl + o. Does it work? You may need to enable OSK on 2016 data center in settings

 
strongm said:
If you physically press win + ctrl + o.

strongm,

It works on my Win10 machine. One time it didn't. Can't recall what I did. Reliability?

Also it worked when I clicked on osk.exe in C:\Windows\System32\. But I couldn't make it work using the RUN command. Don't know why.

In any case, it seems your code is the best solution. Thanks for that!

Steve
 
strongm,

strongm said:
So just thought I'd offer a faster alternative more in keeping with you own easier efforts (I.e. looking for the window)
Yes, I will check this also for sure. As you know, my purpose was to determine if the OSK is already open as I want to show it when focus comes to Textbox, Combo, Grid etc where user input is acceptable, which is further based on a configuration setting if the OSK needs to be shown automatically or not.

strongm said:
If you physically press win + ctrl + o. Does it work?
I can see that On Screen Keyboard is 'ON' in Windows 2016 Data Centre server under
Settings -> Ease Of Access -> Keyboard. However, if I physically press win + ctrl + o, nothing happens!
Could be a restriction by design because its a 'Server' and not a normal Win 10 pc.
Let me check further.

Thank you
Rajesh

 
Dear all

Now, I am using a keyboard made based on the Vfp Toolbar control. I got the idea to use Toolbar control from Tek-Tips itself I believe. But, I missed to note down the thread url. Let me check. I will post it here.

I made two classes for two keyboards, one with alphabets and numeric keypad (attached pic) and the other with only numeric keypad. I create an object in my startup program and invoke it whenever I need, in any of my forms.

Below is how my keyboard looks like:

Screenshot_2022-10-27_161702_ev8uig.png


As it is based on Toolbar control, I don't have to worry about playing with the focus on my controls.

By the way, I was just trying if I can remove the Title bar shown with keyboard. But, being based on Toolbar, that's not possible it seems.

Thanks everyone.
Rajesh
 
Looks nice, Rajesh. Well done.

You say you made two separate classes. That's fine, But my first thought was that it would be better to create a single class, showing the full keyboard, and then to sub-class it, with the alphabetic part made invisible in the sub-class. (Perhaps that's what you did.)

Another approach would be to make a single class showing the full keyboard, but to have it accept a parameter which says whether the alphabetic part is visible. That would allow you to toggle between the two layouts at run time, perhaps according to the user's preference.

I just thought I'd mention this. You have clearly put a lot of work into this, whereas I have only seen it for the first time. So feel free to ignore these suggestions.

As for the title bar, you probably know that is not visible while the toolbar is docked. Have you considered doing that? Of course, there are pros and cons to that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top