On-screen keyboard in Windows Universal App on Windows IoT? - c#

Is it possible to show the On-Screen Keyboard (osk) in a Windows Universal App on Windows 10 IoT Core?
The raspberry pi only has a mouse attached and when I click on a textbox I'd like to show the osk.
I can set the InputScope and IsTextPredictionEnabled but can't figure out how to trigger the osk to show.

There is an example here of an on screen keyboard. If you look at the sample they are using one in their web browser. This is a pretty good keyboard but it would be better to have the default windows keyboard
https://github.com/ms-iot/samples/tree/develop/DigitalSign
If it was up to me I would prefer the default OSK since you can specify slightly different keyboard layouts based on inputs. I don't like this one because the text box loses focus which can limit the use of action listeners that you can use. Hopefully this is something that gets enable in future builds but for now this is a pretty good keyboard you can steal so you don't have to start from scratch.
On a side note you should upvote in Windows Feedback under "Developer Platform/ Windows 10 IoT Core". There should be a suggestion open.

I asked that question back in July on the MSDN forums. The answer that I got was:
"This has been answered here:
https://social.msdn.microsoft.com/Forums/en-US/d81ebfa0-ccdc-479e-8e2f-bc921de17343/onscreen-keyboard?forum=WindowsIoT
There's no onscreen keyboard available at the moment. There's the possibility that one will be added later, but it's not guaranteed. If you read the linked post you also find an explanation as to why none is available."
Just for reference, here's the link to the MSDN question that I asked: https://social.msdn.microsoft.com/Forums/en-US/9c95f424-f0ca-4751-9497-a019c1d40907/touch-keyboard?forum=WindowsIoT
And here's the answer from the linked post:
"At the moment there is no On-Screen Keyboard available. If you want a user to input something via the screen then you’ll want to provide the UI for that input in your application. Part of the reason for this is that we don’t have a ‘shell’ like explorer that is there helping control what app is running or providing other services such as SIP / OSK as is handled on the desktop.
Longer term I believe this is something that the product team is considering / looking into but I do not have any timeline on if or when it might be an option (if ever). If I learn otherwise I will let you know.
I hope that helps."

As mentioned in this answer, if you have the latest version, check On-Screen Keyboard from the Windows Device Portal.

From https://social.msdn.microsoft.com/Forums/en-US/d81ebfa0-ccdc-479e-8e2f-bc921de17343/onscreen-keyboard?forum=WindowsIoT : -
There is one available (I think since 14986). You have to enable it in
the device portal under "Device Settings" > "On-screen Keyboard".
Thursday, January 05, 2017 12:57 PM

I wanted to post the workaround that I came up with, but I didn't have enough rep points yet to include more than 2 links.
So I'm posting it as another answer.
Here it is:
And for those interested, I wrote up a very basic example of a osk-UI element. The Idea was to create something that could be reused if necessary. It's also not the fastest thing but maybe it will give you ideas.
Its basically a UserControl inside a Popup. When a Textbox gets focused, it fires an event that sets the "Keyboard Popup"'s DataContext to that of the Textbox and shows the "Keyboard".
I dropped it into a .zip file and uploaded it to my Box.com account.
Here's the project folder: https://app.box.com/s/vsf1wclaivsan4hhu2u2qdrb2awnbspu

Related

Is it possible to bind running application to a shortcut key?

Say I have started application on Windows (created in WPF for .NET in case that would help), that opens some windows/panels and just runs in a background. User don't want to interact with it constantly, however once in a while needs to urgently execute some actions in it.
Is it possible to bind some key shortcut e.g. alt+key to running application, so on hitting it app gets focus? It doesn't necessarily need to be brought to front, altough that would be nice as well.
"a hotkey that works out of your application" is this what you want?
if so, you need global hotkey that i can reference to!
(Sorry i didn't have enough reputation for commenting!)
I think I found sort of semi-solution, that doesn't need any coding or changing any system settings, but only:
1) keyboard with Windows key
2) possibly forcing user to re-arrange icons on his task bar (or pin my application as one of first 9 applications on his taskbar)
pressing WinKey+digit brings up digit'th application from the taskbar. Pressing it again hides it.
This works for Windows 7.
Obiously doing this way is a bit lame and not customizable at all, but it's always something... Still happy to find better way if there exists such.

Determining (programmatically) who controls the mouse on a PC using C# or C++

Is there a way to determine who is controlling the mouse (and which mouse) on a PC programmatically? I recently installed LogMeIn (logmein.com) and wanted to know if it's possible to (1) tell within a program if the mouse is being clicked/moved by the direct user or by a remote user, (2) write a stand-alone program that simply shows mouse events (on any application) and whether or not the mouse event was generated by a local or remote user. I am somewhat familiar with Win32 hooks, but don't think that they can give this sort of information. Regarding (1) it would seem like a common request. I.e. "Only allow user to complete button presses related to password change if he is local..." or something like that.
Of secondary importance (just academic interest actually) is the question of telling whether the local user is using the mouse or the trackpad.
you can hook the device API's of windows that you want to get the information from, then if the mouse moves the api is probably not called when the user movers the mouse, but if logmein does then it probably calls some SetMousePointerPos-like C WinAPI.
Since posting, I came across this post which basically answers the question.
C# Get Mouse handle (GetRawInputDeviceInfo)
I'd add that for those of you who want to use WPF instead of WinForms (as the example above uses), check out ComponentDispatcher.ThreadFilterMessage (for WPF) or IMessageFilter (Windows Forms).
I wrote a couple of programs based on the above posting (one is basically the posting above with some minor additions and the other is a WPF (as opposed to WinForms)). If I can figure out GitHub I'll post all the code and add a comment here. But the posting above definitely gives you all you need.

Handle button click in another application

I am looking for a method to get a button press event, something similar like this which is used to retrieve a pointer right after an event is fired. The button I mean is located on any particular windows application I set as a target (.eg windows media player's Play button). If you know what message to catch right after I click the Play button.
What you are looking for is Global Mouse Hook. You can take a look at this article: Processing Global Mouse and Keyboard Hooks in C#
Once you handle CLICK event, you can use API functions to get Application / Control under the cursor (WindowFromPoint).
Here is one more article with code sample that will help you: .NET Object Spy and InvokeRemote (this is similar to spy++)
You cannot do this without using windows native methods.
User tagged this in winapi. He probably already knew about hooks. Part of HABJAN reply point to the right direction. Answer to the question is: Use Spy++
I don't think there's a message for "button clicked" or "url link clicked" but if you observe a program with spy++ you'll see there's UI notification messages like these ones: WM_CAPTURECHANGED, WM_CHANGEUISTATE or even WM_POSCHANGING. I think these are the messages you are looking for.
Another way to do this may be to use the AutomationElement, see this answer: Getting the current tab's URL from Google Chrome using C#
PS: If I could downvote an edit by another user to a question, I would downvote Dyppl's edit... question used very precise words: "get message" instead of "handle" in the title.
PS2: It's an old question but I was asking me the same question earlier and came across it on google, maybe my answer will help someone

Entering text into a textbox that doesn't belong to your application (C#/.NET)

So, I was just wondering how I could enter text into a text box on a web page with a windows application.
Almost like a reverse screen scrape.
I know I have read somewhere about being able to do this but, I completely forgot how he did it. I think he may have been using Win32 DLLs which might be a fun endeavor but, getting off-topic now.
So, the question is: How can you inject text into text boxes that don't belong to your application with .NET (C#)
EDIT: Found my answer. See comments below.
Have a look at SendInput Win32 API. You'll need to focus on the correct window first, naturally. Also, it has some security restrictions on Vista and above, so that a low-privilege application cannot manipulate another one with higher privileges.

How to detect when screen brightness or system volume changed?

I want to detect when either of these changes and display an overlay on screen showing the current level. If there is a tool for this, then please point me to it. But if not how would I programatically get this (C#)?
The WmiMonitorBrightness class might be what you're looking for. You'll probably need to periodically query it to get changes.
If you talking about the softwares especially for laptops which OEMs like Dell/IBM etc give along with the windows installation to indicate brightness/voulme etc change then try this approach.
Install global message hooks and see what message is posted when volume/brightness buttons are clicked. You can use spy++ to detect the value of the message. In my opinion each vendor would have a different code for the buttons which are generally used along with the Function(Fn) key. Once you know the messages, make an application which installs a global hook for the system and display the animation or level bar as per your requirement.
The WmiMonitorBrightness class is supported for vista and above so if you using Win XP then it might not help you.

Categories